private void 打开OToolStripMenuItem_Click(object sender, EventArgs e)
{///打开文档;
OpenFileDialog ofd = new OpenFileDialog();
ofd.InitialDirectory = "c:\\";
ofd.RestoreDirectory = true;
ofd.Filter = "txt files(*.txt)|*.txt |RTF Files|*.rtf|All files(*.*)|*.*";
///注意:这前面的代码只可以放在对话框弹出以前,否则没有什么作用了!
if (ofd.ShowDialog() != DialogResult.OK)
{
return;
}
richTextBox1.LoadFile(ofd.FileName, RichTextBoxStreamType.PlainText);
}
private void 另存为GToolStripMenuItem_Click(object sender, EventArgs e)
{
SaveFileDialog sfd = new SaveFileDialog();
sfd.FilterIndex = 2;
sfd.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*"; ///文件类型;
sfd.RestoreDirectory = true;///是否还原开始打开的目录;
if(sfd.ShowDialog()!=DialogResult.OK){
return;
}
///直接进行操作;
///
richTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText); ///文件名,保存的文件格式;
MessageBox.Show("保存成功了");
}
private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
{
if(DialogResult.OK==MessageBox.Show("确定要退出吗?","提示",MessageBoxButtons.OKCancel,MessageBoxIcon.Question))
{
this.Close(); ///退出系统;
}
}
private void 字体FToolStripMenuItem_Click(object sender, EventArgs e)
{ ///字体设置;
FontDialog ftd = new FontDialog();
ftd.ShowColor = true;///是否获取选定项的颜色数据;
///
if(ftd.ShowDialog()!=DialogResult.OK){
return;
}
richTextBox1.SelectionFont = ftd.Font;///获取选定的字体设置;
///
richTextBox1.SelectionColor = ftd.Color;
}
private void Form1_Load(object sender, EventArgs e)
{
this.skinEngine1.SkinFile = "Calmness.ssk"; ///窗体样式的重新设置;
}
private void 背景KToolStripMenuItem_Click(object sender, EventArgs e)
{
ColorDialog cfd = new ColorDialog();
cfd.Color = richTextBox1.BackColor;/// 背景颜色;
///
cfd.ShowDialog();
richTextBox1.BackColor = cfd.Color;
}