Ejemplo n.º 1
0
        private static void CreateControl()
        {
            if (null != _tridentControl && null != _htmlBody)
            {
                return;
            }

            _tridentControl = new MSHTMLHost();

            _tridentControl.Size = new Size(CONTROL_WIDTH, CONTROL_HEIGHT);

            _tridentControl.CreateTrident();
            _tridentControl.ActivateTrident();

            NativeMethods.IHTMLDocument2 htmlDoc2 = _tridentControl.GetDocument();
            _htmlBody = htmlDoc2.GetBody();
        }
Ejemplo n.º 2
0
        /// <include file='doc\CalendarAutoFormatDialog.uex' path='docs/doc[@for="CalendarAutoFormatDialog.UpdateSchemePreview"]/*' />
        /// <devdoc>
        ///    Update scheme preview
        /// </devdoc>
        /// <internalonly/>
        private void UpdateSchemePreview()
        {
            // create a new calendar and apply the scheme to it
            Calendar wc = GetPreviewCalendar();

            // CONSIDER: Its not safe to create a designer and associate it to
            //   a control that is not site'd...
            //   This should use the runtime control directly and call RenderControl instead.

            // get the design time HTML
            IDesigner designer = TypeDescriptor.CreateDesigner(wc, typeof(IDesigner));

            designer.Initialize(wc);
            CalendarDesigner wcd        = (CalendarDesigner)designer;
            string           designHTML = wcd.GetDesignTimeHtml();

            // and show it!
            NativeMethods.IHTMLDocument2 tridentDocument = schemePreview.GetDocument();
            NativeMethods.IHTMLElement   documentElement = tridentDocument.GetBody();
            documentElement.SetInnerHTML(designHTML);
        }
        protected override void OnTemplateModeChanged()
        {
            base.OnTemplateModeChanged();

            if (InTemplateMode)
            {
                // Set xmlns in view linked document to show HTML intrinsic
                // controls in property grid with same schema used by
                // Intellisense for current choice tag in HTML view.

                NativeMethods.IHTMLElement htmlElement = (NativeMethods.IHTMLElement)((IControlDesignerBehavior)Behavior).DesignTimeElementView;
                Debug.Assert(htmlElement != null,
                             "Invalid HTML element in MobileTemplateControlDesigner.OnTemplateModeChanged");
                NativeMethods.IHTMLDocument2 htmlDocument2 = (NativeMethods.IHTMLDocument2)htmlElement.GetDocument();
                Debug.Assert(htmlDocument2 != null,
                             "Invalid HTML Document2 in MobileTemplateControlDesigner.OnTemplateModeChanged");
                NativeMethods.IHTMLElement htmlBody = (NativeMethods.IHTMLElement)htmlDocument2.GetBody();
                Debug.Assert(htmlBody != null,
                             "Invalid HTML Body in MobileTemplateControlDesigner.OnTemplateModeChanged");
                htmlBody.SetAttribute("xmlns", (Object)CurrentChoice.Xmlns, 0);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        ///    Update scheme preview
        /// </summary>
        /// <internalonly/>
        private void UpdateSamplePreview()
        {
            if (_firstActivate)
            {
                return;
            }

            NativeMethods.IHTMLDocument2   tridentDocument = _samplePreview.GetDocument();
            NativeMethods.IHTMLElement     documentElement = tridentDocument.GetBody();
            NativeMethods.IHTMLBodyElement bodyElement;

            bodyElement = (NativeMethods.IHTMLBodyElement)documentElement;
            bodyElement.SetScroll("no");

            if (SelectedStyle == null)
            {
                documentElement.SetInnerHTML(String.Empty);
                tridentDocument.SetBgColor("buttonface");
                return;
            }
            else
            {
                tridentDocument.SetBgColor(String.Empty);
            }

            bool cycle = ReferencesContainCycle(SelectedStyle);

            if (cycle)
            {
                documentElement.SetInnerHTML(String.Empty);
                return;
            }

            // apply the current Style to label
            ApplyStyle();

            DesignerTextWriter tw = new DesignerTextWriter();

            //ToolTip
            tw.AddAttribute("title", ((StyleNode)SelectedStyle).RuntimeStyle.Name);

            // ForeColor
            Color c = _previewStyle.ForeColor;

            if (!c.Equals(Color.Empty))
            {
                tw.AddStyleAttribute("color", ColorTranslator.ToHtml(c));
            }

            // BackColor
            c = _previewStyle.BackColor;
            if (!c.Equals(Color.Empty))
            {
                tw.AddStyleAttribute("background-color", ColorTranslator.ToHtml(c));
            }

            // Font Name
            String name = _previewStyle.Font.Name;

            if (!name.Equals(String.Empty))
            {
                tw.AddStyleAttribute("font-family", name);
            }

            // Font Size
            switch (_previewStyle.Font.Size)
            {
            case FontSize.Large:
                tw.AddStyleAttribute("font-size", "Medium");
                break;

            case FontSize.Small:
                tw.AddStyleAttribute("font-size", "X-Small");
                break;

            default:
                tw.AddStyleAttribute("font-size", "Small");
                break;
            }

            // Font Style
            if (_previewStyle.Font.Bold == BooleanOption.True)
            {
                tw.AddStyleAttribute("font-weight", "bold");
            }
            if (_previewStyle.Font.Italic == BooleanOption.True)
            {
                tw.AddStyleAttribute("font-style", "italic");
            }

            tw.RenderBeginTag("span");
            tw.Write(SR.GetString(SR.StylesEditorDialog_PreviewText));
            tw.RenderEndTag();

            // and show it!
            String finalHTML = "<div align='center'><table width='100%' height='100%'><tr><td><p align='center'>" +
                               tw.ToString() + "</p></td></tr></table></div>";

            documentElement.SetInnerHTML(finalHTML);
        }