Esempio n. 1
0
        // called from SelfNavigateComplete()
        protected void SetBodyText(string text)
        {
            if (text == null)
            {
                text = String.Empty;
            }

            if (!IsHandleCreated)
            {
                return;
            }

            if (control != null)
            {
                IHTMLDocument2 document = control.Document;
                if (document != null)
                {
                    _document = document;
                    IHTMLElement body = document.GetBody();
                    if (body != null)
                    {
                        if (activate)
                        {
                            DoVerb(Interop.OLEIVERB_UIACTIVATE);
                        }
                        body.SetInnerHTML(text);
                        return;
                    }
                }
            }
        }
Esempio n. 2
0
        public void SetBodyText(string text)
        {
            if (control != null)
            {
                IHTMLDocument2 document = control.GetDocument();
                if (document != null)
                {
                    IHTMLElement body = document.GetBody();
                    if (body != null)
                    {
                        if (activate)
                        {
                            DoVerb(-4);
                        }
                        body.SetInnerHTML(text);
                        return;
                    }
                }
            }

            this.body = text;
        }
        ///////////////////////////////////////////////////////////////////////
        // Methods

        public virtual bool InitPreview(string baseUrl)
        {
            bool            result = false;
            IHTMLStyleSheet previewStyleSheet;
            IHTMLStyleSheetRulesCollection rulesCollection;
            IHTMLStyleSheetRule            style;
            IHTMLElement     documentElem;
            IHTMLBodyElement bodyElem;

            try {
                if ((baseUrl != null) && (baseUrl.Length != 0))
                {
                    SetBaseHref(baseUrl);
                }

                previewStyleSheet = previewDocument.CreateStyleSheet("", 0);
                if (previewStyleSheet == null)
                {
                    throw new Exception("Failed to create preview style sheet");
                }

                previewStyleSheet.SetCssText(PREVIEW_CSS);

                documentElem = previewDocument.GetBody();
                if (documentElem == null)
                {
                    throw new Exception("Failed to get body element from preview");
                }

                documentElem.SetInnerHTML(PREVIEW_HTML);

                bodyElem = (IHTMLBodyElement)documentElem;
                bodyElem.SetScroll("no");

                previewElement = GetElement("divPreview");
                if (previewElement == null)
                {
                    throw new Exception("Failed to get preview element");
                }

                sharedElement = GetElement("divShared");
                if (sharedElement == null)
                {
                    throw new Exception("Failed to get shared element");
                }

                rulesCollection = previewStyleSheet.GetRules();
                if (rulesCollection == null)
                {
                    throw new Exception("Failed to get style rules collection");
                }

                style = (IHTMLStyleSheetRule)rulesCollection.Item(0);
                if (style == null)
                {
                    throw new Exception("Failed to get style rule for parsing");
                }

                parseStyle = style.GetStyle();
                if (parseStyle == null)
                {
                    throw new Exception("Failed to get rule's style");
                }

                result = true;
            }
            catch (Exception e) {
                Debug.Fail(e.ToString());
                previewDocument = null;
            }

            return(result);
        }