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

📄 mainform.cs

📁 C#实现DHTML编辑器功能!
💻 CS
📖 第 1 页 / 共 4 页
字号:
			viewOutput.Image = IconProvider.LoadBitmap(this, "XML_editor.Icons.OutputPanel.bmp", true, new Point(0,0));
			MenuCommand viewSep1 = new MenuCommand("-");
			MenuCommand viewGoToLine = new MenuCommand("&Go To Line", Shortcut.CtrlG, new EventHandler(this.Clicked_ViewGoToLine));
			topView.MenuCommands.AddRange(new MenuCommand[]{viewTaskList, viewOutput, viewSep1, viewGoToLine});

			// Format
			MenuCommand formatIndent = new MenuCommand("&Increase Indent", new EventHandler(this.Clicked_FormatIndent));
			formatIndent.Image = IconProvider.LoadBitmap(this, "XML_editor.Icons.indent.png", true, new Point(0,0));
			MenuCommand formatUnindent = new MenuCommand("&Decrease Indent", new EventHandler(this.Clicked_FormatUnindent));
			formatUnindent.Image = IconProvider.LoadBitmap(this, "XML_editor.Icons.unindent.png", true, new Point(0,0));
			MenuCommand formatSep1 = new MenuCommand("-");
			MenuCommand formatTimeStamp = new MenuCommand("Insert &Timestamp", Shortcut.CtrlShiftI, new EventHandler(this.Clicked_FormatTimeStamp));
			topFormat.MenuCommands.AddRange(new MenuCommand[]{formatIndent, formatUnindent, formatSep1, formatTimeStamp});

			// Tools
			MenuCommand toolsTextEditor = new MenuCommand("&Text Editor Properties", new EventHandler(this.Clicked_ToolsTextEditor));
			toolsTextEditor.Image = IconProvider.LoadBitmap(this, "XML_editor.Icons.Properties.png", true, new Point(0,0));
			MenuCommand fileSep5 = new MenuCommand("-");
			MenuCommand toolsXMLTree = new MenuCommand("XML T&reeView", new EventHandler(this.Clicked_ToolsXMLTreeView));
			toolsXMLTree.Image = IconProvider.LoadBitmap(this, "XML_editor.Icons.xml_tree.png", true, new Point(15,15));
			MenuCommand fileSep6 = new MenuCommand("-");
			MenuCommand toolsXMLValidator = new MenuCommand("&XML Validator", new EventHandler(this.Clicked_ToolsXMLValidator));
			toolsXMLValidator.Image = IconProvider.LoadBitmap(this, "XML_editor.Icons.xml_validator.bmp", true, new Point(15,15));
			MenuCommand toolsXSLTTransformations = new MenuCommand("X&SLT Transformations", new EventHandler(this.Clicked_ToolsXSLTTransformations));
			topTools.MenuCommands.AddRange(new MenuCommand[]{toolsTextEditor, fileSep5,
																											toolsXMLTree, fileSep6,
																											toolsXMLValidator, toolsXSLTTransformations});

			// About
			MenuCommand aboutLicense = new MenuCommand("&License", new EventHandler(this.Clicked_AboutLicense));
			aboutLicense.Image = IconProvider.LoadBitmap(this, "XML_editor.Icons.copyleft.png", true, new Point(0,0));
			MenuCommand aboutAbout = new MenuCommand("&About...", new EventHandler(this.Clicked_AboutAbout));
			aboutAbout.Image = IconProvider.LoadBitmap(this, "XML_editor.Icons.about.png", true, new Point(0,0));
			topAbout.MenuCommands.AddRange(new MenuCommand[]{aboutLicense, aboutAbout});

			return topMenu;
		}

		#endregion

		#region Obsluha eventov kliknutia v hlavnom menu

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Edit->Paste.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public void Clicked_EditPaste(object sender, EventArgs e)
		{
			if (this.ActualTextAreaControl != null) 
			{
				this.ActualTextAreaControl.ClipboardHandler.Paste(null, null);
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Edit->Copy.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public void Clicked_EditCopy(object sender, EventArgs e)
		{
			if (this.ActualTextAreaControl != null) 
			{
				this.ActualTextAreaControl.ClipboardHandler.Copy(null, null);
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Edit->Cut.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public void Clicked_EditCut(object sender, EventArgs e)
		{
			if (this.ActualTextAreaControl != null) 
			{
				this.ActualTextAreaControl.ClipboardHandler.Cut(null, null);
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Edit->SelectAll
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public void Clicked_EditSelectAll(object sender, EventArgs e)
		{
			if (this.ActualTextAreaControl != null) 
			{
				this.ActualTextAreaControl.ExecuteDialogKey(Keys.Control | Keys.A);
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Edit->Find...
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public void Clicked_EditFind(object sender, EventArgs e)
		{
			if (this.ActualTextAreaControl != null) 
			{
				if (this.searchForm == null) 
				{
					this.searchForm = new SearchForm(this);
				} 
				this.searchForm.Show();
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Edit->Find Next
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public void Clicked_EditFindNext(object sender, EventArgs e)
		{
			if (this.ActualTextAreaControl != null) 
			{
				if (this.searchForm != null) 
				{
					this.searchForm.Clicked_buttonFind(null, null);
				} 
			}
		}
	
		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Edit->Undo
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public void Clicked_EditUndo(object sender, EventArgs e)
		{
			if (this.ActualTextAreaControl != null) 
			{
				this.ActualTextAreaControl.Undo();
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Edit->Redo
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		public void Clicked_EditRedo(object sender, EventArgs e)
		{
			if (this.ActualTextAreaControl != null) 
			{
				this.ActualTextAreaControl.Redo();
			}
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na File->Close. Zavrie aktualne zvoleny editor.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_FileClose(object sender, EventArgs e)
		{
			this.FileClose(this.SelectedTabPage);
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na File->Close. Zavrie aktualne zvoleny editor.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_FileCloseAll(object sender, EventArgs e)
		{
			this.FileCloseAll();
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na File->Save. Ulozi obsah aktualneho dokumentu, pod
		/// rovnakym menom ake uz ma.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_FileSave(object sender, EventArgs e)
		{
			this.FileSave(this.SelectedTabPage);
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na File->Save As. Ulozi obsah aktualneho dokumentu, pod
		/// novym menom.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_FileSaveAs(object sender, EventArgs e)
		{
			this.FileSaveAs(this.SelectedTabPage);
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na File->Save All. Ulozi obsah vsetkych dokumentov.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_FileSaveAll(object sender, EventArgs e)
		{
			this.FileSaveAll();
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na File->New. Vytvori novy editor a zaradi ho
		/// medzi ostatne editovacie okna. 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_FileNew(object sender, EventArgs e)
		{
			this.FileNew();
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na File->Open. Zobrazi dialog s vyberom suborov, otvori zadany subor
		/// a vytvori pre neho novy editor. 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_FileOpen(object sender, EventArgs e)
		{
			this.FileOpen();
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na File->Exit. Ukonci aplikaciu. 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_FileExit(object sender, EventArgs e)
		{
			this.Close();
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Tools->Text Editor Properties. Zobrazi TextEditor panel, ak este
		/// nebol vytvoreny tak ho vytvori a inicializuje.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_ToolsTextEditor(object sender, EventArgs e)
		{
			Crownwood.Magic.Docking.Content textEditor = (this.dockingPanels["TextEditor"] as Crownwood.Magic.Docking.Content);
			if (textEditor == null) 
			{
#if DEBUG
				System.Diagnostics.Debug.Write("Creating textEditor docking panel");
#endif
				textEditor = new XML_editor.DockingPanels.TextEditorPanel(this, this.dockingManager);
				this.dockingPanels.Add("TextEditor", textEditor);
				this.dockingManager.Contents.Add(textEditor);
				this.dockingManager.AddContentWithState(textEditor, Crownwood.Magic.Docking.State.DockLeft);
#if DEBUG
				System.Diagnostics.Debug.WriteLine("- OK");
#endif
			} 
			else 
			{
#if DEBUG
				System.Diagnostics.Debug.WriteLine("Found textEditor docking panel - using it");
#endif
			}
			this.dockingManager.ShowContent(textEditor);
			textEditor.BringToFront();
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Tools->XML Validator. Zobrazi TextEditor panel, ak este
		/// nebol vytvoreny tak ho vytvori a inicializuje.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_ToolsXMLValidator(object sender, EventArgs e)
		{
			Crownwood.Magic.Docking.Content content = (this.dockingPanels["XMLValidator"] as Crownwood.Magic.Docking.Content);
			if (content == null) 
			{
#if DEBUG
				System.Diagnostics.Debug.Write("Creating XMLValidator docking panel");
#endif
				content = new XML_editor.DockingPanels.XMLValidatingPanel(this, this.dockingManager);
				this.dockingPanels.Add("XMLValidator", content);
#if DEBUG
				System.Diagnostics.Debug.WriteLine("- OK");
#endif
			} 
			else 
			{
#if DEBUG
				System.Diagnostics.Debug.WriteLine("Found XMLValidator docking panel - using it");
#endif
			}
			this.dockingManager.ShowContent(content);
			content.BringToFront();
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Tools->XSLT Trasformations. Zobrazi panel, ktory bude zabezpecovat
		/// XSLT transformacie.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_ToolsXSLTTransformations(object sender, EventArgs e)
		{
			Crownwood.Magic.Docking.Content content = (this.dockingPanels["XSLTTransform"] as Crownwood.Magic.Docking.Content);
			if (content == null) 
			{
#if DEBUG
				System.Diagnostics.Debug.Write("Creating XSLTTransform docking panel");
#endif
				content = new XML_editor.DockingPanels.XSLPanel(this, this.dockingManager);
				this.dockingPanels.Add("XSLTTransform", content);
#if DEBUG
				System.Diagnostics.Debug.WriteLine("- OK");
#endif
			} 
			else 
			{
#if DEBUG
				System.Diagnostics.Debug.WriteLine("Found XSLTTransform docking panel - using it");
#endif
			}
			this.dockingManager.ShowContent(content);
			content.BringToFront();
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na Tools->XML TreeView. Zobrazi XML dokument v stromovej strukture.
		/// Ak este panel nebol vytvoreny tak ho vytvori a inicializuje.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_ToolsXMLTreeView(object sender, EventArgs e)
		{
			Crownwood.Magic.Docking.Content content = (this.dockingPanels["XMLTreeView"] as Crownwood.Magic.Docking.Content);
			if (content == null) 
			{
#if DEBUG
				System.Diagnostics.Debug.Write("Creating XMLTreeView docking panel");
#endif
				content = new XML_editor.DockingPanels.XMLTreePanel(this, this.dockingManager);
				this.dockingPanels.Add("XMLTreeView", content);
#if DEBUG
				System.Diagnostics.Debug.WriteLine("- OK");
#endif
			} 
			else 
			{
#if DEBUG
				System.Diagnostics.Debug.WriteLine("Found XMLTreeView docking panel - using it");
#endif
			}
			this.dockingManager.ShowContent(content);
			content.BringToFront();
		}

		// -------------------------------------------------------------------------
		/// <summary>
		/// Kliknutie na View->Task List. Zobrazi TaskList panel.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Clicked_ViewTaskList(object sender, EventArgs e)
		{
			this.TaskListPanel.BringToFront();
		}

⌨️ 快捷键说明

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