/// <summary> /// 设计窗口弹出菜单事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void designContextMenuStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { InsertElementHelper insert = new InsertElementHelper(); switch (e.ClickedItem.Name) { case "copyToolStripMenuItem": idoc2.execCommand("Copy", true, true); break; case "cutToolStripMenuItem": idoc2.execCommand("Cut", true, true); break; case "pasteToolStripMenuItem": idoc2.execCommand("Paste", true, true); break; case "tableToolStripMenuItem": { foreach (ToolStripItem ts in ((ToolStripMenuItem)e.ClickedItem).DropDownItems) { if (ts.Visible == true) { return; } } InsertElementHelper.Inserttable(idoc2); HTMLDesign.DesignToCode(); break; } case "insimgToolStripMenuItem": { InsertElementHelper.InsertImage(idoc2); break; } case "inslinkToolStripMenuItem": { InsertElementHelper.Insertlink(idoc2, HTMLDesign); break; } case "imgproToolStripMenuItem": { break; } case "activeproToolStripMenuItem": { break; } case "findToolStripMenuItem": { insert.OleCommandExec(true, MSHTML_COMMAND_IDS.IDM_FIND, idoc2); break; } } if (((ToolStripMenuItem)e.ClickedItem).DropDownItems.Count == 0) { ((ContextMenuStrip)sender).Close(); } /* if (HTMLDesign.DesignWebBrowser.Focused) * { * HTMLDesign.DesignToCode(); * HTMLDesign.CodeToDesign(); * } * * else * { * HTMLDesign.CodeToDesign(); * }*/ }
/// <summary> /// 工具栏按钮单击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void HTMLToolStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { IHTMLDocument2 _idoc2 = _htmlDesigner.Idoc2; TextEditorControl codeEdit = _htmlDesigner.CodeTextEditorControl; ToolStripButton thisBtn = e.ClickedItem as ToolStripButton; if (thisBtn == null) { return; } switch (thisBtn.Name) { case "propertyToolStripTextBox": { string pageId = _htmlDesigner.PageId; PagePropertyForm pageTextPropertyForm = new PagePropertyForm(pageId); pageTextPropertyForm.ShowDialog(Service.Workbench.MainForm); break; } case "tableToolStripButton": { InsertElementHelper.Inserttable(_idoc2); _htmlDesigner.DesignToCode(); break; } case "linkToolStripButton": { InsertElementHelper.Insertlink(_idoc2, _htmlDesigner); _htmlDesigner.DesignToCode(); break; } case "imageToolStripButton": { InsertElementHelper.InsertImage(_idoc2); _htmlDesigner.DesignToCode(); break; } case "flashToolStripButton": { InsertElementHelper.InsertFlash(_idoc2); _htmlDesigner.DesignToCode(); break; } case "mediaToolStripButton": { InsertElementHelper.InsertVideo(_idoc2); _htmlDesigner.DesignToCode(); break; } case "emailToolStripButton": { InsertElementHelper.InsertEmail(_idoc2); _htmlDesigner.DesignToCode(); break; } case "dateToolStripButton": { InsertElementHelper.InsertDateTime(_idoc2); _htmlDesigner.DesignToCode(); break; } case "brToolStripButton": { InsertElementHelper.AddToSelection(_idoc2, "<BR />", ""); _htmlDesigner.DesignToCode(); break; } case "hrToolStripButton": { InsertElementHelper.AddToSelection(_idoc2, "<HR />", ""); _htmlDesigner.DesignToCode(); break; } case "audioToolStripButton": { InsertElementHelper.InsertAudio(_idoc2); _htmlDesigner.DesignToCode(); break; } #region design,html,split case "DesignToolStripButton": { GeneralMethods.SetForModeChage(_htmlDesigner, DesignerOpenType.Design, 1); break; } case "HtmlToolStripButton": { GeneralMethods.SetForModeChage(_htmlDesigner, DesignerOpenType.Code, 1); } break; case "SplitToolStripButton": { GeneralMethods.SetForModeChage(_htmlDesigner, DesignerOpenType.Spliter, 1); break; } case "signToolStripButton": { InsertElementHelper.AddToSelection(_idoc2, currentSign, ""); break; } #endregion } if (!string.IsNullOrEmpty(e.ClickedItem.Name)) { if (_htmlDesigner.DesignWebBrowser.Focused) { _htmlDesigner.DesignToCode(); _htmlDesigner.CodeToDesign(); } else { _htmlDesigner.CodeToDesign(); } } }