コード例 #1
0
        public void CodeToDesign()
        {
            if (idoc2 != null && idoc2.body != null)
            {
                //相对路径转绝对路径
                string htmlCode = codeTextEditorControl.Text;
                string ostr     = "${srs_";
                while (htmlCode.IndexOf(ostr) > 0)
                {
                    string mediaId = htmlCode.Substring(htmlCode.IndexOf(ostr) + 6, 32);

                    SimpleExIndexXmlElement ele = Service.Sdsite.CurrentDocument.GetElementById(mediaId) as SimpleExIndexXmlElement;
                    if (ele != null)
                    {
                        if (!ResourcesIdPaths.ContainsKey(ele.Id))
                        {
                            ResourcesIdPaths.Add(ele.Id, ele.AbsoluteFilePath);
                        }

                        string PATH = SiteResourceService.ParseFormatId(ele.Id, true);
                        htmlCode = htmlCode.Replace(htmlCode.Substring(htmlCode.IndexOf(ostr), 39), "file:///" + ele.AbsoluteFilePath.Replace("\\", "/"));
                    }
                    else
                    {
                        break;
                    }
                }

                idoc2.body.innerHTML = htmlCode;
            }
        }
コード例 #2
0
        /// <summary>
        /// 元素绑定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void designWebBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            IHTMLDocument3 pBody = ((IWebBrowser2)designWebBrowser.ActiveXInstance).Document as IHTMLDocument3;

            m_elemEvents.ConnectToHtmlEvents(pBody.documentElement);

            if (idoc2.body != null)
            {
                idoc2.body.innerHTML       = _articleText;
                codeTextEditorControl.Text = GeneralMethods.tidy(idoc2.body.innerHTML);

                string htmlCode = codeTextEditorControl.Text;
                string ostr     = "${srs_";
                while (htmlCode.IndexOf(ostr) > 0)
                {
                    string mediaId = htmlCode.Substring(htmlCode.IndexOf(ostr) + 6, 32);

                    SimpleExIndexXmlElement ele = Service.Sdsite.CurrentDocument.GetElementById(mediaId) as SimpleExIndexXmlElement;
                    if (ele != null)
                    {
                        if (!ResourcesIdPaths.ContainsKey(ele.Id))
                        {
                            ResourcesIdPaths.Add(ele.Id, ele.AbsoluteFilePath);
                        }

                        string PATH = SiteResourceService.ParseFormatId(ele.Id, true);
                        htmlCode = htmlCode.Replace(htmlCode.Substring(htmlCode.IndexOf(ostr), 39), "file:///" + ele.AbsoluteFilePath.Replace("\\", "/"));
                    }
                    else
                    {
                        break;
                    }
                }
            }
            DesignToCode();
            CodeToDesign();
        }