⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.cs

📁 很好用的一个文档
💻 CS
📖 第 1 页 / 共 2 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO;
using System.Drawing.Printing;
using System.Data;

namespace 记事本
{
	/// <summary>
	/// Form1 的摘要说明。
	/// </summary>
	public class FormMain : System.Windows.Forms.Form
	{
		private System.Windows.Forms.TextBox textBoxEdit;
		/// <summary>
		/// 必需的设计器变量。
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.MenuItem menuItem8;
		private System.Windows.Forms.MenuItem menuItem11;
		private System.Windows.Forms.MenuItem menuItem14;
		private System.Windows.Forms.MenuItem menuItem19;
		private System.Windows.Forms.MenuItem menuItem22;
		private System.Windows.Forms.MenuItem menuItemFile;
		private System.Windows.Forms.MenuItem menuItemEdit;
		private System.Windows.Forms.MenuItem menuItemFormat;
		private System.Windows.Forms.MenuItem menuItemNew;
		private System.Windows.Forms.MenuItem menuItemOpen;
		private System.Windows.Forms.MenuItem menuItemSave;
		private System.Windows.Forms.MenuItem menuItemSaveAs;
		private System.Windows.Forms.MenuItem menuItemPageSet;
		private System.Windows.Forms.MenuItem menuItemPrint;
		private System.Windows.Forms.MenuItem menuItemExit;
		private System.Windows.Forms.MenuItem menuItemUndo;
		private System.Windows.Forms.MenuItem menuItemCut;
		private System.Windows.Forms.MenuItem menuItemCopy;
		private System.Windows.Forms.MenuItem menuItemPaste;
		private System.Windows.Forms.MenuItem menuItemDel;
		private System.Windows.Forms.MenuItem menuItemSelAll;
		private System.Windows.Forms.MenuItem menuItemWordWrap;
		private System.Windows.Forms.MenuItem menuItemFont;
		private System.Windows.Forms.MenuItem menuItemColor;
		const int MaxLenght=2000000;
        
		private string currentFileName;
		private System.Drawing.Printing.PrintDocument printDocument=new PrintDocument();
		private bool needToSave;
		public FormMain()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}

