示例#1
0
        public static void InsertDateTime(IHTMLDocument2 m_pDoc2)
        {
            InsertDatetimeForm insertDateTime = new InsertDatetimeForm();

            if (insertDateTime.ShowDialog() == DialogResult.OK)
            {
                DayOfWeek dy     = DateTime.Today.DayOfWeek;
                string    engday = "";
                string    chsday = "";
                switch (dy)
                {
                case DayOfWeek.Monday: { chsday = "星期一"; engday = "Mon"; break; }

                case DayOfWeek.Tuesday: { chsday = "星期二"; engday = "Tue"; break; }

                case DayOfWeek.Wednesday: { chsday = "星期三"; engday = "Wed"; break; }

                case DayOfWeek.Thursday: { chsday = "星期四"; engday = "Thu"; break; }

                case DayOfWeek.Friday: { chsday = "星期五"; engday = "Fri"; break; }

                case DayOfWeek.Saturday: { chsday = "星期六"; engday = "Sat"; break; }

                case DayOfWeek.Sunday: { chsday = "星期日"; engday = "Sun"; break; }
                }
                string dateformat = "";
                string timeformat = "";
                int    datef      = insertDateTime.dateFormat;
                int    dayf       = insertDateTime.dayFormat;
                int    timef      = insertDateTime.TimeFormat;
                bool   update     = insertDateTime.updated;
                switch (datef)
                {
                case 0: dateformat += @"yy\/MM\/dd"; break;

                case 1: dateformat += "yyyy年MM月dd日"; break;

                case 2: dateformat += @"MM\/dd\/yyyy"; break;

                case 3: dateformat += @"M\/d\/yy"; break;

                case 4: dateformat += "yyyy-MM-dd"; break;

                case 5: dateformat += @"d\/M\/yy"; break;

                case 6: dateformat += @"d\/MM\/yy"; break;

                case 7: dateformat += "dd.MM.yyyy"; break;

                case 8: dateformat += "dd.MM.yy"; break;

                case 9: dateformat += "d-MM-yyyy"; break;
                }
                switch (timef)
                {
                case 0: break;

                case 2: timeformat += " HH:mm";; break;

                case 1: timeformat += " hh:mm tt"; break;
                }

                if (update)
                {
                }
                else
                {
                }
                string strDate = DateTime.Now.ToString(dateformat) + " ";
                string strDay  = "";
                string strTime = "";
                if (timef > 0)
                {
                    strTime = DateTime.Now.ToString(timeformat);
                }
                switch (dayf)
                {
                case 1: strDay = chsday; break;

                case 2: strDay = chsday + " "; break;

                case 3: strDay = dy.ToString(); break;

                case 4: strDay = engday; break;
                }
                string str = strDate + " " + strDay + " " + strTime;
                InsertElementHelper.AddToSelection(m_pDoc2, str, "");
            }
        }
示例#2
0
        /// <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();
                }
            }
        }
示例#3
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();
             * }*/
        }
示例#4
0
        /// <summary>
        /// BR事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void brToolStripDropDownButton_DropDownItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            IHTMLDocument2    _idoc2       = _designWebBrouser.Document.DomDocument as IHTMLDocument2;
            ToolStripMenuItem toolMenuItem = sender as ToolStripMenuItem;

            switch (e.ClickedItem.Name)
            {
            case "br":
            {
                InsertElementHelper.AddToSelection(_idoc2, "<br />", "");
                currentSign = "<br />";
                break;
            }

            case "nbsp":
            {
                InsertElementHelper.AddToSelection(_idoc2, "&nbsp;", "");
                currentSign = "&nbsp;";
                break;
            }

            case "L_quotation":
            {
                InsertElementHelper.AddToSelection(_idoc2, "&#8220;", "");
                currentSign = "&#8220;";
                break;
            }

            case "R_quotation":
            {
                InsertElementHelper.AddToSelection(_idoc2, "&#8221;", "");
                currentSign = "&#8221;";
                break;
            }

            case "desh":
            {
                InsertElementHelper.AddToSelection(_idoc2, "&#8212;", "");
                currentSign = "&#8212;";
                break;
            }

            case "pound":
            {
                InsertElementHelper.AddToSelection(_idoc2, "&pound;", "");
                currentSign = "&pound;";
                break;
            }

            case "Eurocurrency":
            {
                InsertElementHelper.AddToSelection(_idoc2, "&#8364;", "");
                currentSign = "&#8364;";
                break;
            }

            case "yen":
            {
                InsertElementHelper.AddToSelection(_idoc2, "&yen;", "");
                currentSign = "&yen;";
                break;
            }

            case "copyright":
            {
                InsertElementHelper.AddToSelection(_idoc2, "&copy;", "");
                currentSign = "&copy;";
                break;
            }

            case "reg_trad_mark":
            {
                InsertElementHelper.AddToSelection(_idoc2, "&reg;", "");
                currentSign = "&reg;";
                break;
            }

            case "brand":
            {
                InsertElementHelper.AddToSelection(_idoc2, "&#8482;", "");
                currentSign = "&#8482;";
                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);// e.ClickedItem.Text;
            brToolStripDropDownButton.Text = "";
        }