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

📄 form2.cs

📁 自己写的多窗口文本编辑器
💻 CS
📖 第 1 页 / 共 3 页
字号:
			this.textBox1.WordWrap = ((bool)(resources.GetObject("textBox1.WordWrap")));
			this.textBox1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBox1_KeyDown);
			this.textBox1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.textBox1_MouseDown);
			this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged);
			// 
			// openFileDialog
			// 
			this.openFileDialog.Filter = resources.GetString("openFileDialog.Filter");
			this.openFileDialog.Title = resources.GetString("openFileDialog.Title");
			// 
			// toolBar1
			// 
			this.toolBar1.AccessibleDescription = resources.GetString("toolBar1.AccessibleDescription");
			this.toolBar1.AccessibleName = resources.GetString("toolBar1.AccessibleName");
			this.toolBar1.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("toolBar1.Anchor")));
			this.toolBar1.Appearance = ((System.Windows.Forms.ToolBarAppearance)(resources.GetObject("toolBar1.Appearance")));
			this.toolBar1.AutoSize = ((bool)(resources.GetObject("toolBar1.AutoSize")));
			this.toolBar1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("toolBar1.BackgroundImage")));
			this.toolBar1.Buttons.AddRange(new System.Windows.Forms.ToolBarButton[] {
																						this.tbtnCopy,
																						this.tbtnCut,
																						this.tbtnPaste,
																						this.tbPrivate,
																						this.tbPreview,
																						this.tbPrint});
			this.toolBar1.ButtonSize = ((System.Drawing.Size)(resources.GetObject("toolBar1.ButtonSize")));
			this.toolBar1.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("toolBar1.Dock")));
			this.toolBar1.DropDownArrows = ((bool)(resources.GetObject("toolBar1.DropDownArrows")));
			this.toolBar1.Enabled = ((bool)(resources.GetObject("toolBar1.Enabled")));
			this.toolBar1.Font = ((System.Drawing.Font)(resources.GetObject("toolBar1.Font")));
			this.toolBar1.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("toolBar1.ImeMode")));
			this.toolBar1.Location = ((System.Drawing.Point)(resources.GetObject("toolBar1.Location")));
			this.toolBar1.Name = "toolBar1";
			this.toolBar1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("toolBar1.RightToLeft")));
			this.toolBar1.ShowToolTips = ((bool)(resources.GetObject("toolBar1.ShowToolTips")));
			this.toolBar1.Size = ((System.Drawing.Size)(resources.GetObject("toolBar1.Size")));
			this.toolBar1.TabIndex = ((int)(resources.GetObject("toolBar1.TabIndex")));
			this.toolBar1.Tag = "";
			this.toolBar1.TextAlign = ((System.Windows.Forms.ToolBarTextAlign)(resources.GetObject("toolBar1.TextAlign")));
			this.toolBar1.Visible = ((bool)(resources.GetObject("toolBar1.Visible")));
			this.toolBar1.Wrappable = ((bool)(resources.GetObject("toolBar1.Wrappable")));
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// tbtnCopy
			// 
			this.tbtnCopy.Enabled = ((bool)(resources.GetObject("tbtnCopy.Enabled")));
			this.tbtnCopy.ImageIndex = ((int)(resources.GetObject("tbtnCopy.ImageIndex")));
			this.tbtnCopy.Tag = "tbtnCopy";
			this.tbtnCopy.Text = resources.GetString("tbtnCopy.Text");
			this.tbtnCopy.ToolTipText = resources.GetString("tbtnCopy.ToolTipText");
			this.tbtnCopy.Visible = ((bool)(resources.GetObject("tbtnCopy.Visible")));
			// 
			// tbtnCut
			// 
			this.tbtnCut.Enabled = ((bool)(resources.GetObject("tbtnCut.Enabled")));
			this.tbtnCut.ImageIndex = ((int)(resources.GetObject("tbtnCut.ImageIndex")));
			this.tbtnCut.Tag = "tbtnCut";
			this.tbtnCut.Text = resources.GetString("tbtnCut.Text");
			this.tbtnCut.ToolTipText = resources.GetString("tbtnCut.ToolTipText");
			this.tbtnCut.Visible = ((bool)(resources.GetObject("tbtnCut.Visible")));
			// 
			// tbtnPaste
			// 
			this.tbtnPaste.Enabled = ((bool)(resources.GetObject("tbtnPaste.Enabled")));
			this.tbtnPaste.ImageIndex = ((int)(resources.GetObject("tbtnPaste.ImageIndex")));
			this.tbtnPaste.Tag = "tbtnPaste";
			this.tbtnPaste.Text = resources.GetString("tbtnPaste.Text");
			this.tbtnPaste.ToolTipText = resources.GetString("tbtnPaste.ToolTipText");
			this.tbtnPaste.Visible = ((bool)(resources.GetObject("tbtnPaste.Visible")));
			// 
			// tbPrivate
			// 
			this.tbPrivate.Enabled = ((bool)(resources.GetObject("tbPrivate.Enabled")));
			this.tbPrivate.ImageIndex = ((int)(resources.GetObject("tbPrivate.ImageIndex")));
			this.tbPrivate.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			this.tbPrivate.Tag = "tbPrivate";
			this.tbPrivate.Text = resources.GetString("tbPrivate.Text");
			this.tbPrivate.ToolTipText = resources.GetString("tbPrivate.ToolTipText");
			this.tbPrivate.Visible = ((bool)(resources.GetObject("tbPrivate.Visible")));
			// 
			// tbPreview
			// 
			this.tbPreview.Enabled = ((bool)(resources.GetObject("tbPreview.Enabled")));
			this.tbPreview.ImageIndex = ((int)(resources.GetObject("tbPreview.ImageIndex")));
			this.tbPreview.Tag = "tbPreview";
			this.tbPreview.Text = resources.GetString("tbPreview.Text");
			this.tbPreview.ToolTipText = resources.GetString("tbPreview.ToolTipText");
			this.tbPreview.Visible = ((bool)(resources.GetObject("tbPreview.Visible")));
			// 
			// tbPrint
			// 
			this.tbPrint.Enabled = ((bool)(resources.GetObject("tbPrint.Enabled")));
			this.tbPrint.ImageIndex = ((int)(resources.GetObject("tbPrint.ImageIndex")));
			this.tbPrint.Tag = "tbPrint";
			this.tbPrint.Text = resources.GetString("tbPrint.Text");
			this.tbPrint.ToolTipText = resources.GetString("tbPrint.ToolTipText");
			this.tbPrint.Visible = ((bool)(resources.GetObject("tbPrint.Visible")));
			// 
			// conCopy
			// 
			this.conCopy.Enabled = ((bool)(resources.GetObject("conCopy.Enabled")));
			this.conCopy.Index = 0;
			this.conCopy.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("conCopy.Shortcut")));
			this.conCopy.ShowShortcut = ((bool)(resources.GetObject("conCopy.ShowShortcut")));
			this.conCopy.Text = resources.GetString("conCopy.Text");
			this.conCopy.Visible = ((bool)(resources.GetObject("conCopy.Visible")));
			this.conCopy.Click += new System.EventHandler(this.conCopy_Click);
			// 
			// conPaste
			// 
			this.conPaste.Enabled = ((bool)(resources.GetObject("conPaste.Enabled")));
			this.conPaste.Index = 1;
			this.conPaste.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("conPaste.Shortcut")));
			this.conPaste.ShowShortcut = ((bool)(resources.GetObject("conPaste.ShowShortcut")));
			this.conPaste.Text = resources.GetString("conPaste.Text");
			this.conPaste.Visible = ((bool)(resources.GetObject("conPaste.Visible")));
			this.conPaste.Click += new System.EventHandler(this.conPaste_Click);
			// 
			// conCut
			// 
			this.conCut.Enabled = ((bool)(resources.GetObject("conCut.Enabled")));
			this.conCut.Index = 2;
			this.conCut.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("conCut.Shortcut")));
			this.conCut.ShowShortcut = ((bool)(resources.GetObject("conCut.ShowShortcut")));
			this.conCut.Text = resources.GetString("conCut.Text");
			this.conCut.Visible = ((bool)(resources.GetObject("conCut.Visible")));
			this.conCut.Click += new System.EventHandler(this.conCut_Click);
			// 
			// conSelectAll
			// 
			this.conSelectAll.Enabled = ((bool)(resources.GetObject("conSelectAll.Enabled")));
			this.conSelectAll.Index = 3;
			this.conSelectAll.Shortcut = ((System.Windows.Forms.Shortcut)(resources.GetObject("conSelectAll.Shortcut")));
			this.conSelectAll.ShowShortcut = ((bool)(resources.GetObject("conSelectAll.ShowShortcut")));
			this.conSelectAll.Text = resources.GetString("conSelectAll.Text");
			this.conSelectAll.Visible = ((bool)(resources.GetObject("conSelectAll.Visible")));
			this.conSelectAll.Click += new System.EventHandler(this.conSelectAll_Click);
			// 
			// contextMenu1
			// 
			this.contextMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																						 this.conCopy,
																						 this.conPaste,
																						 this.conCut,
																						 this.conSelectAll});
			this.contextMenu1.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("contextMenu1.RightToLeft")));
			// 
			// ppDialog
			// 
			this.ppDialog.AccessibleDescription = resources.GetString("ppDialog.AccessibleDescription");
			this.ppDialog.AccessibleName = resources.GetString("ppDialog.AccessibleName");
			this.ppDialog.Anchor = ((System.Windows.Forms.AnchorStyles)(resources.GetObject("ppDialog.Anchor")));
			this.ppDialog.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("ppDialog.AutoScaleBaseSize")));
			this.ppDialog.AutoScroll = ((bool)(resources.GetObject("ppDialog.AutoScroll")));
			this.ppDialog.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("ppDialog.AutoScrollMargin")));
			this.ppDialog.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("ppDialog.AutoScrollMinSize")));
			this.ppDialog.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("ppDialog.BackgroundImage")));
			this.ppDialog.ClientSize = ((System.Drawing.Size)(resources.GetObject("ppDialog.ClientSize")));
			this.ppDialog.Dock = ((System.Windows.Forms.DockStyle)(resources.GetObject("ppDialog.Dock")));
			this.ppDialog.Document = this.pDoc;
			this.ppDialog.Enabled = ((bool)(resources.GetObject("ppDialog.Enabled")));
			this.ppDialog.Font = ((System.Drawing.Font)(resources.GetObject("ppDialog.Font")));
			this.ppDialog.Icon = ((System.Drawing.Icon)(resources.GetObject("ppDialog.Icon")));
			this.ppDialog.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("ppDialog.ImeMode")));
			this.ppDialog.Location = ((System.Drawing.Point)(resources.GetObject("ppDialog.Location1")));
			this.ppDialog.MaximumSize = ((System.Drawing.Size)(resources.GetObject("ppDialog.MaximumSize")));
			this.ppDialog.MinimumSize = ((System.Drawing.Size)(resources.GetObject("ppDialog.MinimumSize")));
			this.ppDialog.Name = "ppDialog";
			this.ppDialog.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("ppDialog.RightToLeft")));
			this.ppDialog.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("ppDialog.StartPosition")));
			this.ppDialog.Text = resources.GetString("ppDialog.Text");
			this.ppDialog.TransparencyKey = System.Drawing.Color.Empty;
			this.ppDialog.Visible = ((bool)(resources.GetObject("ppDialog.Visible")));
			// 
			// pDoc
			// 
			this.pDoc.PrintPage += new System.Drawing.Printing.PrintPageEventHandler(this.pDoc_PrintPage);
			// 
			// Form2
			// 
			this.AccessibleDescription = resources.GetString("$this.AccessibleDescription");
			this.AccessibleName = resources.GetString("$this.AccessibleName");
			this.AutoScaleBaseSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScaleBaseSize")));
			this.AutoScroll = ((bool)(resources.GetObject("$this.AutoScroll")));
			this.AutoScrollMargin = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMargin")));
			this.AutoScrollMinSize = ((System.Drawing.Size)(resources.GetObject("$this.AutoScrollMinSize")));
			this.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("$this.BackgroundImage")));
			this.ClientSize = ((System.Drawing.Size)(resources.GetObject("$this.ClientSize")));
			this.Controls.Add(this.textBox1);
			this.Controls.Add(this.toolBar1);
			this.Enabled = ((bool)(resources.GetObject("$this.Enabled")));
			this.Font = ((System.Drawing.Font)(resources.GetObject("$this.Font")));
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.ImeMode = ((System.Windows.Forms.ImeMode)(resources.GetObject("$this.ImeMode")));
			this.Location = ((System.Drawing.Point)(resources.GetObject("$this.Location")));
			this.MaximumSize = ((System.Drawing.Size)(resources.GetObject("$this.MaximumSize")));
			this.Menu = this.mainMenu1;
			this.MinimumSize = ((System.Drawing.Size)(resources.GetObject("$this.MinimumSize")));
			this.Name = "Form2";
			this.RightToLeft = ((System.Windows.Forms.RightToLeft)(resources.GetObject("$this.RightToLeft")));
			this.StartPosition = ((System.Windows.Forms.FormStartPosition)(resources.GetObject("$this.StartPosition")));
			this.Text = resources.GetString("$this.Text");
			this.Closing += new System.ComponentModel.CancelEventHandler(this.Form2_Closing);
			this.ResumeLayout(false);

		}
	
	

		

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

		private void miFont_Click(object sender, System.EventArgs e)
		{
			if(fontDialog.ShowDialog()==DialogResult.OK)
			{
				textBox1.Font =fontDialog.Font;
			}
		
		}

		private void textBox1_TextChanged(object sender, System.EventArgs e)
		{
		
		}

		private void menuItem1_Click(object sender, System.EventArgs e)
		{
			miAutoWrap.Checked =!miAutoWrap.Checked ;
			textBox1.WordWrap =miAutoWrap.Checked ;
		}


		private void midefault_Click_1(object sender, System.EventArgs e)
		{
			for(int i=0;i<miview.MenuItems .Count ;i++)
				miview.MenuItems [i].Checked =false;
			(sender as MenuItem ).Checked =true; 
			 Encoding en ;
		     int os=0;
			switch ((sender as MenuItem).Index)
			{
				case 0:en=Encoding.Default ;
					os=0;
					break;
					
				case 1: en = Encoding.UTF8;
					os=3;
		
					break;
				case 2:en=Encoding.Unicode;
					os=2;
	
					break;
				case 3: en = Encoding.BigEndianUnicode;
					os=2;
		
					break;
				default:
					en = null;
					break;
			
			}
			if(en!=null)
			{
				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();
			}
			else return;
				
		
		}

		private void textBox1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
		{
			if (posChanged!=null)
			{
				Point p= GetCaretPos();
				posChanged(p);
			}
		}

		private void textBox1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
		{
			if (posChanged!=null)
			{
				Point p= GetCaretPos();
				posChanged(p);
			}
		
		}
		private Point GetCaretPos()
		{
			int x = 0;

⌨️ 快捷键说明

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