		/// <summary>
		/// 清理所有正在使用的资源。
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// 设计器支持所需的方法 - 不要使用代码编辑器修改
		/// 此方法的内容。
		/// </summary>
		private void InitializeComponent()
		{
			this.textBoxEdit = new System.Windows.Forms.TextBox();
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.menuItemFile = new System.Windows.Forms.MenuItem();
			this.menuItemNew = new System.Windows.Forms.MenuItem();
			this.menuItemOpen = new System.Windows.Forms.MenuItem();
			this.menuItemSave = new System.Windows.Forms.MenuItem();
			this.menuItemSaveAs = new System.Windows.Forms.MenuItem();
			this.menuItem8 = new System.Windows.Forms.MenuItem();
			this.menuItemPageSet = new System.Windows.Forms.MenuItem();
			this.menuItemPrint = new System.Windows.Forms.MenuItem();
			this.menuItem11 = new System.Windows.Forms.MenuItem();
			this.menuItemExit = new System.Windows.Forms.MenuItem();
			this.menuItemEdit = new System.Windows.Forms.MenuItem();
			this.menuItemUndo = new System.Windows.Forms.MenuItem();
			this.menuItem14 = new System.Windows.Forms.MenuItem();
			this.menuItemCut = new System.Windows.Forms.MenuItem();
			this.menuItemCopy = new System.Windows.Forms.MenuItem();
			this.menuItemPaste = new System.Windows.Forms.MenuItem();
			this.menuItemDel = new System.Windows.Forms.MenuItem();
			this.menuItem19 = new System.Windows.Forms.MenuItem();
			this.menuItemSelAll = new System.Windows.Forms.MenuItem();
			this.menuItemFormat = new System.Windows.Forms.MenuItem();
			this.menuItemWordWrap = new System.Windows.Forms.MenuItem();
			this.menuItem22 = new System.Windows.Forms.MenuItem();
			this.menuItemFont = new System.Windows.Forms.MenuItem();
			this.menuItemColor = new System.Windows.Forms.MenuItem();
			this.SuspendLayout();
			// 
			// textBoxEdit
			// 
			this.textBoxEdit.AcceptsTab = true;
			this.textBoxEdit.BackColor = System.Drawing.Color.FromArgb(((System.Byte)(192)), ((System.Byte)(192)), ((System.Byte)(255)));
			this.textBoxEdit.Cursor = System.Windows.Forms.Cursors.Arrow;
			this.textBoxEdit.Dock = System.Windows.Forms.DockStyle.Fill;
			this.textBoxEdit.Location = new System.Drawing.Point(0, 0);
			this.textBoxEdit.MaxLength = 2000000;
			this.textBoxEdit.Multiline = true;
			this.textBoxEdit.Name = "textBoxEdit";
			this.textBoxEdit.ScrollBars = System.Windows.Forms.ScrollBars.Both;
			this.textBoxEdit.Size = new System.Drawing.Size(442, 393);
			this.textBoxEdit.TabIndex = 0;
			this.textBoxEdit.Text = "Hello ChengKing !";
			this.textBoxEdit.WordWrap = false;
			this.textBoxEdit.TextChanged += new System.EventHandler(this.textBoxEdit_TextChanged);
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.menuItemFile,
																					  this.menuItemEdit,
																					  this.menuItemFormat});
			// 
			// menuItemFile
			// 
			this.menuItemFile.Index = 0;
			this.menuItemFile.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						 this.menuItemNew,
																						 this.menuItemOpen,
																						 this.menuItemSave,
																						 this.menuItemSaveAs,
																						 this.menuItem8,
																						 this.menuItemPageSet,
																						 this.menuItemPrint,
																						 this.menuItem11,
																						 this.menuItemExit});
			this.menuItemFile.Text = "文件(&F)";
			// 
			// menuItemNew
			// 
			this.menuItemNew.Index = 0;
			this.menuItemNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN;
			this.menuItemNew.Text = "新建(&N)";
			this.menuItemNew.Click += new System.EventHandler(this.menuItemNew_Click);
			// 
			// menuItemOpen
			// 
			this.menuItemOpen.Index = 1;
			this.menuItemOpen.Shortcut = System.Windows.Forms.Shortcut.CtrlO;
			this.menuItemOpen.Text = "打开(O)...";
			this.menuItemOpen.Click += new System.EventHandler(this.menuItem5_Click);
			// 
			// menuItemSave
			// 
			this.menuItemSave.Index = 2;
			this.menuItemSave.Shortcut = System.Windows.Forms.Shortcut.CtrlS;
			this.menuItemSave.Text = "保存(&S)";
			this.menuItemSave.Click += new System.EventHandler(this.menuItemSave_Click);
			// 
			// menuItemSaveAs
			// 
			this.menuItemSaveAs.Index = 3;
			this.menuItemSaveAs.Text = "另存为(A)...";
			this.menuItemSaveAs.Click += new System.EventHandler(this.menuItemSaveAs_Click);
			// 
			// menuItem8
			// 
			this.menuItem8.Index = 4;
			this.menuItem8.Text = "-";
			// 
			// menuItemPageSet
			// 
			this.menuItemPageSet.Index = 5;
			this.menuItemPageSet.Text = "页面设置(U)...";
			this.menuItemPageSet.Click += new System.EventHandler(this.menuItemPageSet_Click);
			// 
			// menuItemPrint
			// 
			this.menuItemPrint.Index = 6;
			this.menuItemPrint.Shortcut = System.Windows.Forms.Shortcut.CtrlP;
			this.menuItemPrint.Text = "打印(&P)";
			this.menuItemPrint.Click += new System.EventHandler(this.menuItemPrint_Click);
			// 
			// menuItem11
			// 
			this.menuItem11.Index = 7;
			this.menuItem11.Text = "-";
			// 
			// menuItemExit
			// 
			this.menuItemExit.Index = 8;
			this.menuItemExit.Text = "退出(&X)";
			this.menuItemExit.Click += new System.EventHandler(this.menuItemExit_Click);
			// 
			// menuItemEdit
			// 
			this.menuItemEdit.Index = 1;
			this.menuItemEdit.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						 this.menuItemUndo,
																						 this.menuItem14,
																						 this.menuItemCut,
																						 this.menuItemCopy,
																						 this.menuItemPaste,
																						 this.menuItemDel,
																						 this.menuItem19,
																						 this.menuItemSelAll});
			this.menuItemEdit.Text = "编辑(&E)";
			this.menuItemEdit.Popup += new System.EventHandler(this.menuItemEdit_Popup);
			// 
			// menuItemUndo
			// 
			this.menuItemUndo.Index = 0;
			this.menuItemUndo.Shortcut = System.Windows.Forms.Shortcut.CtrlZ;
			this.menuItemUndo.Text = "撤消(&U)";
			this.menuItemUndo.Click += new System.EventHandler(this.menuItemUndo_Click);
			// 
			// menuItem14
			// 
			this.menuItem14.Index = 1;
			this.menuItem14.Text = "-";
			// 
			// menuItemCut
			// 
			this.menuItemCut.Index = 2;
			this.menuItemCut.Shortcut = System.Windows.Forms.Shortcut.CtrlX;
			this.menuItemCut.Text = "剪切(&T)";
			this.menuItemCut.Click += new System.EventHandler(this.menuItemCut_Click);
			// 
			// menuItemCopy
			// 
			this.menuItemCopy.Index = 3;
			this.menuItemCopy.Shortcut = System.Windows.Forms.Shortcut.CtrlC;
			this.menuItemCopy.Text = "复制(&C)";
			this.menuItemCopy.Click += new System.EventHandler(this.menuItemCopy_Click);
			// 
			// menuItemPaste
			// 
			this.menuItemPaste.Index = 4;
			this.menuItemPaste.Shortcut = System.Windows.Forms.Shortcut.CtrlP;
			this.menuItemPaste.Text = "粘贴(&P)";
			this.menuItemPaste.Click += new System.EventHandler(this.menuItemPaste_Click);
			// 
			// menuItemDel
			// 
			this.menuItemDel.Index = 5;
			this.menuItemDel.Shortcut = System.Windows.Forms.Shortcut.Del;
			this.menuItemDel.Text = "删除(&L)";
			this.menuItemDel.Click += new System.EventHandler(this.menuItemDel_Click);
			// 
			// menuItem19
			// 
			this.menuItem19.Index = 6;
			this.menuItem19.Text = "-";
			// 
			// menuItemSelAll
			// 
			this.menuItemSelAll.Index = 7;
			this.menuItemSelAll.Shortcut = System.Windows.Forms.Shortcut.CtrlA;
			this.menuItemSelAll.Text = "全选(&A)";
			this.menuItemSelAll.Click += new System.EventHandler(this.menuItemSelAll_Click);
			// 
			// menuItemFormat
			// 
			this.menuItemFormat.Index = 2;
			this.menuItemFormat.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						   this.menuItemWordWrap,
																						   this.menuItem22,
																						   this.menuItemFont,
																						   this.menuItemColor});
			this.menuItemFormat.Text = "格式(&O)";
			// 
			// menuItemWordWrap
			// 
			this.menuItemWordWrap.Index = 0;
			this.menuItemWordWrap.Text = "自动换行(&W)";
			// 
			// menuItem22
			// 
			this.menuItem22.Index = 1;
			this.menuItem22.Text = "-";
			// 
			// menuItemFont
			// 
			this.menuItemFont.Index = 2;
			this.menuItemFont.Text = "字体(&F)...";
			this.menuItemFont.Click += new System.EventHandler(this.menuItemFont_Click);
			// 
			// menuItemColor
			// 
			this.menuItemColor.Index = 3;
			this.menuItemColor.Text = "背景颜色(&C)...";
			this.menuItemColor.Click += new System.EventHandler(this.menuItemColor_Click);
			// 
			// FormMain
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.ClientSize = new System.Drawing.Size(442, 393);
			this.Controls.Add(this.textBoxEdit);
			this.Menu = this.mainMenu1;
			this.Name = "FormMain";
			this.Text = "ChengKing Rote";
			this.Closing += new System.ComponentModel.CancelEventHandler(this.FormMain_Closing);
			this.Load += new System.EventHandler(this.FormMain_Load);
			this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// 应用程序的主入口点。
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new FormMain());
		}

		private void FormMain_Load(object sender, System.EventArgs e)
		{
			//textBoxEdit.MaxLength=MaxLength;
			//textBoxEdit.Multiline=t
		}

		private void textBoxEdit_TextChanged(object sender, System.EventArgs e)
		{
			needToSave=true;
		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -