Simple notepad, simple notepad camera
public partial class Form2 : Form { public Form2() { InitializeComponent(); } private Form1 jishiben; public Form2(Form1 f) { InitializeComponent(); jishiben = f; } public int index = -1; private void cha_Click(object sender, EventArgs e) { string mubiao = txtchazhao.Text; string yuanshuju = jishiben.txtjishiben.Text; index = yuanshuju.IndexOf(mubiao,index+1); if (index > -1) { jishiben.txtjishiben.Select(index, mubiao.Length); jishiben.Focus(); } } private void tihuan_Click(object sender, EventArgs e) { jishiben.txtjishiben.Text = jishiben.txtjishiben.Text.Replace(txtchazhao.Text,txttihuan.Text); } }
Public partial class Form1: Form {public Form1 () {InitializeComponent ();} private void open OToolStripMenuItem_Click (object sender, EventArgs e) {openFileDialog1.Filter = "Text Document | *. txt | all files | *. * "; DialogResult isok = openFileDialog1.ShowDialog (); if (isok = DialogResult. OK) {string filePath = openFileDialog1.FileName; this.txt jishiben. text = File. readAllText (filePath, Encoding. default); this. text = new FileInfo (filePath ). name; // get file Name} private void create NToolStripMenuItem_Click (object sender, EventArgs e) {this.txt jishiben. text = "";} Save private void as AToolStripMenuItem_Click (object sender, EventArgs e) {saveFileDialog1.Filter = "Text Document | *. txt | all files | *. * "; DialogResult isok = saveFileDialog1.ShowDialog (); if (isok = DialogResult. OK) {string filename = saveFileDialog1.FileName; // StreamWriter sw = new StreamWriter (filename); // sw.Write(this.txt jishiben. text); // sw. close (); File.WriteAllText(filename,this.txt jishiben. text, Encoding. default) ;}} private void save SToolStripMenuItem_Click (object sender, EventArgs e) {string path = openFileDialog1.FileName; string n = this.txt jishiben. text; File. writeAllText (path, n, Encoding. default);} private void exit XToolStripMenuItem_Click (object sender, EventArgs e) {this. close ();} private void Print outputs (object sender, EventArgs e) {printDialog1.Document = printDocument1; DialogResult isok = printDialog1.ShowDialog (); if (isok = DialogResult. OK) {printDocument1.Print () ;}} private void print preview VToolStripMenuItem_Click (object sender, EventArgs e) {response (); printPreviewDialog1.Document = printDocument1;} private void printdocument#printpage (object sender, System. drawing. printing. printPageEventArgs e) {System. drawing. font f = new System. drawing. font ("", 19.8f); e.Graphics.DrawString(this.txt jishiben. text, f, System. drawing. brushes. blue, new Point (100,100);} private void search ToolStripMenuItem_Click (object sender, EventArgs e) {Form2 f = new Form2 (this); f. show ();}}