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;
}