public static void InsertVideo(HTMLDesignerContrl htmlDesigner) { string htmlCode = htmlDesigner.OpenMediaDialog(); InsertElementHelper.AddToSelection(htmlDesigner.DesignWebBrowser.idoc2, htmlCode, ""); /*InsertVideoCodeForm inserVideo = new InsertVideoCodeForm(htmlDesigner); * if (inserVideo.ShowDialog() == DialogResult.OK) * { * if (inserVideo.MediaPath != string.Empty) * { * //不管如何,只要存在此文件则加入到HTML编辑器中 * string path = inserVideo.MediaPath;// FileFullPath;// Path.GetFileName(Path.GetDirectoryName(FileFullPath)) + "/" + Path.GetFileName(FileFullPath); * string mwidth = inserVideo.MediaWidth.ToString() + inserVideo.MediaWidUint; * string mheight = inserVideo.MediaHeight.ToString() + inserVideo.MediaHeigUint; * string mvspace = inserVideo.MediaVspace.ToString(); * string mhspace = inserVideo.MediaHspace.ToString(); * string mtitle = inserVideo.MediaTitle; * string maccesskey = inserVideo.MediaAccessKey; * string mtabindex = inserVideo.MediaTab; * string mscale = inserVideo.MediaScale; * Align malign = inserVideo.MediaAlign; * Quality mquality = inserVideo.MediaQuality; * bool misloopplay = inserVideo.MediaLoop; * bool misautopaly = inserVideo.MediaAutoPlay; * string mediaID = inserVideo.MediaID; * Video insmedia = new Video(); * string insMediahtml = insmedia.MediaHtml(htmlDesigner.InsertUseMode,path, mwidth, mheight, mvspace, mhspace, mtitle, maccesskey, mtabindex, malign, mquality, misloopplay, misautopaly, mscale, mediaID); * AddToSelection(htmlDesigner.DesignWebBrowser.idoc2, insMediahtml, ""); * } * }*/ }
public static void InsertFlash(HTMLDesignerContrl htmlDesigner) { string htmlCode = htmlDesigner.OpenFlashDialog(); InsertElementHelper.AddToSelection(htmlDesigner.DesignWebBrowser.idoc2, htmlCode, ""); /*InsertFlashCodeForm insertflash = new InsertFlashCodeForm(htmlDesigner); * if (insertflash.ShowDialog() == DialogResult.OK) * { * if (insertflash.MediaPath != string.Empty) * { * //不管如何,只要存在此文件则加入到HTML编辑器中 * string path = insertflash.MediaPath; * string fwidth = insertflash.MediaWidth.ToString() + insertflash.MediaWidUint; * string fheight = insertflash.MediaHeight.ToString() + insertflash.MediaHeigUint; * string fvspace = insertflash.MediaVspace.ToString(); * string fhspace = insertflash.MediaHspace.ToString(); * string ftitle = insertflash.MediaTitle; * string faccesskey = insertflash.MediaAccessKey; * string ftabindex = insertflash.MediaTab; * string fscale = insertflash.MediaScale; * Align falign = insertflash.FlashAlign; * Quality fquality = insertflash.FlashQuality; * bool fisloopplay = insertflash.MediaLoop; * bool fisautopaly = insertflash.MediaAutoPlay; * string mediaID = insertflash.MediaID; * Flash insflash = new Flash(); * string insflashhtml = insflash.FlashHtml(htmlDesigner.InsertUseMode,path, fwidth, fheight, fvspace, fhspace, ftitle, faccesskey, ftabindex, falign, fquality, fisloopplay, fisautopaly, fscale, mediaID); * AddToSelection(htmlDesigner.DesignWebBrowser.idoc2, insflashhtml, ""); * // m_pDoc2.body.outerHTML; * } * }*/ }
public static void InsertDateTime(IHTMLDocument2 m_pDoc2) { InsertDatetimeForm insertDateTime = new InsertDatetimeForm(); if (insertDateTime.ShowDialog() == DialogResult.OK) { InsertElementHelper.AddToSelection(m_pDoc2, insertDateTime.InsertDateTimeHTML, ""); } }
public static void InsertImage(HTMLDesignerContrl htmlDesigner) { string htmlCode = htmlDesigner.OpenPicDialog(); /* InsertPicCodeForm insertpic = new InsertPicCodeForm(); * insertpic.HtmlDesigner = htmlDesigner; * if (insertpic.ShowDialog() == DialogResult.OK) * { * InsertElementHelper.AddToSelection(htmlDesigner.DesignWebBrowser.idoc2, insertpic.InsertImageHTML, ""); * }*/ InsertElementHelper.AddToSelection(htmlDesigner.DesignWebBrowser.idoc2, htmlCode, ""); }
void ToolStripComboBox_SelectedIndexChanged(object sender, EventArgs e) { IHTMLDocument2 _idoc2 = _ownerHtmlDesigner.DesignWebBrowser.idoc2; ToolStripComboBox item = sender as ToolStripComboBox; switch (item.Name) { case "fontToolStripComboBox": { _idoc2.execCommand("FontName", true, item.Text); break; } case "sizeToolStripComboBox": { _idoc2.execCommand("FontSize", true, item.Text); break; } case "paraToolStripComboBox": { string beginStr = ""; string endStr = ""; switch (item.ComboBox.SelectedIndex) { case 0: { beginStr = "<P>"; endStr = "</P>"; break; } case 1: { beginStr = "<H1>"; endStr = "</H1>"; break; } case 2: { beginStr = "<H2>"; endStr = "</H2>"; break; } case 3: { beginStr = "<H3>"; endStr = "</H3>"; break; } case 4: { beginStr = "<H4>"; endStr = "</H4>"; break; } case 5: { beginStr = "<H5>"; endStr = "</H5>"; break; } case 6: { beginStr = "<H6>"; endStr = "</H6>"; break; } } InsertElementHelper.AddToSelection(_idoc2, beginStr, endStr); break; } default: break; } }
/// <summary> /// 插入HTML元素,窗口切换 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void HTMLToolStrip_ItemClicked(object sender, ToolStripItemClickedEventArgs e) { idoc2 = _ownerHtmlDesigner.DesignWebBrowser.idoc2; ToolStripButton thisBtn = e.ClickedItem as ToolStripButton; if (thisBtn == null) { return; } switch (thisBtn.Name) { case "leftToolStripButton": { idoc2.execCommand("JustifyLeft", true, true); break; } case "rightToolStripButton": { idoc2.execCommand("JustifyRight", true, true); break; } case "allToolStripButton": { idoc2.execCommand("JustifyCenter", true, true); break; } case "boldToolStripButton": { idoc2.execCommand("bold", true, true); break; } case "inToolStripButton": { idoc2.execCommand("Indent", true, true); break; } case "outToolStripButton": { idoc2.execCommand("Outdent", true, true); break; } case "numToolStripButton": { idoc2.execCommand("InsertOrderedList", true, true); break; } case "listToolStripButton": { idoc2.execCommand("InsertUnorderedList", true, true); break; } case "italicToolStripButton": { idoc2.execCommand("italic", true, true); break; } case "underlineToolStripButton": { idoc2.execCommand("underline", true, true); break; } case "DesignToolStripButton": { if (OwnerHtmlDesigner.splitCon.Panel1Collapsed) { OwnerHtmlDesigner.splitCon.Panel2Collapsed = true; OwnerHtmlDesigner.DesignWebBrowser.Document.Body.InnerHtml = OwnerHtmlDesigner.CodeRichText.Text; designToolStripButton.Checked = true; codeToolStripButton.Checked = false; } break; } case "CodeToolStripButton": { if (OwnerHtmlDesigner.splitCon.Panel2Collapsed) { OwnerHtmlDesigner.splitCon.Panel1Collapsed = true; OwnerHtmlDesigner.CodeRichText.Text = OwnerHtmlDesigner.DesignWebBrowser.Document.Body.InnerHtml; codeToolStripButton.Checked = true; designToolStripButton.Checked = false; } break; } case "signToolStripButton": { InsertElementHelper.AddToSelection(idoc2, currentSign, ""); break; } case "propertyToolStripTextBox": { //string pageId = _htmlDesigner.PageId; //PagePropertyForm pageTextPropertyForm = new PagePropertyForm(pageId); //pageTextPropertyForm.ShowDialog(Service.Workbench.MainForm); break; } case "tableToolStripButton": { InsertElementHelper.Inserttable(idoc2); break; } case "linkToolStripButton": { InsertElementHelper.Insertlink(_ownerHtmlDesigner); break; } case "imageToolStripButton": { InsertElementHelper.InsertImage(_ownerHtmlDesigner); break; } case "flashToolStripButton": { InsertElementHelper.InsertFlash(_ownerHtmlDesigner); break; } case "mediaToolStripButton": { InsertElementHelper.InsertVideo(_ownerHtmlDesigner); break; } case "emailToolStripButton": { InsertElementHelper.InsertEmail(idoc2); break; } case "dateToolStripButton": { InsertElementHelper.InsertDateTime(idoc2); break; } case "brToolStripButton": { InsertElementHelper.AddToSelection(idoc2, "<BR />", ""); break; } case "hrToolStripButton": { InsertElementHelper.AddToSelection(idoc2, "<HR />", ""); break; } case "audioToolStripButton": { InsertElementHelper.InsertAudio(_ownerHtmlDesigner); break; } } }
/// <summary> /// 插入符号 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void signToolStripDropDownButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e) { IHTMLDocument2 _idoc2 = _ownerHtmlDesigner.DesignWebBrowser.idoc2; ToolStripMenuItem toolMenuItem = sender as ToolStripMenuItem; switch (e.ClickedItem.Name) { case "br": { InsertElementHelper.AddToSelection(_idoc2, "<br />", ""); currentSign = "<br />"; break; } case "nbsp": { InsertElementHelper.AddToSelection(_idoc2, " ", ""); currentSign = " "; break; } case "L_quotation": { InsertElementHelper.AddToSelection(_idoc2, "“", ""); currentSign = "“"; break; } case "R_quotation": { InsertElementHelper.AddToSelection(_idoc2, "”", ""); currentSign = "”"; break; } case "desh": { InsertElementHelper.AddToSelection(_idoc2, "—", ""); currentSign = "—"; break; } case "pound": { InsertElementHelper.AddToSelection(_idoc2, "£", ""); currentSign = "£"; break; } case "Eurocurrency": { InsertElementHelper.AddToSelection(_idoc2, "€", ""); currentSign = "€"; break; } case "yen": { InsertElementHelper.AddToSelection(_idoc2, "¥", ""); currentSign = "¥"; break; } case "copyright": { InsertElementHelper.AddToSelection(_idoc2, "©", ""); currentSign = "©"; break; } case "reg_trad_mark": { InsertElementHelper.AddToSelection(_idoc2, "®", ""); currentSign = "®"; break; } case "brand": { InsertElementHelper.AddToSelection(_idoc2, "™", ""); currentSign = "™"; break; } case "osign": { InsertOtherForm sign = new InsertOtherForm(); if (sign.ShowDialog() == DialogResult.OK) { InsertElementHelper.AddToSelection(_idoc2, sign.InsertSign, ""); currentSign = sign.InsertSign; } break; } } signToolStripButton.Text = HttpUtility.HtmlDecode(currentSign); signToolStripDropDownButton.Text = ""; }