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

📄 form2.cs

📁 自己写的多窗口文本编辑器
💻 CS
📖 第 1 页 / 共 3 页
字号:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.IO ;
using System.Text ;

public delegate void PosChangedHandler(Point CaretPos);

namespace 窗口编辑器
{
	/// <summary>
	/// Form2 的摘要说明。
	/// </summary>
	public class Form2 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MainMenu mainMenu1;
		private System.Windows.Forms.TextBox textBox1;
		private System.Windows.Forms.OpenFileDialog openFileDialog;
		private System.Windows.Forms.MenuItem miOption;
		private System.Windows.Forms.FontDialog fontDialog;
		private System.Windows.Forms.MenuItem miFont;
		private System.Windows.Forms.MenuItem miAutoWrap;
		private System.Windows.Forms.MenuItem miview;
		private System.Windows.Forms.MenuItem midefault;
		private System.Windows.Forms.MenuItem menuItem1;
		private System.Windows.Forms.MenuItem miUBE;
		private System.Windows.Forms.MenuItem miUnicode2;
		private System.Windows.Forms.MenuItem miColor;
		private System.Windows.Forms.ColorDialog colorDialog1;
		internal System.Windows.Forms.ToolBar toolBar1;
		private System.Windows.Forms.ToolBarButton tbtnCopy;
		private System.Windows.Forms.ToolBarButton tbtnCut;
		private System.Windows.Forms.ToolBarButton tbtnPaste;
		private System.Windows.Forms.MenuItem miEidt;
		private System.Windows.Forms.MenuItem miCopy;
		private System.Windows.Forms.MenuItem miCut;
		private System.Windows.Forms.MenuItem miPaste;
		private System.Windows.Forms.MenuItem miSelectAll;
		private System.Windows.Forms.MenuItem conCopy;
		private System.Windows.Forms.MenuItem conPaste;
		private System.Windows.Forms.MenuItem conCut;
		private System.Windows.Forms.MenuItem conSelectAll;
		private System.Windows.Forms.ContextMenu contextMenu1;
		private System.Windows.Forms.ToolBarButton tbPreview;
		private System.Windows.Forms.ToolBarButton tbPrint;
		private System.Windows.Forms.PrintPreviewDialog ppDialog;
		private System.Drawing.Printing.PrintDocument pDoc;
		private System.Windows.Forms.ToolBarButton tbPrivate;
		private System.ComponentModel.IContainer components;
		public event PosChangedHandler posChanged;

