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

📄 mdiparent.cs

📁 用C#写的多重文本编辑器 代码全 仅供参考 不作销售
💻 CS
📖 第 1 页 / 共 2 页
字号:
																						this.toolBarButton4,
																						this.toolBarButton5,
																						this.toolBarButton6,
																						this.toolBarButton7,
																						this.toolBarButton8,
																						this.toolBarButton9,
																						this.toolBarButton10});
			this.toolBar1.DropDownArrows = true;
			this.toolBar1.ImageList = this.imageList1;
			this.toolBar1.Location = new System.Drawing.Point(0, 0);
			this.toolBar1.Name = "toolBar1";
			this.toolBar1.ShowToolTips = true;
			this.toolBar1.Size = new System.Drawing.Size(472, 28);
			this.toolBar1.TabIndex = 1;
			this.toolBar1.ButtonClick += new System.Windows.Forms.ToolBarButtonClickEventHandler(this.toolBar1_ButtonClick);
			// 
			// toolBarButton1
			// 
			this.toolBarButton1.ImageIndex = 0;
			this.toolBarButton1.ToolTipText = "新建";
			// 
			// toolBarButton2
			// 
			this.toolBarButton2.ImageIndex = 6;
			this.toolBarButton2.ToolTipText = "打开";
			// 
			// toolBarButton3
			// 
			this.toolBarButton3.ImageIndex = 1;
			this.toolBarButton3.ToolTipText = "保存";
			// 
			// toolBarButton4
			// 
			this.toolBarButton4.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// toolBarButton5
			// 
			this.toolBarButton5.ImageIndex = 2;
			this.toolBarButton5.ToolTipText = "剪切";
			// 
			// toolBarButton6
			// 
			this.toolBarButton6.ImageIndex = 3;
			this.toolBarButton6.ToolTipText = "复制";
			// 
			// toolBarButton7
			// 
			this.toolBarButton7.ImageIndex = 4;
			this.toolBarButton7.ToolTipText = "粘贴";
			// 
			// toolBarButton8
			// 
			this.toolBarButton8.Style = System.Windows.Forms.ToolBarButtonStyle.Separator;
			// 
			// toolBarButton9
			// 
			this.toolBarButton9.ImageIndex = 5;
			this.toolBarButton9.ToolTipText = "关于";
			// 
			// toolBarButton10
			// 
			this.toolBarButton10.ImageIndex = 7;
			this.toolBarButton10.ToolTipText = "搜索";
			// 
			// statusBar1
			// 
			this.statusBar1.Location = new System.Drawing.Point(0, 283);
			this.statusBar1.Name = "statusBar1";
			this.statusBar1.Panels.AddRange(new System.Windows.Forms.StatusBarPanel[] {
																						  this.statusBarPanel1});
			this.statusBar1.Size = new System.Drawing.Size(472, 22);
			this.statusBar1.TabIndex = 3;
			this.statusBar1.Text = "欢迎使用MDI Text Editor!";
			// 
			// statusBarPanel1
			// 
			this.statusBarPanel1.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring;
			this.statusBarPanel1.Text = "欢迎使用MDI Text Editor";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
			this.BackColor = System.Drawing.SystemColors.Control;
			this.ClientSize = new System.Drawing.Size(472, 305);
			this.Controls.Add(this.statusBar1);
			this.Controls.Add(this.toolBar1);
			this.IsMdiContainer = true;
			this.Menu = this.mainMenu1;
			this.Name = "Form1";
			this.Text = "MDI Text Editor";
			this.WindowState = System.Windows.Forms.FormWindowState.Maximized;
			((System.ComponentModel.ISupportInitialize)(this.statusBarPanel1)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion

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

		private int WindowCount;

		private void menuItem2_Click(object sender, System.EventArgs e)
		{
			MDIChild child=new MDIChild();
			child.Text="Document"+ ++WindowCount;
			child.MdiParent=this;
			child.Show();
			statusBar1.Text="Creating file";
		}

		private void menuItem3_Click(object sender, System.EventArgs e)
		{
			OpenFileDialog ofDlg=new OpenFileDialog();
			ofDlg.Filter="Rich Text Format(*.rtf)|*.rtf|All Files(*.*)|*.*";
			ofDlg.FilterIndex=1;
			ofDlg.DefaultExt="rtf";
			ofDlg.AddExtension=true;
			ofDlg.Multiselect=false;
				if(ofDlg.ShowDialog()==DialogResult.OK)
				{
					MDIChild child=new MDIChild();
					child.Text=ofDlg.FileName;
					child.MdiParent=this;
					child.richTextBox1.LoadFile(ofDlg.FileName);
					child.Show();
					statusBar1.Text="File:"+ofDlg.FileName+"loaded!";
				}
		}

		private void menuItem5_Click(object sender, System.EventArgs e)
		{
			Application.Exit();
		}

		private void menuItem7_Click(object sender, System.EventArgs e)
		{
			if(menuItem7.Checked)
			{
				toolBar1.Dock=DockStyle.None;
				toolBar1.Hide();
				menuItem7.Checked=false;
			}
			else
			{
				toolBar1.Dock=DockStyle.Top;
				toolBar1.Show ();
				menuItem7.Checked=true;
			}
		}

		private void menuItem9_Click(object sender, System.EventArgs e)
		{
			this.LayoutMdi(MdiLayout.Cascade);
		}

		private void menuItem10_Click(object sender, System.EventArgs e)
		{
			this.LayoutMdi(MdiLayout.TileHorizontal);
		}

		private void menuItem11_Click(object sender, System.EventArgs e)
		{
			this.LayoutMdi(MdiLayout.ArrangeIcons);
		}

		private void menuItem13_Click(object sender, System.EventArgs e)
		{
			MessageBox.Show("多文档界面文本编辑应用软件,1.0版\n免费使用!",
				"关  于   MDI  Text  Editor",MessageBoxButtons.OK,
				MessageBoxIcon.Exclamation);
		}

		private void toolBar1_ButtonClick(object sender, System.Windows.Forms.ToolBarButtonClickEventArgs e)
		{
			if(e.Button==toolBarButton1)
			{
				menuItem2_Click(null,null);
			}
			else if(e.Button==toolBarButton2)
			{
				menuItem3_Click(null,null);
			}
			else if(e.Button==toolBarButton3)
			{
				if(ActiveMdiChild!=null)
				{
					SaveFileDialog sfDlg=new SaveFileDialog();
					sfDlg.Filter="Rich Text Format(*.rtf)|*.rtf|All Files(*.*)|*.*";
					sfDlg.FilterIndex=1;
					sfDlg.DefaultExt="rtf";
					sfDlg.AddExtension=true;
					sfDlg.RestoreDirectory=true;
					if(sfDlg.ShowDialog()==DialogResult.OK)
					{
						((MDIChild)ActiveMdiChild).richTextBox1.SaveFile(sfDlg.FileName);
						ActiveMdiChild.Text=sfDlg.FileName;
					}
					
				}
			}
			else if(e.Button==toolBarButton5)
			{
				if(ActiveMdiChild!=null)
				{
					((MDIChild)ActiveMdiChild).richTextBox1.Cut();
				}
			}
			else if(e.Button==toolBarButton6)
			{
				if(ActiveMdiChild!=null)
				{
					((MDIChild)ActiveMdiChild).richTextBox1.Copy();
				}
			}
			else if(e.Button==toolBarButton7)
			{
				if(ActiveMdiChild!=null)
				{
					((MDIChild)ActiveMdiChild).richTextBox1.Paste();
				}
			}
			else if(e.Button==toolBarButton9)
			{
				menuItem13_Click(null,null);
			}
			else if(e.Button==toolBarButton10)
			{
				menuItem14_Click(null,null);
			}
		}

		private void menuItem14_Click(object sender, System.EventArgs e)
		{
			MDISearch search=new MDISearch();
			search.MdiParent=this;
			search.Show();
			statusBar1.Text="Ready for search files.......";
		}
	}
}

⌨️ 快捷键说明

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