using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; namespace 记事本 { public partial class notebook : Form { #region 初始变量 bool Status = false;//状态栏的显示状态 bool WordWrap = false;//显示是否自动换行 bool newnote = true;//是否是新建文档 string str = "";//中间变量,判断文本框的值是否改变 bool RighttoLeft = false;//是否从右向左读 public notebook() { InitializeComponent(); }//窗体的初始化 #endregion #region 文件 //实现创建一个新的文本功能 private void 新建NToolStripMenuItem_Click( object sender, EventArgs e) { try { //如果是新建文档,按以下方式 if (newnote) { if (richTextBox1.Text != "") { DialogResult r = MessageBox.Show(" 是否将更改保存到 无标题?" , "记事本" , MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); int g = (int)r; if (g == 6) { saveFileDialog1.Title = "保存" ; saveFileDialog1.FileName = "无标题" ; saveFileDialog1.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*" ; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { FileStream fr = (FileStream)saveFileDialog1.OpenFile(); StreamWriter w = new StreamWriter(fr); w.Write(richTextBox1.Text); w.Flush(); w.Close(); fr.Close(); richTextBox1.Clear(); this.Text = "无标题 - 记事本" ; } } else if (g == 7) { richTextBox1.Clear(); this.Text = "无标题 - 记事本" ; } else { return; } } else { richTextBox1.Clear(); this.Text = "无标题 - 记事本" ; } } //不是新建文档 else { if (richTextBox1.Text == str) { richTextBox1.Clear(); this.Text = "无标题 - 记事本" ; } else { DialogResult q = MessageBox.Show("是否将更改保存到 " + openFileDialog1.SafeFileName + " ?", "记事本" , MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question); int p = (int)q; if (p == 6) { St...