//notepad.cs
//==========================
using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using System.IO;
namespace csnotepad { /// /// Summary description for Form1. /// public class notepad : System.Windows.Forms.Form { private System.Windows.Forms.MainMenu mainMenu1; private System.Windows.Forms.MenuItem menuItem1; private System.Windows.Forms.MenuItem menuItem2; private System.Windows.Forms.MenuItem menuItem3; private System.Windows.Forms.MenuItem menuItem4; private System.Windows.Forms.MenuItem menuItem5; private System.Windows.Forms.MenuItem menuItem6; private System.Windows.Forms.MenuItem menuItem7; private System.Windows.Forms.MenuItem menuItem8; private System.Windows.Forms.MenuItem menuItem9; private System.Windows.Forms.MenuItem menuItem10; private System.Windows.Forms.MenuItem menuItem11; private System.Windows.Forms.MenuItem menuItem12; private System.Windows.Forms.TextBox textBox1; private System.Windows.Forms.MenuItem menuItem14; private System.Windows.Forms.SaveFileDialog saveFileDialog1; private System.Windows.Forms.MenuItem menuItem13; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.MenuItem menuItem15; private System.Windows.Forms.MenuItem menuItem16; /// /// Required designer variable. /// private System.ComponentModel.Container components = null;
public notepad() { // // Required for Windows Form Designer support // InitializeComponent();
// // TODO: Add any constructor code after InitializeComponent call // }
/// /// Clean up any resources being used. /// protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Dispose(); } } base.Dispose( disposing ); }
#region Windows Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.mainMenu1 = new System.Windows.Forms.MainMenu(); this.menuItem1 = new System.Windows.Forms.MenuItem(); this.menuItem2 = new System.Windows.Forms.MenuItem(); this.menuItem3 = new System.Windows.Forms.MenuItem(); this.menuItem13 = new System.Windows.Forms.MenuItem(); this.menuItem4 = new System.Windows.Forms.MenuItem(); this.menuItem14 = new System.Windows.Forms.MenuItem(); this.menuItem5 = new System.Windows.Forms.MenuItem(); this.menuItem6 = new System.Windows.Forms.MenuItem(); this.menuItem7 = new System.Windows.Forms.MenuItem(); this.menuItem8 = new System.Windows.Forms.MenuItem(); this.menuItem9 = new System.Windows.Forms.MenuItem(); this.menuItem10 = new System.Windows.Forms.MenuItem(); this.menuItem11 = new System.Windows.Forms.MenuItem(); this.menuItem12 = new System.Windows.Forms.MenuItem(); this.menuItem15 = new System.Windows.Forms.MenuItem(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog(); this.textBox1 = new System.Windows.Forms.TextBox(); this.menuItem16 = new System.Windows.Forms.MenuItem(); this.SuspendLayout(); // // mainMenu1 // this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem1, this.menuItem6, this.menuItem11, this.menuItem15}); // // menuItem1 // this.menuItem1.Index = 0; this.menuItem1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem2, this.menuItem3, this.menuItem13, this.menuItem4, this.menuItem14, this.menuItem5}); this.menuItem1.Text = "文件"; // // menuItem2 // this.menuItem2.Index = 0; this.menuItem2.Text = "&New"; this.menuItem2.Click += new System.EventHandler(this.menuItem2_Click); // // menuItem3 // this.menuItem3.Index = 1; this.menuItem3.Text = "&Open"; this.menuItem3.Click += new System.EventHandler(this.menuItem3_Click); // // menuItem13 // this.menuItem13.Index = 2; this.menuItem13.Text = "-"; // // menuItem4 // this.menuItem4.Index = 3; this.menuItem4.Text = "&Save"; this.menuItem4.Click += new System.EventHandler(this.menuItem4_Click); // // menuItem14 // this.menuItem14.Index = 4; this.menuItem14.Text = "-"; // // menuItem5 // this.menuItem5.Index = 5; this.menuItem5.Text = "Exit"; this.menuItem5.Click += new System.EventHandler(this.menuItem5_Click_1); // // menuItem6 // this.menuItem6.Index = 1; this.menuItem6.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem7, this.menuItem8, this.menuItem9, this.menuItem10}); this.menuItem6.Text = "编辑"; // // menuItem7 // this.menuItem7.Index = 0; this.menuItem7.Text = "&Cut"; this.menuItem7.Click += new System.EventHandler(this.menuItem7_Click); // // menuItem8 // this.menuItem8.Index = 1; this.menuItem8.Text = "&Copy"; this.menuItem8.Click += new System.EventHandler(this.menuItem8_Click); // // menuItem9 // this.menuItem9.Index = 2; this.menuItem9.Text = "Paste"; this.menuItem9.Click += new System.EventHandler(this.menuItem9_Click); // // menuItem10 // this.menuItem10.Index = 3; this.menuItem10.Text = "&Select All"; this.menuItem10.Click += new System.EventHandler(this.menuItem10_Click); // // menuItem11 // this.menuItem11.Index = 2; this.menuItem11.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItem12, this.menuItem16}); this.menuItem11.Text = "帮助"; // // menuItem12 // this.menuItem12.Index = 0; this.menuItem12.Text = "About"; this.menuItem12.Click += new System.EventHandler(this.menuItem12_Click); // // menuItem15 // this.menuItem15.Index = 3; this.menuItem15.Text = ""; // // saveFileDialog1 // this.saveFileDialog1.FileName = "doc1"; // // textBox1 // this.textBox1.Dock = System.Windows.Forms.DockStyle.Fill; this.textBox1.Multiline = true; this.textBox1.Name = "textBox1"; this.textBox1.ScrollBars = System.Windows.Forms.ScrollBars.Vertical; this.textBox1.Size = new System.Drawing.Size(544, 321); this.textBox1.TabIndex = 0; this.textBox1.Text = ""; this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged_1); // // menuItem16 // this.menuItem16.Index = 1; this.menuItem16.Text = "General"; this.menuItem16.Click += new System.EventHandler(this.menuItem16_Click); // // notepad // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(544, 321); this.Controls.AddRange(new System.Windows.Forms.Control[] { this.textBox1}); this.ImeMode = System.Windows.Forms.ImeMode.Off; this.Menu = this.mainMenu1; this.Name = "notepad"; this.Text = "Notepad By 【孟宪会之精彩世界】"; this.Load += new System.EventHandler(this.Form1_Load); this.ResumeLayout(false);
} #endregion
/// /// The main entry point for the application. /// [STAThread] static void Main() { Application.Run(new notepad()); }
private void Form1_Load(object sender, System.EventArgs e) {
}
private void menuItem3_Click(object sender, System.EventArgs e) { // for opening file openFileDialog1.ShowDialog(); StreamReader sr = new StreamReader(openFileDialog1.FileName); textBox1.Text = sr.ReadToEnd(); sr.Close(); }
private void menuItem7_Click(object sender, System.EventArgs e) { Clipboard.SetDataObject(textBox1.SelectedText); textBox1.SelectedText="";
}
private void menuItem9_Click(object sender, System.EventArgs e) { textBox1.Paste(); }
private void textBox1_TextChanged(object sender, System.EventArgs e) {
}
private void menuItem12_Click(object sender, System.EventArgs e) { Form2 helpnew = new Form2(); helpnew.Show(); }
private void textBox1_TextChanged_1(object sender, System.EventArgs e) {
}
private void menuItem5_Click(object sender, System.EventArgs e) { }
private void menuItem5_Click_1(object sender, System.EventArgs e) { Dispose(true); }
private void menuItem8_Click(object sender, System.EventArgs e) { textBox1.Copy(); }
private void menuItem10_Click(object sender, System.EventArgs e) { textBox1.SelectAll();
}
private void menuItem2_Click(object sender, System.EventArgs e) { textBox1.Clear();
}
private void menuItem4_Click(object sender, System.EventArgs e) { // for file save saveFileDialog1.FileName = "*.txt"; //saveFileDialog1.FilterIndex ="*.txt"; saveFileDialog1.ShowDialog(); //MessageBox.Show (saveFileDialog1.FileName); StreamWriter sw = new StreamWriter(saveFileDialog1.FileName); sw.Write (textBox1.Text); sw.Close(); }
private void menuItem16_Click(object sender, System.EventArgs e) { Form3 gen = new Form3 (); gen.Show();
}
} public class Form3 : System.Windows.Forms.Form { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null;
public Form3() { // // Required for Windows Form Designer support // InitializeComponent();
// // TODO: Add any constructor code after InitializeComponent call // }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); }
#region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { // // Form3 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 273); this.Name = "Form3"; this.Text = "Form3"; this.Load += new System.EventHandler(this.Form3_Load);
} #endregion
private void Form3_Load(object sender, System.EventArgs e) { } } public class Form2 : System.Windows.Forms.Form { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.Container components = null;
public Form2() { // // Required for Windows Form Designer support // InitializeComponent();
// // TODO: Add any constructor code after InitializeComponent call // }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose( bool disposing ) { if( disposing ) { if(components != null) { components.Dispose(); } } base.Dispose( disposing ); }
#region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { // // Form2 // this.AutoScaleBaseSize = new System.Drawing.Size(6, 14); this.ClientSize = new System.Drawing.Size(292, 273); this.Name = "Form2"; this.Text = "Form2"; this.Load += new System.EventHandler(this.Form2_Load);
} #endregion
private void Form2_Load(object sender, System.EventArgs e) { } } }

|