VS编写的记事本源码
- 格式:doc
- 大小:309.00 KB
- 文档页数:11
记事本源代码先上效果图。
这个记事本操作简便,功能强⼤,在记事本的基础上添加了将内容发送短信和发送邮件的功能。
这个应⽤也已经功过了微软的认证。
115⽹盘⾥⾯的是最新的。
QQ:29992379下载地址:Memo.xap实体类1: public class Note2: {3: public string NoteGuid { get; set; }4: public string NoteContent { get; set; }5: public string NoteTime { get; set; }6: }在独⽴存储中⽣成存储结构。
1: if (!IsolatedStorageSettings.ApplicationSettings.Contains("Notes"))2: {3: List<Note> notes = new List<Note>();4: IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;5: IsolatedStorageSettings.ApplicationSettings.Save();6:7: }绑定⽂章的列表,并按编号倒排序。
1: public partial class MainPage : PhoneApplicationPage2: {3: // 构造函数4: public MainPage()5: {6: InitializeComponent();7: BingData();8: }9: List<Note> notes = new List<Note>();10: private void BingData()11: {12: notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;13:14: var descInfo = from i in notes orderby i.NoteTime descending select i;//linq对⽂章列表的排序15:16: MainListBox.ItemsSource = descInfo;17: }18:19: private void ApplicationBarIconButton_Click(object sender, EventArgs e)20: {21: NavigationService.Navigate(new Uri("/Add.xaml", UriKind.RelativeOrAbsolute));22: }23:24: protected override void OnBackKeyPress(ponentModel.CancelEventArgs e)25: {26: e.Cancel = true;27: App.Quit();28: base.OnBackKeyPress(e);29: }30:31: private void ApplicationBarIconButton_Click_1(object sender, EventArgs e)32: {33: NavigationService.Navigate(new Uri("/About.xaml", UriKind.RelativeOrAbsolute));34: }35:36: private void StackPanel_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)37: {38: string noteguid = ((TextBlock)(((StackPanel)sender).Children.First())).Tag.ToString();39: NavigationService.Navigate(new Uri("/DetailsPage.xaml?noteguid=" + noteguid, UriKind.Relative));40: }41: }⽂章显⽰的页⾯以及⼀系列功能1: public partial class DetailsPage : PhoneApplicationPage2: {3: // 构造函数4: public DetailsPage()5: {6: InitializeComponent();7: }8: string noteguid;9: protected override void OnNavigatedTo(NavigationEventArgs e)10: {11: BingData();12: noteguid = NavigationContext.QueryString["noteguid"].ToString();13: foreach (var item in notes)14: {15: if (item.NoteGuid==noteguid)16: {17: ContentText.Text = item.NoteContent;18: TimeText.Text = item.NoteTime;19: return;20: }21: }22: }23:24: List<Note> notes = new List<Note>();25: private void BingData()26: {27: notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;28: }29:30: private void Edit_Click(object sender, EventArgs e)31: {32: NavigationService.Navigate(new Uri("/Edit.xaml?noteguid=" + noteguid.ToString(), UriKind.RelativeOrAbsolute)); 33: }34:35: protected override void OnBackKeyPress(ponentModel.CancelEventArgs e)36: {37: e.Cancel = true;38: NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));39: base.OnBackKeyPress(e);40: }41:42: private void Del_Click(object sender, EventArgs e)43: {44: for (int i = 0; i < notes.Count; i++)45: {46: if (notes[i].NoteGuid==noteguid)47: {48: notes.RemoveAt(i);49: }50: }51: IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;52: IsolatedStorageSettings.ApplicationSettings.Save();53: NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute));54: }55:56: private void Email_Click(object sender, EventArgs e)57: {58: EmailComposeTask email = new EmailComposeTask();59: email.Body = ContentText.Text.ToString();60: email.Show();61: }62:63: private void Message_Click(object sender, EventArgs e)64: {65: SmsComposeTask sms = new SmsComposeTask();66: sms.Body = ContentText.Text.ToString();67: sms.Show();68: }69: }⽂章的编辑页⾯代码1: public partial class Edit : PhoneApplicationPage2: {3: public Edit()4: {5: InitializeComponent();6: }7:8: private void ApplicationBarIconButton_Click(object sender, EventArgs e)9: {10: foreach (var item in notes)11: {12: if (item.NoteGuid == noteguid)13: {14: item.NoteContent = ContentText.Text;15: item.NoteTime=TimeText.Text;16: }17: }18:19: IsolatedStorageSettings.ApplicationSettings["Notes"] = notes as List<Note>;20: IsolatedStorageSettings.ApplicationSettings.Save();21: NavigationService.Navigate(new Uri("/DetailsPage.xaml?noteguid=" + noteguid.ToString(), UriKind.RelativeOrAbsolute)); 22: }23: string noteguid;24: protected override void OnNavigatedTo(NavigationEventArgs e)25: {26: BingData();27: noteguid = NavigationContext.QueryString["noteguid"].ToString();28: foreach (var item in notes)29: {30: if (item.NoteGuid==noteguid)31: {32: ContentText.Text = item.NoteContent;33: TimeText.Text = item.NoteTime;34: return;35: }36: }37: }38:39: List<Note> notes = new List<Note>();40: private void BingData()41: {42: notes = IsolatedStorageSettings.ApplicationSettings["Notes"] as List<Note>;43: }44: }。
吉林电子信息职业技术学院JiLin Technical College of Electronic Information课程实训课程名称:_________ 《C#.NET》 ___________指导教师:____________________________________ 实训时间:___________________________________吉林电子信息职业技术学院吉林电子信息职业技术学院课程实训任务书姓名:院(系):计算机系专业:软件技术班级:10软件任务起至日期:综合实训题目:“记事本”的文本编辑器已知技术参数和设计要求:应用环境:Win dows Server 2000/2003/XPSQL Server 2005开发环境:VS2005应用模式:B/S设计要求:按题目要求完成数据库设计、系统功能设计、界面设计。
(1)能够实现基本的文本文件读取、保存、设置字体等功能。
(2)具有菜单、工具栏和状态栏。
(3)实现其它相关功能(如字体、剪切板的操作,查找、打印预览等功能)(4)实现多文档界面工作量:记事本的程序测试,修改,以及添加。
工作计划安排:1项目培训、选题、准备开发环境0.5天2 项目设计、制作2天3 测试、完善0.5天4 完成报告1天同组实训者及分工:同组实训者:本人完成工作如下:记事本的代码修改以及添加测试。
指导教师签字月日年教研室主任意见:教研室主任签字年月日*注:此任务书由课程设计指导教师填写。
综合评语:成绩评定:指导教师签字 ________________________ 年教研室主任意见:教研室主任签字 _______________________系部审核盖章: 教务处批准盖章:课程实训用纸第1章问题描述(1 )能够实现基本的文本文件读取、保存、设置字体等功能。
(2) 具有菜单、工具栏和状态栏。
(3) 实现其它相关功能(如字体、剪切板的操作,查找、打印预览等功能) (4) 实现多文档界面第2章总体设计第3章界面设计1 •文件操作:包括文件的新建、打开、保存、另存为、页面设置、打印及退 出。
记事本代码#include<iostream.h>#include<string.h>#include<ctype.h> //为了以下使用isdigit(string)函数作铺垫typedef struct node{char a[100]; //每行100字符node * next; //关于此处next的作用还不清楚,但不可去掉}node;class notepad{public:notepad(){i=1;line=0;}~notepad(){}void operator_interface();void input();void ct_input();void delete1();void copy();void paste();void open();void save();char * find();void print();char store[100]; //储存需复制内容private:char * ptr_array[100]; //指针数组,记录100行行指针int linelen[100]; //最大100行int line; //当前总行数char d[30]; //记录操作数据int k,l; //记录当前查找行ilint i; //文档录入初始标记};void notepad::operator_interface(){cout<<"********************************************************"<<en dl;cout<<"***0.继续录入文档"<<endl;cout<<"***1.输入文档内容"<<endl;cout<<"***2.删除某些内容"<<endl;cout<<"***3.复制某些内容"<<endl;cout<<"***4.粘贴某些内容"<<endl;cout<<"***5.打开文档内容"<<endl;cout<<"***6.是否保存文档"<<endl;cout<<"***7.获取操作帮助"<<endl;cout<<"***8.我要结束操作"<<endl;cout<<"********************************************************"<<en dl;}void notepad::input(){-99"<<endl; cout<<"输入总行数,格式:01char e[10];cin>>e;char *lin=e;if(*(lin+2)=='\0'&&isdigit(*lin)&&isdigit(*(lin+1))){line=(*lin-'0')*10+(*(lin+1)-'0');if(line!=0){cout<<"请输入各行内容"<<endl;while(i<=line){cout<<"第"<<i<<"行 ";node *p=new node;cin>>p->a;ptr_array[i]=p->a;linelen[i]=strlen(p->a);i++;}}else cout<<"你输入的行数有误"<<endl;}else cout<<"你输入的行数有误"<<endl; }void notepad::ct_input(){if(line!=0){int i=line+1;cout<<"输入要录入的总行数,格式:01-99"<<endl;char e[10];cin>>e;char *lin=e;if(*(lin+2)=='\0'&&isdigit(*lin)&&isdigit(*(lin+1))){ line=line+(*lin-'0')*10+(*(lin+1)-'0');if(line!=0){cout<<"请输入各行内容"<<endl;while(i<=line){cout<<"第"<<i<<"行 ";node *p=new node;cin>>p->a;ptr_array[i]=p->a;linelen[i]=strlen(p->a);i++;}}else cout<<"你输入的行数有误"<<endl;}else cout<<"你输入的行数有误"<<endl;}else cout<<"当前文档并无内容,请先输入1录入文档"<<endl; }void notepad::print(){cout<<endl<<endl;int j=1;cout<<"当前文档内容为:"<<endl;while(j<=line){cout<<"第"<<j<<"行 ";char *q=ptr_array[j];while(*q!='\0'){cout<<*q;q++;}cout<<endl;j++;}cout<<endl;}char * notepad::find(){ //暂未解决跨行查找问题k=1;cin>>d;l=strlen(d);char *n=d;int c=1;char *m=ptr_array[k];while(k<=line){if(*m=='\0'){k=k+1;if(k<=line)m=ptr_array[k];}if(*m!='\0'&&*m!=*n)m++;while(*n!='\0'&&*m!='\0'&&*m==*n){ m=m+1;n=n+1;c=c+1;}if(*n=='\0'){return m-c+1;}else {n=d;c=1;}}return NULL;}void notepad::delete1(){char * dp1;char * dp2;cout<<"请输入要删除的文本前几位字符,注意区分"<<endl;dp1=find();int l1=k;cout<<"请输入要删除的文本末几位字符,注意区分"<<endl;dp2=find();int l2=k;if(dp1==NULL||dp2==NULL||l1>l2)cout<<"输入错误"<<endl;else{dp2=dp2+l;if(l1==l2){while(*dp2!='\0'){*dp1=*dp2;dp1++;dp2++;}*dp1='\0';linelen[l1]=strlen(ptr_array[l1]);}else {if(l1+1<l2){for(intt1=l1+1,t2=l2;t2<=line;t1++,t2++)ptr_array[t1]=ptr_array[t2]; line=line-l2+l1+1;l2=l1+1;}*dp1='\0';char *dp21=ptr_array[l2];while(*(dp2-1)!='\0'){*dp21=*dp2;dp21++;dp2++;}linelen[l1]=strlen(ptr_array[l1]);linelen[l2]=strlen(ptr_array[l2]);}if(linelen[l1]==0){for(int v=l1;v<=line;v++)ptr_array[v]=ptr_array[v+1]; line--;}if(linelen[l2]==0){for(int v=l2;v<=line;v++)ptr_array[v]=ptr_array[v+1]; line--;}}}void notepad::copy(){char * cp1;char * cp2;cout<<"请输入要复制的文本前几位字符,注意区分"<<endl; cp1=find();int l1=k;cout<<"请输入要复制的文本末几位字符,注意区分"<<endl; cp2=find();int l2=k;char *pt=store;if(cp1!=NULL&&cp2!=NULL&&l1<=l2){cp2=cp2+l;while(cp1!=cp2){if(*cp1=='\0'){l1++;cp1=ptr_array[l1];}else {*pt=*cp1;pt++;cp1++;}}*pt='\0';}else cout<<"输入错误"<<endl; }void notepad::paste(){cout<<"请输入要粘贴位置的前几位字符(在首字符后粘贴)"<<endl; char *pat=find();if(pat!=NULL){int choice2;cout<<"请选择要粘贴内容:1/从内存中0/我自己输入"<<endl; cin>>choice2;if(!choice2)cin>>store;char *ppt=store;for(char *pat1=pat;*(pat1+1)!='\0';pat1++); //定位至末尾int pl=strlen(store);*(pat1+pl+1)='\0';while(pat1!=pat){ //移位*(pat1+pl)=*pat1;pat1--;}pat++;for(int u=1;u<=pl;u++){*pat=*ppt;ppt++;pat++;}linelen[k]=linelen[k]+pl;}else cout<<"输入错误"<<endl;}void notepad::open(){print();}void notepad::save(){cout<<"是否保存文件,1/是0/否"<<endl;char g[10];int choice1;cin>>g;char *choi=g;if(*(choi+1)=='\0'&&isdigit(*choi)){ choice1=*choi-'0';if(choice1==1)cout<<"文件已保存"<<endl; else if(choice1==0){for(int w=1;w<=line;w++){ //相当于析构函数的作用ptr_array[w]=NULL;linelen[w]=0;}line=0;}else cout<<"输入错误"<<endl;}else cout<<"输入错误"<<endl; }void main(){cout<<"欢迎使用本程序,您可以在要输入文档内容时通过切换输入法实现输入汉字,byhk"<<endl;notepad b;b.operator_interface();char f[10];int choice;cin>>f;char *choic=f;if(*(choic+1)=='\0'&&isdigit(*choic)){ //错误输入处理机制choice=*choic-'0';}else choice=9;while(choice!=8){switch(choice){case 0:b.ct_input();break;case 1:b.input();break;case 2:b.delete1();b.print();break;case 3:{b.copy();cout<<endl;char *p_t=b.store;int fzcd=strlen(b.store);cout<<"你所要复制的内容长度为"<<endl<<fzcd<<endl; cout<<"你所要复制的内容为"<<endl;while(*p_t!='\0'){cout<<*p_t;p_t++;}cout<<endl;}break;case 4:b.paste();b.print();break;case 5:b.open();break;case 6:b.save();break;case 7:b.operator_interface();break;case 8:break;default:break;}if(choice==9||(choice>=0&&choice<=7)){ //输入错误时的操作及输入正确时 //的继续操作判断if(choice==9)cout<<"你输入的操作有误,请重新输入,输入 7 获取操作帮助"<<endl;else cout<<"继续你的操作,输入 7 获取操作帮助"<<endl;cin>>f;choic=f;if(*(choic+1)=='\0'&&isdigit(*choic)) //错误输入处理机制choice=*choic-'0';else choice=9;}}cout<<"感谢您的使用"<<endl; }。
C#记事本源程序(VS2013)图1 程序设计界面程序源代码:using System;using System.Collections.Generic;using ponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.IO;using System.Windows.Forms;namespace 记事本{public partial class FormMain : Form{/// <summary>/// 判断是否需要保存/// </summary>private bool needToSave;/// <summary>/// 记录单前文件的路径及名字/// </summary>private string currentFileName = null;/// <summary>/// 记录打开的内容/// </summary>private string initText;/// <summary>/// 设置文本缩进的序号/// </summary>private int index=0;int start, end, location, erorr = 0;private System.Drawing.Printing.PrintDocument printDocument = newSystem.Drawing.Printing.PrintDocument();public FormMain(){InitializeComponent();}private void menuStrip1_ItemClicked(object sender, ToolStripItemClickedEventArgs e) {}private void ToolStripMenuItemNew_Click(object sender, EventArgs e){checkChange();if (needToSave == true){DialogResult result = MessageBox.Show("文本内容已改变需要保存吗?", "保存文件", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);switch (result){case DialogResult.Yes:{ToolStripMenuItemSave_Click(sender, e);textBoxEdit.Clear();this.Text = "文本编辑--新建文本";break;}case DialogResult.No:{textBoxEdit.Clear();this.Text = "文本编辑--新建文本";break;}case DialogResult.Cancel:{break;}}}else{textBoxEdit.Clear();this.Text = "文本编辑新建文本";}initText = textBoxEdit.Text;currentFileName = null;}private void ToolStripMenuItemSave_Click(object sender, EventArgs e){if (currentFileName == null){ToolStripMenuItemSaveAs_Click(sender, e);}else{saveFile(textBoxEdit.Text);initText = textBoxEdit.Text;}}private void ToolStripMenuItemOpen_Click(object sender, EventArgs e){checkChange();if (needToSave == true){DialogResult result = MessageBox.Show("文本内容已改变,是否保存?", "保存文件", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);if (result == DialogResult.Cancel){return;}if (result == DialogResult.Yes){ToolStripMenuItemSave_Click(sender, e);}}string file = GetOpenFile();if (file == null){return;}else{currentFileName = file;openFile();initText = textBoxEdit.Text;}}/// <summary>/// 打开文本文件/// </summary>private void openFile(){try{FileInfo f = new FileInfo(currentFileName);StreamReader reader = new StreamReader(currentFileName,System.Text.Encoding.Default);textBoxEdit.Text = reader.ReadToEnd();reader.Close();this.Text = "文本编辑--" + ;}catch (Exception e){MessageBox.Show(e.Message);}}/// <summary>/// 获得打开的文件的路径/// </summary>private string GetOpenFile(){OpenFileDialog openFile = new OpenFileDialog();openFile.Title = "打开本地文件";openFile.CheckFileExists = true;openFile.CheckPathExists = true;openFile.AddExtension = true;openFile.Multiselect = false;openFile.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";if (openFile.ShowDialog() == DialogResult.OK){return openFile.FileName;}else{return null;}}/// <summary>/// 文件保存/// </summary>/// <param name="str"></param>private void saveFile(string str){try{StreamWriter writer = new StreamWriter(currentFileName, false, System.Text.Encoding.Default);writer.Write(str);writer.Close();}catch (Exception e){MessageBox.Show(e.Message);}}private void FormMain_Load(object sender, EventArgs e){initText = textBoxEdit.Text;//判断剪切板里面有没有数据从而初始化按钮可用不可用DataFormats.Format textFormat = DataFormats.GetFormat(DataFormats.Text); if (textBoxEdit.CanPaste(textFormat)){ToolStripMenuItemUndo.Enabled = false;ToolStripMenuItemCut.Enabled = false;ToolStripMenuItemCopy.Enabled = false;ToolStripMenuItemFind.Enabled = false;ToolStripMenuItemReplace.Enabled = false;ToolStripMenuItemDelete.Enabled = false;ToolStripMenuItemSelectAll.Enabled = false;btnBack.Enabled = false;btnCopy.Enabled = false;btnCut.Enabled = false;btnSearch.Enabled = false;}else{ToolStripMenuItemUndo.Enabled = false;ToolStripMenuItemCut.Enabled = false;ToolStripMenuItemCopy.Enabled = false;ToolStripMenuItemFind.Enabled = false;ToolStripMenuItemReplace.Enabled = false;ToolStripMenuItemDelete.Enabled = false;ToolStripMenuItemSelectAll.Enabled = false;ToolStripMenuItemPaste.Enabled = false;btnBack.Enabled = false;btnCopy.Enabled = false;btnCut.Enabled = false;btnPaste.Enabled = false;btnSearch.Enabled = false;}}/// <summary>/// 获得要保存的文件/// </summary>/// <returns></returns>private string getSaveFile(){SaveFileDialog saveFile = new SaveFileDialog();saveFile.Title = "保存文本文件";saveFile.OverwritePrompt = true;saveFile.CreatePrompt = true;saveFile.AddExtension = true;saveFile.Filter = "文本文件(*.txt)|*.txt|所有文件(*.*)|*.*";if (saveFile.ShowDialog() == DialogResult.OK){return saveFile.FileName;}else{return null;}}/// <summary>/// 判断是否改变/// </summary>private void checkChange(){if (initText == textBoxEdit.Text){needToSave = false;}else{needToSave = true;}}private void ToolStripMenuItemSaveAs_Click(object sender, EventArgs e) {string file = getSaveFile();if (file == null){return;}else{currentFileName = file;saveFile(textBoxEdit.Text);FileInfo f = new FileInfo(currentFileName);this.Text = "文本编辑--" + ;initText = textBoxEdit.Text;}}private void ToolStripMenuItemPageSet_Click(object sender, EventArgs e) {PageSetupDialog pageSet = new PageSetupDialog();pageSet.Document = printDocument;pageSet.ShowDialog();}private void ToolStripMenuItemPrint_Click(object sender, EventArgs e) {PrintDialog printDialog = new PrintDialog();printDialog.Document = printDocument;if (printDialog.ShowDialog() == DialogResult.OK){try{printDocument.Print();}catch (Exception e1){MessageBox.Show(e1.Message);}}}private void ToolStripMenuItemExit_Click(object sender, EventArgs e){this.Close();}private void ToolStripMenuItemUndo_Click(object sender, EventArgs e){//如果可以进行撤消则进行撤消操作if (textBoxEdit.CanUndo == true){textBoxEdit.Undo();}}private void ToolStripMenuItemCut_Click(object sender, EventArgs e){//如果选中的内容不为空则进行剪切,同时复制和删除可用if (textBoxEdit.SelectedText != ""){textBoxEdit.Cut();ToolStripMenuItemCopy.Enabled = true;ToolStripMenuItemDelete.Enabled = true;}}private void ToolStripMenuItemCopy_Click(object sender, EventArgs e){//如果选中的内容长度大于0则可以进行复制if (textBoxEdit.SelectionLength > 0){textBoxEdit.Copy();}}private void ToolStripMenuItemPaste_Click(object sender, EventArgs e){//粘贴功能如果可以进行将系统剪切板的内容转换为Text格式的则进行粘贴if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text) == true) {//判断是否有被选中的内容如果有的话则询问是否要进行替换。
import java.awt.event.*;import java.awt.*;import java.io.*;import ng.String;class jsb implements ActionListener{Dialog bb;String strt;int i;FileDialog fd;File file;public Frame f;public TextArea p1;public MenuBar menubar;public Menu menu1,menu2,menu3;public MenuItem item1,item2,item3,item4,item5,item6,item7,item8,item9,item10; jsb(String s{ i=0;f=new Frame(s;p1=new TextArea("";f.setSize(500,500;f.setBackground(Color.white;f.setVisible(true;menubar=new MenuBar(;menu1=new Menu("文件";menu2=new Menu("编辑";menu3=new Menu("帮助";item1=new MenuItem("新建";item2=new MenuItem("打开";item3=new MenuItem("保存";item4=new MenuItem("另存为";item5=new MenuItem("退出";item6=new MenuItem("全选";item7=new MenuItem("复制";item8=new MenuItem("剪切";item9=new MenuItem("粘贴";item10=new MenuItem("关于";f.addWindowListener(new WindowAdapter({public void windowClosing(WindowEvent e {f.setVisible(false;System.exit(0;}};menu1.add(item1;menu1.add(item2;menu1.add(item3;menu1.add(item4;menu1.add(item5;menu2.add(item6;menu2.add(item7;menu2.add(item8;menu2.add(item9;menu3.add(item10;menubar.add(menu1;menubar.add(menu2;menubar.add(menu3;f.setMenuBar(menubar;item1.addActionListener(this;item2.addActionListener(this;item3.addActionListener(this;item4.addActionListener(this;item5.addActionListener(this;item6.addActionListener(this;item7.addActionListener(this;item8.addActionListener(this;item9.addActionListener(this;item10.addActionListener(this;f.setLayout(new GridLayout(1,1;f.add(p1;f.pack(;}public void actionPerformed(ActionEvent e { String ss;ss=p1.getText(.trim(;if (e.getSource(==item5{if (i==0 &&(ss.length(!=0{bc(;}else{System.exit(0;}}if (e.getSource(==item1{if (i==0&&(ss.length(!=0{bc(;}else{p1.setText("";i=0;f.setTitle("文件对话框"; } }if (e.getSource(==item2{fd=new FileDialog(f,"打开文件",0;fd.setVisible(true;try{file=new File(fd.getDirectory(,fd.getFile(;f.setTitle(fd.getFile(+"文件对话框"; FileReader fr=new FileReader(file; BufferedReader br=new BufferedReader(fr; String line = null;String view = "";while((line=br.readLine(!=null{view += line+"\n";}p1.setText(view;br.close(;fr.close(;}catch(IOException expIn{}}if (e.getSource(==item3{if (i==0{bc(;}else{try{file=new File(fd.getDirectory(,fd.getFile(;f.setTitle(fd.getFile(+"--记事本";FileWriter fw=new FileWriter(file; BufferedWriter bw=new BufferedWriter(fw; String s =p1.getText(;s = s.replaceAll("\n","\r\n";bw.write(s;bw.flush(;bw.close(;fw.close(;i=1;}catch(IOException expOut{i=0;}}}if (e.getSource(==item4{bc(;}if (e.getSource(==item10{bb=new Dialog(f,"关于";Label l1=new Label("本记事本的完成感谢老师和同学的帮助!!"; bb.add(l1; bb.setSize(250,150;bb.setBackground(Color.white;bb.show(;bb.addWindowListener(new WindowAdapter({public void windowClosing(WindowEvent e{bb.setVisible(false;bb.dispose(;}};}if (e.getSource(==item6{p1.setSelectionStart(0;p1.setSelectionEnd(p1.getText(.length(; }if (e.getSource(==item7{try{String str=p1.getSelectedText(;if(str.length(!=0{strt=str;}}catch(Exception ex{}}if (e.getSource(==item8{try{String str=p1.getSelectedText(;if(str.length(!=0{p1.replaceRange("",p1.getSelectionStart(,p1.getSelectionEnd(; } }catch(Exception ex{}}if (e.getSource(==item9{if(strt.length(>0{p1.insert(strt,p1.getCaretPosition(;}}}public void bc({fd=new FileDialog(f,"保存文件",1;fd.setVisible(true;try{file=new File(fd.getDirectory(,fd.getFile(;f.setTitle(fd.getFile(+"--记事本"; FileWriter fw=new FileWriter(file; BufferedWriter bw=new BufferedWriter(fw; String s =p1.getText(;s = s.replaceAll("\n","\r\n";bw.write(s;bw.flush(;bw.close(;fw.close(;i=1;}catch(IOException expOut{}} } public class EX0101 { public static void main(String args[] {jsb dd=new jsb("我的记事本";} }。
使用Windows自带的记事本编写简单代码在如今数字化的时代,编程不再是专业程序员的专属技能,普通人也可以通过简单的工具和基础的知识来体验编程的乐趣。
Windows 自带的记事本就是这样一个容易上手的工具,它虽然看似简单,但却能帮助我们编写一些简单的代码。
首先,让我们来了解一下记事本。
记事本是 Windows 操作系统中一个基本的文本编辑工具,它没有复杂的功能和花哨的界面,只有纯粹的文字编辑区域。
但这恰恰为我们编写代码提供了一个干净、简洁的环境。
当我们决定使用记事本编写代码时,第一步就是打开它。
在Windows 系统中,您可以通过点击“开始”菜单,然后在搜索框中输入“记事本”来找到并打开它。
或者,您也可以按下快捷键“Windows +R”,在弹出的“运行”对话框中输入“notepad”并回车。
接下来,让我们从一个简单的 HTML 代码开始入手。
HTML(超文本标记语言)是用于创建网页的基础语言。
以下是一个简单的 HTML代码示例,用于创建一个包含标题和段落的网页:```html<!DOCTYPE html><html><head><title>我的第一个网页</title></head><body><h1>这是一个标题</h1><p>这是一个段落。
</p></body></html>```在记事本中输入上述代码后,点击“文件”菜单,选择“另存为”。
在“文件名”框中,输入“my_first_webpagehtml”(注意,一定要加上“html”扩展名,否则浏览器无法正确识别它为 HTML 文件),然后选择保存类型为“所有文件”,最后选择一个您想要保存的位置,点击“保存”。
保存完成后,找到您保存的文件,双击它,它应该会在您的默认浏览器中打开,显示出您刚刚编写的网页内容,包含一个标题和一个段落。
除了 HTML,我们还可以使用记事本编写 Python 代码。
/*** 作品:记事本* 作者:**** 功能:简单的文字编辑*/import java.awt.*;import java.awt.event.*;import java.io.*;import javax.swing.*;import javax.swing.event.ChangeEvent;import javax.swing.event.ChangeListener;class NotePad extends JFrame{private JMenuBar menuBar;private JMenu fielMenu,editMenu,formMenu,aboutMenu;private JMenuItemnewMenuItem,openMenuItem,saveMenuItem,exitMenuItem;private JMenuItemcutMenuItem,copyMenuItem,pasteMenuItem,foundItem,replaceItem,s electAll;private JMenuItem font,about;private JTextArea textArea;private JFrame foundFrame,replaceFrame;private JCheckBoxMenuItem wrapline;private JTextField textField1=new JTextField(15);private JTextField textField2=new JTextField(15);private JButton startButton,replaceButton,reallButton;int start=0;String value;File file=null;JFileChooser fileChooser=new JFileChooser();boolean wrap=false;public NotePad(){//创建文本域textArea=new JTextArea();add(new JScrollPane(textArea),BorderLayout.CENTER);//创建文件菜单及文件菜单项fielMenu=new JMenu("文件");fielMenu.setFont(new Font("微软雅黑",0,15));newMenuItem=new JMenuItem("新建",newImageIcon("icons\\new24.gif"));newMenuItem.setFont(new Font("微软雅黑",Font.BOLD,13));newMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent. VK_N,InputEvent.CTRL_MASK));newMenuItem.addActionListener(listener);openMenuItem=new JMenuItem("打开",newImageIcon("icons\\open24.gif"));openMenuItem.setFont(new Font("微软雅黑",Font.BOLD,13));openMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent .VK_O,InputEvent.CTRL_MASK));openMenuItem.addActionListener(listener);saveMenuItem=new JMenuItem("保存",newImageIcon("icons\\save.gif"));saveMenuItem.setFont(new Font("微软雅黑",Font.BOLD,13));saveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent .VK_S,InputEvent.CTRL_MASK));saveMenuItem.addActionListener(listener);exitMenuItem=new JMenuItem("退出",newImageIcon("icons\\exit24.gif"));exitMenuItem.setFont(new Font("微软雅黑",Font.BOLD,13));exitMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent .VK_E,InputEvent.CTRL_MASK));exitMenuItem.addActionListener(listener);//创建编辑菜单及菜单项editMenu=new JMenu("编辑");editMenu.setFont(new Font("微软雅黑",0,15));cutMenuItem=new JMenuItem("剪切",newImageIcon("icons\\cut24.gif"));cutMenuItem.setFont(new Font("微软雅黑",Font.BOLD,13));cutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent. VK_X,InputEvent.CTRL_MASK));cutMenuItem.addActionListener(listener);copyMenuItem=new JMenuItem("复制",newImageIcon("icons\\copy24.gif"));copyMenuItem.setFont(new Font("微软雅黑",Font.BOLD,13));copyMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent .VK_C,InputEvent.CTRL_MASK));copyMenuItem.addActionListener(listener);pasteMenuItem=new JMenuItem("粘贴",newImageIcon("icons\\paste24.gif"));pasteMenuItem.setFont(new Font("微软雅黑",Font.BOLD,13));pasteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEven t.VK_V,InputEvent.CTRL_MASK));pasteMenuItem.addActionListener(listener);foundItem=new JMenuItem("查找");foundItem.setFont(new Font("微软雅黑",Font.BOLD,13));foundItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK _F,InputEvent.CTRL_MASK));foundItem.addActionListener(listener);replaceItem=new JMenuItem("替换");replaceItem.setFont(new Font("微软雅黑",Font.BOLD,13));replaceItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent. VK_R,InputEvent.CTRL_MASK));replaceItem.addActionListener(listener);selectAll=new JMenuItem("全选");selectAll.setFont(new Font("微软雅黑",Font.BOLD,13));selectAll.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK _A,InputEvent.CTRL_MASK));selectAll.addActionListener(listener);//创建格式菜单及菜单项formMenu=new JMenu("格式");formMenu.setFont(new Font("微软雅黑",0,15));wrapline=new JCheckBoxMenuItem("自动换行");wrapline.setFont(new Font("微软雅黑",Font.BOLD,13));wrapline.addActionListener(listener);wrapline.addChangeListener(new ChangeListener() {public void stateChanged(ChangeEvent e) {if(wrapline.isSelected()){textArea.setLineWrap(true);}elsetextArea.setLineWrap(false);}});font=new JMenuItem("字体");font.setFont(new Font("微软雅黑",Font.BOLD,13)); font.addActionListener(listener);//创建关于菜单aboutMenu=new JMenu("关于");aboutMenu.setFont(new Font("微软雅黑",0,15)); about=new JMenuItem("记事本……");about.setFont(new Font("微软雅黑",Font.BOLD,13)); about.addActionListener(listener);//添加文件菜单项fielMenu.add(newMenuItem);fielMenu.add(openMenuItem);fielMenu.add(saveMenuItem);fielMenu.addSeparator();fielMenu.add(exitMenuItem);//添加编辑菜单项editMenu.add(cutMenuItem);editMenu.add(copyMenuItem);editMenu.add(pasteMenuItem);editMenu.add(foundItem);editMenu.add(replaceItem);editMenu.addSeparator();editMenu.add(selectAll);//添加格式菜单项formMenu.add(wrapline);formMenu.add(font);//添加关于菜单项aboutMenu.add(about);//添加菜单menuBar=new JMenuBar();menuBar.add(fielMenu);menuBar.add(editMenu);menuBar.add(formMenu);menuBar.add(aboutMenu);setJMenuBar(menuBar);//创建两个框架,用作查找和替换foundFrame=new JFrame();replaceFrame=new JFrame();//创建两个文本框textField1=new JTextField(15);textField2=new JTextField(15);startButton=new JButton("开始");startButton.addActionListener(listener);replaceButton=new JButton("替换为");replaceButton.addActionListener(listener);reallButton=new JButton("全部替换");reallButton.addActionListener(listener);}//创建菜单项事件监听器ActionListener listener=new ActionListener() {public void actionPerformed(ActionEvent e) {String name=e.getActionCommand();if(e.getSource() instanceof JMenuItem){if("新建".equals(name)){textArea.setText("");file=null;}if("打开".equals(name)){if(file!=null){fileChooser.setSelectedFile(file);}intreturnVal=fileChooser.showOpenDialog(NotePad.this);if(returnVal==JFileChooser.APPROVE_OPTION){file=fileChooser.getSelectedFile();}try{FileReader reader=new FileReader(file);int len=(int)file.length();char[] array=new char[len];reader.read(array,0,len);reader.close();textArea.setText(new String(array));}catch(Exception e_open){e_open.printStackTrace();}}}if("保存".equals(name)){if(file!=null){fileChooser.setSelectedFile(file);}intreturnVal=fileChooser.showSaveDialog(NotePad.this);if(returnVal==JFileChooser.APPROVE_OPTION){file=fileChooser.getSelectedFile();}try{FileWriter writer=new FileWriter(file);writer.write(textArea.getText());writer.close();}catch (Exception e_save) {e_save.getStackTrace();}}if("退出".equals(name)){System.exit(0);}if("剪切".equals(name)){textArea.cut();}if("复制".equals(name)){textArea.copy();}if("粘贴".equals(name)){textArea.paste();}if("查找".equals(name)){value=textArea.getText();foundFrame.add(textField1,BorderLayout.CENTER);foundFrame.add(startButton,BorderLayout.SOUTH);foundFrame.setLocation(300,300);foundFrame.setTitle("查找");foundFrame.pack();foundFrame.setVisible(true);foundFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE );}if("替换".equals(name)){value=textArea.getText();JLabel label1=new JLabel("查找内容:");JLabel label2=new JLabel("替换为:");JPanel panel1=new JPanel();panel1.setLayout(new GridLayout(2,2));JPanel panel2=new JPanel();panel2.setLayout(new GridLayout(1,3));replaceFrame.add(panel1,BorderLayout.NORTH);replaceFrame.add(panel2,BorderLayout.CENTER);panel1.add(label1);panel1.add(textField1);panel1.add(label2);panel1.add(textField2);panel2.add(startButton);panel2.add(replaceButton);panel2.add(reallButton);replaceFrame.setTitle("替换");replaceFrame.setLocation(300,300);replaceFrame.pack();replaceFrame.setVisible(true);replaceFrame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLO SE);}if("开始".equals(name)||"下一个".equals(name)){String temp=textField1.getText();int s=value.indexOf(temp,start);if(value.indexOf(temp,start)!=-1){textArea.setSelectionStart(s);textArea.setSelectionEnd(s+temp.length());textArea.setSelectedTextColor(Color.GREEN);start=s+1;startButton.setText("下一个");}else {JOptionPane.showMessageDialog(foundFrame, "查找完毕!", "提示", 0,new ImageIcon("icons\\search.gif"));foundFrame.dispose();}}if("替换为".equals(name)){String temp=textField1.getText();int s=value.indexOf(temp,start);if(value.indexOf(temp,start)!=-1){textArea.setSelectionStart(s);textArea.setSelectionEnd(s+temp.length());textArea.setSelectedTextColor(Color.GREEN);start=s+1;textArea.replaceSelection(textField2.getText());}else {JOptionPane.showMessageDialog(foundFrame, "查找完毕!", "提示", 0,new ImageIcon("icons\\search.gif"));foundFrame.dispose();}}if("全部替换".equals(name)){String temp=textArea.getText();temp=temp.replaceAll(textField1.getText(),textField2.getTex t());textArea.setText(temp);}if("全选".equals(name)){textArea.selectAll();}if("字体".equals(name)){FontDialog fontDialog=newFontDialog(NotePad.this);fontDialog.setVisible(true);if(textArea.getFont()!=fontDialog.getFont()){textArea.setFont(fontDialog.getFont());}}if("记事本……".equals(name)){AboutDialog aboutDialog=newAboutDialog(NotePad.this);aboutDialog.setVisible(true);}}};//创建字体设置对话面板,并添加相应事件监听器class FontDialog extends JDialog implements ItemListener, ActionListener, WindowListener{public JCheckBox Bold=new JCheckBox("Bold",false);public JCheckBox Italic=new JCheckBox("Italic",false);public List Size,Name;public int FontName;public int FontStyle;public int FontSize;public JButton OK=new JButton("OK");public JButton Cancel=new JButton("Cancel");public JTextArea Text=new JTextArea("字体预览文本域\n0123456789\nAaBbCcXxYyZz");public FontDialog(JFrame owner) {super(owner,"字体设置",true);GraphicsEnvironmentg=GraphicsEnvironment.getLocalGraphicsEnvironment();String name[]=g.getAvailableFontFamilyNames();Name=new List();Size=new List();FontName=0;FontStyle=0;FontSize=8;int i=0;Name.add("Default Value");for(i=0;i<name.length;i++)Name.add(name[i]);for(i=8;i<257;i++)Size.add(String.valueOf(i));this.setLayout(null);this.setBounds(250,200,480, 306);this.setResizable(false);OK.setFocusable(false);Cancel.setFocusable(false);Bold.setFocusable(false);Italic.setFocusable(false);Name.setFocusable(false);Size.setFocusable(false);Name.setBounds(10, 10, 212, 259);this.add(Name);Bold.setBounds(314, 10, 64, 22);this.add(Bold);Italic.setBounds(388, 10, 64, 22);this.add(Italic);Size.setBounds(232, 10, 64, 259);this.add(Size);Text.setBounds(306, 40, 157, 157);this.add(Text);OK.setBounds(306, 243, 74, 26);this.add(OK);Cancel.setBounds(390, 243, 74, 26);this.add(Cancel);Name.select(FontName);Size.select(FontSize);Text.setFont(getFont());Name.addItemListener(this);Size.addItemListener(this);Bold.addItemListener(this);Italic.addItemListener(this);OK.addActionListener(this);Cancel.addActionListener(this);this.addWindowListener(this);}public void itemStateChanged(ItemEvent e) {Text.setFont(getFont());}public void actionPerformed(ActionEvent e) {if(e.getSource()==OK){FontName=Name.getSelectedIndex();FontStyle=getStyle();FontSize=Size.getSelectedIndex();this.setVisible(false);}else cancel();}public void windowClosing(WindowEvent e) {cancel();}public Font getFont(){if(Name.getSelectedIndex()==0) return new Font("新宋体",getStyle(),Size.getSelectedIndex()+8);else return newFont(Name.getSelectedItem(),getStyle(),Size.getSelectedIndex() +8);}public void cancel(){Name.select(FontName);Size.select(FontSize);setStyle();Text.setFont(getFont());this.setVisible(false);}public void setStyle(){if(FontStyle==0 || FontStyle==2)Bold.setSelected(false);else Bold.setSelected(true);if(FontStyle==0 || FontStyle==1)Italic.setSelected(false);else Italic.setSelected(true);}public int getStyle(){int bold=0,italic=0;if(Bold.isSelected()) bold=1;if(Italic.isSelected()) italic=1;return bold+italic*2;}public void windowActivated(WindowEvent arg0) {}public void windowClosed(WindowEvent arg0) {}public void windowDeactivated(WindowEvent arg0) {}public void windowDeiconified(WindowEvent arg0) {}public void windowIconified(WindowEvent arg0) {}public void windowOpened(WindowEvent arg0) {} }//创建关于对话框class AboutDialog extends JDialog implements ActionListener{ public JButton OK,Icon;public JLabel Name,Version,Author,Java;public JPanel Panel;AboutDialog(JFrame owner) {super(owner,"关于",true);OK=new JButton("OK");Icon=new JButton(new ImageIcon("icons\\edit.gif"));Name=new JLabel("Notepad");Version=new JLabel("Version 1.0");Java=new JLabel("JRE Version 6.0");Author=new JLabel("Copyright (c) 11-5-2012 By Jianmin Chen");Panel=new JPanel();Color c=new Color(0,95,191);Name.setForeground(c);Version.setForeground(c);Java.setForeground(c);Author.setForeground(c);Panel.setBackground(Color.white);OK.setFocusable(false);this.setBounds(250,200,280, 180);this.setResizable(false);this.setLayout(null);Panel.setLayout(null);OK.addActionListener(this);Icon.setFocusable(false);Icon.setBorderPainted(false);Author.setFont(new Font(null,Font.PLAIN,11));Panel.add(Icon);Panel.add(Name);Panel.add(Version);Panel.add(Author);Panel.add(Java);this.add(Panel);this.add(OK);Panel.setBounds(0, 0, 280, 100);OK.setBounds(180, 114, 72, 26);Name.setBounds(80, 10, 160, 20);Version.setBounds(80, 27, 160, 20);Author.setBounds(15, 70, 250, 20);Java.setBounds(80, 44, 160, 20);Icon.setBounds(16, 14, 48, 48);}public void actionPerformed(ActionEvent e) { this.setVisible(false);}}}//创建记事本public class ChenJianmin {public static void main(String[] args){EventQueue.invokeLater(new Runnable() {public void run() {NotePad notePad=new NotePad();notePad.setTitle("记事本");notePad.setVisible(true);notePad.setBounds(100,100,800,600);notePad.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}});}}。
记事本一、打开visual studio 新建——项目——windows窗体应用程序命名:年终大作业;二、Form.cs中作如下操作:三、在工具箱中选择如下控件:menuStrip、contextMenustrip、colordialog、savefiledialog、folderbrowserdialog、fontdialog、openfiledialog、statustrip 、Folderbrowserdialog四、单击menuStrip并输入文件(&F),双击后输入新建(&N)并单击新建在属性中的shortkeys中选择Ctl+N;并在那么属性中改名为“新建”、后面类似;五、单击statustrip在其属性中的item属性中选择添加label4个;六、分别输入以下代码:using System;七、using System.Collections.Generic;八、using ponentModel;九、using System.Data;十、using System.Drawing;十一、using System.Linq;十二、using System.Text;十三、using System.Windows.Forms;十四、using System.IO;十五、十六、十七、namespace 年终大作业十八、{十九、public partial class Form1 : Form二十、{二十一、public Form1()二十二、{二十三、InitializeComponent();二十四、}二十五、二十六、private void 新建_Click(object sender, EventArgs e)二十七、{二十八、this.richTextBox1.Text="";二十九、}三十、三十一、private void 打开_Click(object sender, EventArgs e)三十二、{三十三、openFileDialog1.FileName = "";三十四、openFileDialog1.Filter = "RTF File(*.rtf)|*.RTF|TXT FILE(*.txt)|*.txt";三十五、openFileDialog1.ShowDialog();三十六、if (openFileDialog1.FileName != "")三十七、switch (openFileDialog1.FilterIndex)三十八、{三十九、case 1: //选择的是.rtf类型四十、richTextBox1.LoadFile(openFileDialog1.FileName,RichTextBoxStreamType.RichText);四十一、break;四十二、case 2: //选择的是.txt类型四十三、richTextBox1.LoadFile(openFileDialog1.FileName,RichTextBoxStreamType.PlainText);四十四、break;四十五、}四十六、}四十七、四十八、private void 保存_Click(object sender, EventArgs e)四十九、{五十、saveFileDialog1.Filter = "RTF File(*.rtf)|*.RTF|TXT FILE(*.txt)|*.txt";五十一、if (saveFileDialog1.ShowDialog() == DialogResult.OK) 五十二、switch (openFileDialog1.FilterIndex)五十三、{五十四、case 1: //选择的是.rtf类型五十五、richTextBox1.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.RichText);五十六、break;五十七、case 2: //选择的是.txt类型五十八、richTextBox1.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.PlainText);五十九、break;六十、}六十一、}六十二、六十三、private void 另存为_Click(object sender, EventArgs e)六十四、{六十五、saveFileDialog1.Filter = "RTF File(*.rtf)|*.RTF|TXT FILE(*.txt)|*.txt";六十六、if (saveFileDialog1.ShowDialog() == DialogResult.OK) 六十七、switch (openFileDialog1.FilterIndex)六十八、{六十九、case 1: //选择的是.rtf类型七十、richTextBox1.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.RichText);七十一、break;七十二、case 2: //选择的是.txt类型七十三、richTextBox1.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.PlainText);七十四、break;七十五、}七十六、}七十七、七十八、private void 退出_Click(object sender, EventArgs e)七十九、{八十、// 退出时应提示用户是否保存当前文本文件八十一、DialogResult result = MessageBox.Show("是否将更改保存?", "Mickey温馨提示", MessageBoxButtons.YesNoCancel,rmation);八十二、if (result == DialogResult.Yes)八十三、{八十四、saveFileDialog1.Filter = "RTF File(*.rtf)|*.RTF|TXT FILE(*.txt)|*.txt";八十五、if (saveFileDialog1.ShowDialog() == DialogResult.OK)八十六、switch (openFileDialog1.FilterIndex) 八十七、{八十八、case 1: //选择的是.rtf类型八十九、richTextBox1.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.RichText);九十、break;九十一、case 2: //选择的是.txt类型九十二、richTextBox1.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.PlainText);九十三、break;九十四、}九十五、Application.Exit();九十六、this.Close();九十七、}九十八、else if (result == DialogResult.No)九十九、{百、Application.Exit();百一、}百二、}百三、百四、private void 撤销_Click(object sender, EventArgs e) 百五、{百六、richTextBox1.Undo();百七、}百八、百九、private void 剪切_Click(object sender, EventArgs e)百十、{百十一、richTextBox1.Cut();百十二、}百十三、百十四、private void 复制_Click(object sender, EventArgs e)百十五、{百十六、richTextBox1.Copy();百十七、}百十八、百十九、private void 粘贴_Click(object sender, EventArgs e)百二十、{百二十一、richTextBox1.Paste();百二十二、}百二十三、百二十四、private void 删除_Click(object sender, EventArgs e)百二十五、{百二十六、richTextBox1.Clear();百二十七、}百二十八、百二十九、private void 全选_Click(object sender, EventArgs e)百三十、{百三十一、richTextBox1.SelectAll();百三十二、}百三十三、百三十四、private void 时间日期_Click(object sender, EventArgs e) 百三十五、{百三十六、richTextBox1.SelectedText =System.DateTime.Now.ToLocalTime().ToString();百三十七、}百三十八、百三十九、private void 自动换行_Click(object sender, EventArgs e) 百四十、{百四十一、if (richTextBox1.WordWrap == true)百四十二、{百四十三、自动换行.Checked = true;百四十四、richTextBox1.WordWrap = false;百四十五、百四十六、}百四十七、else百四十八、{百四十九、自动换行.Checked = false;百五十、richTextBox1.WordWrap = true;百五十一、}百五十二、}百五十三、百五十四、private void 背景颜色_Click(object sender, EventArgs e) 百五十五、{百五十六、colorDialog1.ShowDialog();百五十七、richTextBox1.BackColor = colorDialog1.Color;百五十八、}百五十九、百六十、private void 状态栏_Click(object sender, EventArgs e) 百六十一、{百六十二、if (statusStrip1.Visible == true)百六十三、{百六十四、状态栏.Checked = false;百六十五、statusStrip1.Visible = false;百六十六、}百六十七、else百六十八、{百六十九、状态栏.Checked = true;百七十、statusStrip1.Visible = true;百七十一、}百七十二、}百七十三、百七十四、private void 右撤销_Click(object sender, EventArgs e) 百七十五、{百七十六、richTextBox1.Undo();百七十七、}百七十八、百七十九、private void 右剪切_Click(object sender, EventArgs e)百八十、{百八十一、richTextBox1.Cut();百八十二、}百八十三、百八十四、private void 右复制_Click(object sender, EventArgs e)百八十五、{百八十六、richTextBox1.Copy();百八十七、}百八十八、百八十九、private void 右粘贴_Click(object sender, EventArgs e)百九十、{百九十一、richTextBox1.Paste();百九十二、}百九十三、百九十四、private void 右删除_Click(object sender, EventArgs e)百九十五、{百九十六、richTextBox1.Clear();百九十七、}百九十八、百九十九、private void 右全选_Click(object sender, EventArgs e)二百、{二百一、richTextBox1.SelectAll();二百二、}二百三、二百四、private void 字体颜色_Click_1(object sender, EventArgse)二百五、{二百六、fontDialog1.AllowVectorFonts = true;//设置用户可以选择矢量字体二百七、fontDialog1.AllowVerticalFonts = true;//设置字体对话框既显示水平字体,也显示垂直字体二百八、fontDialog1.FixedPitchOnly = false;//设置用户可以选择不固定间距的字体二百九、fontDialog1.MaxSize = 72;//设置可选择的最大字二百十、fontDialog1.MinSize = 5;//设置可选择的最小字二百十一、if (fontDialog1.ShowDialog() == DialogResult.OK)//判断是否选择了字体二百十二、{二百十三、if (richTextBox1.SelectedText == "")//判断是否选择了文本二百十四、richTextBox1.SelectAll();//全选文本二百十五、richTextBox1.SelectionFont = fontDialog1.Font;//设置选中的文本字体二百十六、}二百十七、colorDialog1.AllowFullOpen = true;//设置允许用户自定义颜色二百十八、colorDialog1.AnyColor = true;//设置颜色对话框中显示所有颜色二百十九、colorDialog1.SolidColorOnly = false;//设置用户可以在颜色对话框中选择复杂颜色二百二十、if (colorDialog1.ShowDialog() == DialogResult.OK)//判断是否选择了颜色二百二十一、{二百二十二、if (richTextBox1.SelectedText == "")//判断是否选择了文本二百二十三、richTextBox1.SelectAll();//全选文本二百二十四、richTextBox1.SelectionColor = colorDialog1.Color;//将选定的文本颜色设置为颜色对话框中选择的颜色二百二十五、}二百二十六、二百二十七、}二百二十八、二百二十九、private void Form1_FormClosed(object sender, FormClosedEventArgs e)二百三十、{二百三十一、// 退出时应提示用户是否保存当前文本文件二百三十二、DialogResult result = MessageBox.Show("是否将更改保存?", "Mickey温馨提示", MessageBoxButtons.YesNoCancel,rmation);二百三十三、if (result == DialogResult.Yes)二百三十四、{二百三十五、saveFileDialog1.Filter = "RTFFile(*.rtf)|*.RTF|TXT FILE(*.txt)|*.txt";二百三十六、if (saveFileDialog1.ShowDialog() == DialogResult.OK)二百三十七、switch (openFileDialog1.FilterIndex)二百三十八、{二百三十九、case 1: //选择的是.rtf类型二百四十、richTextBox1.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.RichText);二百四十一、break;二百四十二、case 2: //选择的是.txt类型二百四十三、richTextBox1.SaveFile(saveFileDialog1.FileName,RichTextBoxStreamType.PlainText);二百四十四、break;二百四十五、}二百四十六、Application.Exit();二百四十七、}二百四十八、MessageBox.Show("谢谢使用!"+DateTime.Now );二百四十九、}二百五十、二百五十一、private void 关于主题_Click(object sender, EventArgse)二百五十二、{二百五十三、主题();二百五十四、}二百五十五、private void 主题()二百五十六、{二百五十七、string str = "本程序由本人初次制作,内容可能还有些许漏洞,如果在您使用过程中发现问题,敬请联系本人。