首页 记事本源代码C#_cheaper

记事本源代码C#_cheaper

举报
开通vip

记事本源代码C#_cheaperC#编写的记事本 时间:2010-11-16 14:24:26来源:网络 作者:未知 点击:0次 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Printing; using System.Linq; using System.Text; using System.Windows. us...

记事本源代码C#_cheaper
C#编写的记事本 时间:2010-11-16 14:24:26来源:网络 作者:未知 点击:0次 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Printing; using System.Linq; using System.Text; using System.Windows. using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Drawing.Printing; using System.Linq; using System.Text; using System.Windows.Forms; using System.IO; using System.Diagnostics; namespace WindowsFormsApplication2 {     public partial class 记事本 : Form     {         private bool SaveBefore;         public 记事本()         {             InitializeComponent();         }         private void 记事本_Load(object sender, EventArgs e)         {             this.Text = "无标题-记事本";             this.Tag = "";             SaveBefore = true;             转到GToolStripMenuItem.Enabled = false;             if (richTextBox1.Text != "")             {                 查找FToolStripMenuItem.Enabled = true;                 查找下一个NToolStripMenuItem.Enabled = true;             }             else if (richTextBox1.Text == "")             {                 查找FToolStripMenuItem.Enabled = false;                 查找下一个NToolStripMenuItem.Enabled = false;             }         }         private void 记事本_FormClosing(object sender, FormClosingEventArgs e)         {             try             {                 if (this.Tag.ToString() == "")                 {                     Convert.ToDouble(this.Tag.ToString());                 }                 if (SaveBefore == false)                 {                     DialogResult dr = MessageBox.Show("文字已改变,您是否要保存到 " + this.Tag.ToString(), "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);                     if (dr == DialogResult.Yes)                     {                         this.richTextBox1.SaveFile(this.Tag.ToString(), RichTextBoxStreamType.PlainText);                         e.Cancel = false;                     }                     else if (dr == DialogResult.No)                     {                         e.Cancel = false;                     }                     else                     {                         e.Cancel = true;                     }                 }                 else                 {                     e.Cancel = false;                 }             }             catch              {                 if (this.richTextBox1.Text != "")                 {                     DialogResult dr = MessageBox.Show("文字已改变,您是否要保存到 无标题", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);                     if (dr == DialogResult.Yes)                     {                         if (sfd.ShowDialog() == DialogResult.OK)                         {                             this.richTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText);                             e.Cancel = false;                         }                         else                         {                             e.Cancel = true;                         }                     }                     else if (dr == DialogResult.No)                     {                         e.Cancel = false;                     }                     else                     {                         e.Cancel = true;                     }                 }                 else                 {                     e.Cancel = false;                 }             }         }         private void 新建NToolStripMenuItem_Click(object sender, EventArgs e)         {             try             {                 if (this.Tag.ToString() == "")                 {                     Convert.ToDouble(this.Tag.ToString());                 }                 if (SaveBefore == false)                 {                     DialogResult dr = MessageBox.Show("文字已改变,您是否要保存到 " + this.Tag.ToString(), "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);                     if (dr == DialogResult.Yes)                     {                         this.richTextBox1.SaveFile(this.Tag.ToString(), RichTextBoxStreamType.PlainText);                             this.richTextBox1.Text = "";                             this.Text = "无标题-记事本";                             this.Tag = "";                             SaveBefore = true;                     }                     else if (dr == DialogResult.No)                     {                         this.richTextBox1.Text = "";                         this.Text = "无标题-记事本";                         this.Tag = "";                         SaveBefore = true;                     }                     else                     {                         return;                     }                 }                 else                 {                     this.richTextBox1.Text = "";                     this.Text = "无标题-记事本";                     this.Tag = "";                     SaveBefore = true;                 }             }             catch             {                 if (this.richTextBox1.Text != "")                 {                     DialogResult dr = MessageBox.Show("文字已改变,您是否要保存到 无标题", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);                     if (dr == DialogResult.Yes)                     {                         if (sfd.ShowDialog() == DialogResult.OK)                         {                             this.richTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText);                             this.richTextBox1.Text = "";                             this.Text = "无标题-记事本";                             this.Tag = "";                             SaveBefore = true;                         }                         else                         {                             return ;                         }                     }                     else if (dr == DialogResult.No)                     {                         this.richTextBox1.Text = "";                         this.Text = "无标题-记事本";                         this.Tag = "";                         SaveBefore = true;                     }                     else                     {                         return;                     }                 }                 else                 {                     this.richTextBox1.Text = "";                     this.Text = "无标题-记事本";                     this.Tag = "";                     SaveBefore = true;                 }             }         }         private void 打开OToolStripMenuItem_Click(object sender, EventArgs e)         {             try             {                 if (this.Tag.ToString() == "")                 {                     Convert.ToDouble(this.Tag.ToString());                 }                 if (SaveBefore == false)                 {                     DialogResult dr = MessageBox.Show("文字已改变,您是否要保存到 " + this.Tag.ToString(), "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);                     if (dr == DialogResult.Yes)                     {                         this.richTextBox1.SaveFile(this.Tag.ToString(), RichTextBoxStreamType.PlainText);                         if (ofd.ShowDialog() == DialogResult.OK)                         {                             this.richTextBox1.LoadFile(ofd.FileName, RichTextBoxStreamType.PlainText);                             this.Tag = ofd.FileName;                             this.Text = Path.GetFileNameWithoutExtension(ofd.FileName) + "-记事本";                             SaveBefore = true;                         }                         else                         {                             return;                         }                     }                     else if (dr == DialogResult.No)                     {                         if (ofd.ShowDialog() == DialogResult.OK)                         {                             this.richTextBox1.LoadFile(ofd.FileName, RichTextBoxStreamType.PlainText);                             this.Tag = ofd.FileName;                             this.Text = Path.GetFileNameWithoutExtension(ofd.FileName) + "-记事本";                             SaveBefore = true;                         }                         else                         {                             return;                         }                     }                     else                     {                         return;                     }                 }                 else                 {                     if (ofd.ShowDialog() == DialogResult.OK)                     {                         this.richTextBox1.LoadFile(ofd.FileName, RichTextBoxStreamType.PlainText);                         this.Tag = ofd.FileName;                         this.Text = Path.GetFileNameWithoutExtension(ofd.FileName) + "-记事本";                         SaveBefore = true;                     }                     else                     {                         return;                     }                 }             }             catch             {                 if (this.richTextBox1.Text != "")                 {                     DialogResult dr = MessageBox.Show("文字已改变,您是否要保存到 无标题", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Information);                     if (dr == DialogResult.Yes)                     {                         if (sfd.ShowDialog() == DialogResult.OK)                         {                             this.richTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText);                             SaveBefore = true;                             if (ofd.ShowDialog() == DialogResult.OK)                             {                                 this.richTextBox1.LoadFile(ofd.FileName, RichTextBoxStreamType.PlainText);                                 this.Tag = ofd.FileName;                                 this.Text = Path.GetFileNameWithoutExtension(ofd.FileName) + "-记事本";                             }                             else                             {                                 return;                             }                         }                         else                         {                             return;                         }                     }                     else if (dr == DialogResult.No)                     {                         if (ofd.ShowDialog() == DialogResult.OK)                         {                             this.richTextBox1.LoadFile(ofd.FileName, RichTextBoxStreamType.PlainText);                             this.Tag = ofd.FileName;                             this.Text = Path.GetFileNameWithoutExtension(ofd.FileName) + "-记事本";                             SaveBefore = true;                         }                         else                         {                             return;                         }                     }                     else                     {                         return;                     }                     }                 else                 {                     if (ofd.ShowDialog() == DialogResult.OK)                     {                         this.richTextBox1.LoadFile(ofd.FileName, RichTextBoxStreamType.PlainText);                         this.Tag = ofd.FileName;                         this.Text = Path.GetFileNameWithoutExtension(ofd.FileName) + "-记事本";                         SaveBefore = true;                     }                     else                     {                         return;                     }                 }             }         }         private void 保存SToolStripMenuItem_Click(object sender, EventArgs e)         {             try             {                 if (this.Tag.ToString() == "")                 {                     Convert.ToDouble(this.Tag);                 }                 this.richTextBox1.SaveFile(this.Tag.ToString(), RichTextBoxStreamType.PlainText);                 SaveBefore = true;             }             catch             {                 if (sfd.ShowDialog() == DialogResult.OK)                 {                     this.richTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText);                     this.Text = Path.GetFileNameWithoutExtension(sfd.FileName) + "-记事本";                     this.Tag = sfd.FileName;                     SaveBefore = true;                 }                 else                 {                     return;                 }             }         }         private void 另存为AToolStripMenuItem_Click(object sender, EventArgs e)         {             if (sfd.ShowDialog() == DialogResult.OK)             {                 this.richTextBox1.SaveFile(sfd.FileName, RichTextBoxStreamType.PlainText);                 SaveBefore = true;                 this.Tag = sfd.FileName;                 this.Text = Path.GetFileNameWithoutExtension(sfd.FileName) + "-记事本";             }         }         private void 页面设置UToolStripMenuItem_Click(object sender, EventArgs e)         {             //PageSetupDialog psd = new PageSetupDialog() ;             psd.ShowDialog();         }         private void 打印PToolStripMenuItem_Click(object sender, EventArgs e)         {         }         private void 打印预览VToolStripMenuItem_Click(object sender, EventArgs e)         {         }         private void 退出XToolStripMenuItem_Click(object sender, EventArgs e)         {             this.Close();         }         private void 撤消UToolStripMenuItem_Click(object sender, EventArgs e)         {             this.richTextBox1.Undo();         }         private void 剪切TToolStripMenuItem_Click(object sender, EventArgs e)         {             richTextBox1.Cut();         }         private void 复制CToolStripMenuItem_Click(object sender, EventArgs e)         {             richTextBox1.Copy();         }         private void 粘贴PToolStripMenuItem_Click(object sender, EventArgs e)         {             richTextBox1.Paste();         }         private void 删除LToolStripMenuItem_Click(object sender, EventArgs e)         {             richTextBox1.SelectedText = "";         }         private void 查找FToolStripMenuItem_Click(object sender, EventArgs e)         {             查找 chazhao = new 查找();             chazhao.Owner = this;             chazhao.Show();         }         private void 查找下一个NToolStripMenuItem_Click(object sender, EventArgs e)         {             查找 chazhao = new 查找();             chazhao.Owner = this;             chazhao.Show();         }         private void 替换RToolStripMenuItem_Click(object sender, EventArgs e)         {             替换 tihuan = new 替换();             tihuan.Owner = this;             tihuan.Show();         }         private void 转到GToolStripMenuItem_Click(object sender, EventArgs e)         {         }         private void 全选AToolStripMenuItem_Click(object sender, EventArgs e)         {             richTextBox1.SelectAll();         }         private void 时间日期DToolStripMenuItem_Click(object sender, EventArgs e)         {             DateTime Time = DateTime.Now;             richTextBox1.Text += Time;          }//日期注入位置不对         private void 自动换行WToolStripMenuItem_Click(object sender, EventArgs e)         {             if (自动换行WToolStripMenuItem.CheckState == CheckState.Unchecked)             {                 this.richTextBox1.WordWrap =true;                 自动换行WToolStripMenuItem.CheckState = CheckState.Checked;             }             else if (自动换行WToolStripMenuItem.CheckState == CheckState.Checked)             {                 this.richTextBox1.WordWrap =false;                 自动换行WToolStripMenuItem.CheckState = CheckState.Unchecked;             }         }         private void 字体FToolStripMenuItem_Click(object sender, EventArgs e)         {             fd.ShowDialog();             richTextBox1.Font = fd.Font;         }         private void richTextBox1_Click(object sender, EventArgs e)         {             if (richTextBox1.SelectedText == "")             {                 复制CToolStripMenuItem.Enabled = false;                 复制toolStripMenuItem.Enabled = false;                 剪切TToolStripMenuItem.Enabled = false;                 剪切toolStripMenuItem.Enabled = false;                 删除LToolStripMenuItem.Enabled = false;                 删除toolStripMenuItem.Enabled = false;             }             else              {                 复制CToolStripMenuItem.Enabled = true;                 复制toolStripMenuItem.Enabled = true;                 剪切TToolStripMenuItem.Enabled = true;                 剪切toolStripMenuItem.Enabled = true;                 删除LToolStripMenuItem.Enabled = true;                 删除toolStripMenuItem.Enabled = true;             }             IDataObject data;             data = Clipboard.GetDataObject();             if (data.GetDataPresent(DataFormats.Text))             {                 粘贴PToolStripMenuItem.Enabled = true;                 粘贴toolStripMenuItem.Enabled = true;             }             else              {                 粘贴PToolStripMenuItem.Enabled = false;                 粘贴toolStripMenuItem.Enabled = false;             }             if (richTextBox1.Text != "")             {                 查找FToolStripMenuItem.Enabled = true;                 查找下一个NToolStripMenuItem.Enabled = true;             }             else             {                 查找FToolStripMenuItem.Enabled = false;                 查找下一个NToolStripMenuItem.Enabled = false;             }         }         private void richTextBox1_TextChanged(object sender, EventArgs e)         {             SaveBefore = false;             if (richTextBox1.Text != "")             {                 查找FToolStripMenuItem.Enabled = true;                 查找下一个NToolStripMenuItem.Enabled = true;             }             else if (richTextBox1.Text == "")             {                 查找FToolStripMenuItem.Enabled = false;                 查找下一个NToolStripMenuItem.Enabled = false;             }         }         private void 查看帮助HToolStripMenuItem_Click(object sender, EventArgs e)         {             MessageBox.Show("这是一个仿照windows的记事本应用程序");         }         private void 关于记事本AToolStripMenuItem_Click(object sender, EventArgs e)         {             MessageBox.Show("计算器---作者:陈林---联系方式QQ:772622524");                            }     } }
本文档为【记事本源代码C#_cheaper】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑, 图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。
下载需要: 免费 已有0 人下载
最新资料
资料动态
专题动态
is_788965
暂无简介~
格式:doc
大小:120KB
软件:Word
页数:14
分类:
上传时间:2011-04-08
浏览量:20