Esempio n. 1
0
        public void LoadWixFileText(string filename)
        {
            webBrowser.Navigate(filename);

            // change font size
            IHTMLDocument2 doc = (IHTMLDocument2)webBrowser.Document;

            doc.execCommand("SelectAll", false, null);
            doc.execCommand("FontSize", false, 1);
            doc.execCommand("Unselect", false, null);

            // do not allow user to select text if not registered
            if (Globals.registered == false)
            {
                browserEvents = (HTMLDocumentEvents2_Event)webBrowser.Document;
                browserEvents.onselectionchange += new HTMLDocumentEvents2_onselectionchangeEventHandler(browserEvents_onselectionchange);
            }
            else
            {
                browserEvents = null;
            }

            using (StreamReader reader = new StreamReader(filename)) {
                wixCode = null;
                wixCode = new StringBuilder(reader.ReadToEnd());
            }
            lblTime.Text = DateTime.Now.ToString("dddd, dd MMMM yyyy HH:mm:ss fff");
        }
Esempio n. 2
0
        public bool ExecuteCommand(string name, bool showUi, object value, bool throwOnError, bool raiseChanged)
        {
            IHTMLDocument2 doc = (IHTMLDocument2)Browser.Document;

            if (doc == null)
            {
                return(false);
            }

            bool b;

            if (throwOnError)
            {
                b = doc.execCommand(name, showUi, value);
            }
            try
            {
                b = doc.execCommand(name, showUi, value);
            }
            catch
            {
                b = false;
            }
            if (b)
            {
                OnBodyChanged(this, EventArgs.Empty);
            }
            return(b);
        }
Esempio n. 3
0
        private void NewsForm_Load(object sender, EventArgs e)
        {
            InitDesignWebBrowser();
            newColComboBox.SelectedIndex = 0;

            idoc2.execCommand("FontName", true, "宋体");
            idoc2.execCommand("FontSize", true, "12px");
        }
Esempio n. 4
0
        public static void ExecuteCommandHtmlDoc(IHTMLDocument2 htmlDoc, HtmlCommand command, object data)
        {
            try
            {
                if (htmlDoc.IsNull())
                {
                    return;
                }

                // ensure command is valid and enabled
                if (!htmlDoc.queryCommandSupported(command.Name()))
                {
                    return;
                }

                if (!htmlDoc.queryCommandEnabled(command.Name()))
                {
                    return;
                }

                htmlDoc.execCommand(command.Name(), false, data);
            }
            catch (RemotingException) { }
            catch (UnauthorizedAccessException) { }
        }
Esempio n. 5
0
        public void SelectAll()
        {
#if !__MonoCS__
            IHTMLDocument2 doc = (IHTMLDocument2)axWebBrowser1.Document;
            doc.execCommand("SelectAll", false, null);
#endif
        }
Esempio n. 6
0
        public void PrintFile()
        {
#if !__MonoCS__
            IHTMLDocument2 doc = (IHTMLDocument2)axWebBrowser1.Document;
            doc.execCommand("PRINT", true, null);
#endif
        }
        private void BtnPrint_Click(object sender, RoutedEventArgs e)
        {
            IHTMLDocument2 document = WBDoc.Document as IHTMLDocument2;

            document.execCommand("Print");
            BtnBack_Click(null, null);
        }
Esempio n. 8
0
        public void CopyToClipboard()
        {
#if !__MonoCS__
            IHTMLDocument2 doc = (IHTMLDocument2)axWebBrowser1.Document;
            doc.execCommand("Copy", false, null);
#endif
        }
Esempio n. 9
0
        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;
            }
        }
Esempio n. 10
0
        private void btnAddImageContentMail_Click(object sender, EventArgs e)
        {
            string linkimg = txt_link_img.Text;

            doc = mainForm.HTMLEditors.Document.DomDocument as IHTMLDocument2;
            doc.execCommand("insertImage", false, linkimg);
            this.Close();
        }
Esempio n. 11
0
 public override void Print(bool ShowDialog)
 {
     if (BrowserView.Document != null)
     {
         IHTMLDocument2 htmlDocument = (mshtml.IHTMLDocument2)BrowserView.Document.DomDocument;
         htmlDocument.execCommand("print", ShowDialog, null);
     }
 }
Esempio n. 12
0
 public override void SaveAs(string FileName)
 {
     if (BrowserView.Document != null)
     {
         IHTMLDocument2 htmlDocument = (mshtml.IHTMLDocument2)BrowserView.Document.DomDocument;
         htmlDocument.execCommand("saveas", true, FileName);
     }
 }
Esempio n. 13
0
 private void selectAllToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (BrowserView.Document != null)
     {
         IHTMLDocument2 htmlDocument = (mshtml.IHTMLDocument2)BrowserView.Document.DomDocument;
         htmlDocument.execCommand("selectall", true, null);
     }
 }
Esempio n. 14
0
        public static void RibbonComboboxFontHeight(ComboBox RibbonComboboxFontHeight)
        {
            IHTMLDocument2 doc = webBrowser.webBrowser.Document as IHTMLDocument2;

            if (doc != null)
            {
                doc.execCommand("FontSize", false, RibbonComboboxFontHeight.SelectedItem);
            }
        }
Esempio n. 15
0
 public bool ExecCommand(bool bTopLevel, string CmdId, bool showUI, object CmdValue, IHTMLDocument2 doc2)
 {
     if (doc2 != null)
     {
         return(doc2.execCommand(CmdId, showUI, CmdValue));
     }
     else
     {
         return(false);
     }
 }
        public void ToggleBold()
        {
            doc.execCommand("Bold", false, null);

            // If no text is selected, flip the state ("None")
            // If text is actually highlighted, the type is "Text"
            if (doc.selection.type == "None")
            {
                Bold = !Bold;
            }
        }
Esempio n. 17
0
 public void FontHeight(ComboBox fontsize)
 {
     if (doc != null)
     {
         doc.execCommand("FontSize", false, fontsize.SelectedItem);
     }
 }
Esempio n. 18
0
        private void Print(object obj)
        {
            IHTMLDocument2 doc = ((WebBrowser)obj).Document as IHTMLDocument2;

            doc.execCommand("Print", true, null);
        }
Esempio n. 19
0
        /// <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;
            }
            }
        }
Esempio n. 20
0
 public bool execCommand(string cmdID, bool showUI, object value)
 {
     return(_innerDoc2.execCommand(cmdID, showUI, value));
 }
Esempio n. 21
0
 public void ExecuteCommand(NoteEditorCommand command)
 {
     htmlDoc.execCommand(command.Value);
 }
Esempio n. 22
0
        void colorToolStripButton_MyColorChanged(object sender, EventArgs e)
        {
            IHTMLDocument2 _idoc2 = _ownerHtmlDesigner.DesignWebBrowser.idoc2;

            idoc2.execCommand("ForeColor", true, colorToolStripButton.MyColor.ToArgb());
        }
Esempio n. 23
0
        /// <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();
             * }*/
        }
Esempio n. 24
0
 /// <summary>
 /// 添加页面
 /// </summary>
 public override void Undo()
 {
     IDoc2.execCommand("Undo", true, true);
 }