		public Form2()
		{
			//
			// Windows 窗体设计器支持所必需的
			//
			InitializeComponent();

			//
			// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
			//
		}
		string fileName;
		public Form2(string fileName):this()
		{   this.fileName = fileName;
			StreamReader sr=File.OpenText(fileName);
			textBox1.Text=sr.ReadToEnd();
			sr.Close();
			this.Text=fileName;
               Encoding en = Encoding.Default;
               int os = 0;
               FileStream fs = File.OpenRead(this.fileName);
               BinaryReader br = new BinaryReader(fs);
               byte[] buff = br.ReadBytes((int)fs.Length);
               buff = Encoding.Convert(en, Encoding.Default, buff, os, buff.Length - os);
               textBox1.Text = Encoding.Default.GetString(buff);
               br.Close();
               fs.Close();
		}
		public Form2(int ord):this()
		{
			textBox1.Clear();
			this.Text ="新建文件"+ord.ToString ();
		}



		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form2));
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.miOption = new System.Windows.Forms.MenuItem();
			this.miAutoWrap = new System.Windows.Forms.MenuItem();
			this.miFont = new System.Windows.Forms.MenuItem();
			this.miColor = new System.Windows.Forms.MenuItem();
			this.miview = new System.Windows.Forms.MenuItem();
			this.midefault = new System.Windows.Forms.MenuItem();
			this.menuItem1 = new System.Windows.Forms.MenuItem();
			this.miUnicode2 = new System.Windows.Forms.MenuItem();
			this.miUBE = new System.Windows.Forms.MenuItem();
			this.miEidt = new System.Windows.Forms.MenuItem();
			this.miCopy = new System.Windows.Forms.MenuItem();
			this.miCut = new System.Windows.Forms.MenuItem();
			this.miPaste = new System.Windows.Forms.MenuItem();
			this.miSelectAll = new System.Windows.Forms.MenuItem();
			this.textBox1 = new System.Windows.Forms.TextBox();
			this.openFileDialog = new System.Windows.Forms.OpenFileDialog();
			this.fontDialog = new System.Windows.Forms.FontDialog();
			this.colorDialog1 = new System.Windows.Forms.ColorDialog();
			this.toolBar1 = new System.Windows.Forms.ToolBar();
			this.tbtnCopy = new System.Windows.Forms.ToolBarButton();
			this.tbtnCut = new System.Windows.Forms.ToolBarButton();
			this.tbtnPaste = new System.Windows.Forms.ToolBarButton();
			this.tbPrivate = new System.Windows.Forms.ToolBarButton();
			this.tbPreview = new System.Windows.Forms.ToolBarButton();
			this.tbPrint = new System.Windows.Forms.ToolBarButton();
			this.conCopy = new System.Windows.Forms.MenuItem();
			this.conPaste = new System.Windows.Forms.MenuItem();
			this.conCut = new System.Windows.Forms.MenuItem();
			this.conSelectAll = new System.Windows.Forms.MenuItem();
			this.contextMenu1 = new System.Windows.Forms.ContextMenu();
			this.ppDialog = new System.Windows.Forms.PrintPreviewDialog();
			this.pDoc = new System.Drawing.Printing.PrintDocument();
			this.SuspendLayout();
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.miOption,
																					  this.miview,
																					  this.miEidt});
			this.mainMenu1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("mainMenu1.RightToLeft")));
			// 
			// miOption
			// 
			this.miOption.Enabled = ((bool)(resources.GetObject("miOption.Enabled")));
			this.miOption.Index = 0;
			this.miOption.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.miAutoWrap,
																					 this.miFont,
																					 this.miColor});
			this.miOption.MergeOrder = 1;
			this.miOption.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miOption.Shortcut")));
			this.miOption.ShowShortcut = ((bool)(resources.GetObject("miOption.ShowShortcut")));
			this.miOption.Text = resources.GetString("miOption.Text");
			this.miOption.Visible = ((bool)(resources.GetObject("miOption.Visible")));
			// 
			// miAutoWrap
			// 
			this.miAutoWrap.Checked = true;
			this.miAutoWrap.Enabled = ((bool)(resources.GetObject("miAutoWrap.Enabled")));
			this.miAutoWrap.Index = 0;
			this.miAutoWrap.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miAutoWrap.Shortcut")));
			this.miAutoWrap.ShowShortcut = ((bool)(resources.GetObject("miAutoWrap.ShowShortcut")));
			this.miAutoWrap.Text = resources.GetString("miAutoWrap.Text");
			this.miAutoWrap.Visible = ((bool)(resources.GetObject("miAutoWrap.Visible")));
			this.miAutoWrap.Click += new System.EventHandler(this.menuItem1_Click);
			// 
			// miFont
			// 
			this.miFont.Enabled = ((bool)(resources.GetObject("miFont.Enabled")));
			this.miFont.Index = 1;
			this.miFont.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miFont.Shortcut")));
			this.miFont.ShowShortcut = ((bool)(resources.GetObject("miFont.ShowShortcut")));
			this.miFont.Text = resources.GetString("miFont.Text");
			this.miFont.Visible = ((bool)(resources.GetObject("miFont.Visible")));
			this.miFont.Click += new System.EventHandler(this.miFont_Click);
			// 
			// miColor
			// 
			this.miColor.Enabled = ((bool)(resources.GetObject("miColor.Enabled")));
			this.miColor.Index = 2;
			this.miColor.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miColor.Shortcut")));
			this.miColor.ShowShortcut = ((bool)(resources.GetObject("miColor.ShowShortcut")));
			this.miColor.Text = resources.GetString("miColor.Text");
			this.miColor.Visible = ((bool)(resources.GetObject("miColor.Visible")));
			this.miColor.Click += new System.EventHandler(this.miColor_Click);
			// 
			// miview
			// 
			this.miview.Enabled = ((bool)(resources.GetObject("miview.Enabled")));
			this.miview.Index = 1;
			this.miview.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																				   this.midefault,
																				   this.menuItem1,
																				   this.miUnicode2,
																				   this.miUBE});
			this.miview.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miview.Shortcut")));
			this.miview.ShowShortcut = ((bool)(resources.GetObject("miview.ShowShortcut")));
			this.miview.Text = resources.GetString("miview.Text");
			this.miview.Visible = ((bool)(resources.GetObject("miview.Visible")));
			// 
			// midefault
			// 
			this.midefault.Checked = true;
			this.midefault.Enabled = ((bool)(resources.GetObject("midefault.Enabled")));
			this.midefault.Index = 0;
			this.midefault.RadioCheck = true;
			this.midefault.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("midefault.Shortcut")));
			this.midefault.ShowShortcut = ((bool)(resources.GetObject("midefault.ShowShortcut")));
			this.midefault.Text = resources.GetString("midefault.Text");
			this.midefault.Visible = ((bool)(resources.GetObject("midefault.Visible")));
			this.midefault.Click += new System.EventHandler(this.midefault_Click_1);
			// 
			// menuItem1
			// 
			this.menuItem1.Enabled = ((bool)(resources.GetObject("menuItem1.Enabled")));
			this.menuItem1.Index = 1;
			this.menuItem1.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("menuItem1.Shortcut")));
			this.menuItem1.ShowShortcut = ((bool)(resources.GetObject("menuItem1.ShowShortcut")));
			this.menuItem1.Text = resources.GetString("menuItem1.Text");
			this.menuItem1.Visible = ((bool)(resources.GetObject("menuItem1.Visible")));
			this.menuItem1.Click += new System.EventHandler(this.midefault_Click_1);
			// 
			// miUnicode2
			// 
			this.miUnicode2.Enabled = ((bool)(resources.GetObject("miUnicode2.Enabled")));
			this.miUnicode2.Index = 2;
			this.miUnicode2.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miUnicode2.Shortcut")));
			this.miUnicode2.ShowShortcut = ((bool)(resources.GetObject("miUnicode2.ShowShortcut")));
			this.miUnicode2.Text = resources.GetString("miUnicode2.Text");
			this.miUnicode2.Visible = ((bool)(resources.GetObject("miUnicode2.Visible")));
			this.miUnicode2.Click += new System.EventHandler(this.midefault_Click_1);
			// 
			// miUBE
			// 
			this.miUBE.Enabled = ((bool)(resources.GetObject("miUBE.Enabled")));
			this.miUBE.Index = 3;
			this.miUBE.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miUBE.Shortcut")));
			this.miUBE.ShowShortcut = ((bool)(resources.GetObject("miUBE.ShowShortcut")));
			this.miUBE.Text = resources.GetString("miUBE.Text");
			this.miUBE.Visible = ((bool)(resources.GetObject("miUBE.Visible")));
			this.miUBE.Click += new System.EventHandler(this.midefault_Click_1);
			// 
			// miEidt
			// 
			this.miEidt.Enabled = ((bool)(resources.GetObject("miEidt.Enabled")));
			this.miEidt.Index = 2;
			this.miEidt.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																				   this.miCopy,
																				   this.miCut,
																				   this.miPaste,
																				   this.miSelectAll});
			this.miEidt.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miEidt.Shortcut")));
			this.miEidt.ShowShortcut = ((bool)(resources.GetObject("miEidt.ShowShortcut")));
			this.miEidt.Text = resources.GetString("miEidt.Text");
			this.miEidt.Visible = ((bool)(resources.GetObject("miEidt.Visible")));
			// 
			// miCopy
			// 
			this.miCopy.Enabled = ((bool)(resources.GetObject("miCopy.Enabled")));
			this.miCopy.Index = 0;
			this.miCopy.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miCopy.Shortcut")));
			this.miCopy.ShowShortcut = ((bool)(resources.GetObject("miCopy.ShowShortcut")));
			this.miCopy.Text = resources.GetString("miCopy.Text");
			this.miCopy.Visible = ((bool)(resources.GetObject("miCopy.Visible")));
			this.miCopy.Click += new System.EventHandler(this.miCopy_Click);
			// 
			// miCut
			// 
			this.miCut.Enabled = ((bool)(resources.GetObject("miCut.Enabled")));
			this.miCut.Index = 1;
			this.miCut.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miCut.Shortcut")));
			this.miCut.ShowShortcut = ((bool)(resources.GetObject("miCut.ShowShortcut")));
			this.miCut.Text = resources.GetString("miCut.Text");
			this.miCut.Visible = ((bool)(resources.GetObject("miCut.Visible")));
			this.miCut.Click += new System.EventHandler(this.miCut_Click);
			// 
			// miPaste
			// 
			this.miPaste.Enabled = ((bool)(resources.GetObject("miPaste.Enabled")));
			this.miPaste.Index = 2;
			this.miPaste.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miPaste.Shortcut")));
			this.miPaste.ShowShortcut = ((bool)(resources.GetObject("miPaste.ShowShortcut")));
			this.miPaste.Text = resources.GetString("miPaste.Text");
			this.miPaste.Visible = ((bool)(resources.GetObject("miPaste.Visible")));
			this.miPaste.Click += new System.EventHandler(this.miPaste_Click);
			// 
			// miSelectAll
			// 
			this.miSelectAll.Enabled = ((bool)(resources.GetObject("miSelectAll.Enabled")));
			this.miSelectAll.Index = 3;
			this.miSelectAll.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("miSelectAll.Shortcut")));
			this.miSelectAll.ShowShortcut = ((bool)(resources.GetObject("miSelectAll.ShowShortcut")));
			this.miSelectAll.Text = resources.GetString("miSelectAll.Text");
			this.miSelectAll.Visible = ((bool)(resources.GetObject("miSelectAll.Visible")));
			this.miSelectAll.Click += new System.EventHandler(this.miSelectAll_Click);
			// 
			// textBox1
			// 
			this.textBox1.AccessibleDescription = resources.GetString("textBox1.AccessibleDescription");
			this.textBox1.AccessibleName = resources.GetString("textBox1.AccessibleName");
			this.textBox1.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("textBox1.Anchor")));
			this.textBox1.AutoSize = ((bool)(resources.GetObject("textBox1.AutoSize")));
			this.textBox1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("textBox1.BackgroundImage")));
			this.textBox1.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("textBox1.Dock")));
			this.textBox1.Enabled = ((bool)(resources.GetObject("textBox1.Enabled")));
			this.textBox1.Font = ((System.Drawing.Font)(resources.GetObject("textBox1.Font")));
			this.textBox1.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("textBox1.ImeMode")));
			this.textBox1.Location = ((System.Drawing.Point)(resources.GetObject("textBox1.Location")));
			this.textBox1.MaxLength = ((int)(resources.GetObject("textBox1.MaxLength")));
			this.textBox1.Multiline = ((bool)(resources.GetObject("textBox1.Multiline")));
			this.textBox1.Name = "textBox1";
			this.textBox1.PasswordChar = ((char)(resources.GetObject("textBox1.PasswordChar")));
			this.textBox1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("textBox1.RightToLeft")));
			this.textBox1.ScrollBars = ((System.Windows.Forms.ScrollBars)(resources.GetObject("textBox1.ScrollBars")));
			this.textBox1.Size = ((System.Drawing.Size)(resources.GetObject("textBox1.Size")));
			this.textBox1.TabIndex = ((int)(resources.GetObject("textBox1.TabIndex")));
			this.textBox1.Text = resources.GetString("textBox1.Text");
			this.textBox1.TextAlign = ((System.Windows.Forms.HorizontalAlignment)(resources.GetObject("textBox1.TextAlign")));
			this.textBox1.Visible = ((bool)(resources.GetObject("textBox1.Visible")));

⌨️ 快捷键说明

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