/// <include file='doc\StyleBuilderForm.uex' path='docs/doc[@for="StyleBuilderForm.InitSite"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        internal void InitSite(StyleBuilderSite site, string baseUrl)
        {
            builderSite = site;

            container = new StyleBuilderFormContainer(this);
            container.SetSite(site);

            context = new StyleBuilderUrlContext(baseUrl);
        }
        ///////////////////////////////////////////////////////////////////////////
        // Methods

        internal void Initialize(StyleBuilderSite site, StyleBuilderPageSite[] pages,
                                 object styleObject, int styleType,
                                 string caption, int captionType,
                                 string baseUrl)
        {
            InitSite(site, baseUrl);
            InitStyleObject(styleObject, styleType);
            InitSelectedPages(pages);

            InitForm();
            InitCaption(caption, captionType);
        }
        /// <include file='doc\StyleBuilderPage.uex' path='docs/doc[@for="StyleBuilderPage.Help"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        void IStyleBuilderPage.Help()
        {
            ISite site = Site;

            if (site != null)
            {
                StyleBuilderSite builderSite = (StyleBuilderSite)site.GetService(typeof(StyleBuilderSite));
                if (builderSite != null)
                {
                    builderSite.ShowHelp(helpKeyword);
                }
            }
        }
        private object GetBuilder(Type builderType)
        {
            Debug.Assert(builderType != null, "null builder type");

            object builder = null;
            ISite  site    = Site;

            if (site != null)
            {
                StyleBuilderSite builderSite = (StyleBuilderSite)site.GetService(typeof(StyleBuilderSite));
                if (builderSite != null)
                {
                    builder = builderSite.GetBuilder(builderType);
                }
            }
            return(builder);
        }
        /// <include file='doc\StyleBuilderPage.uex' path='docs/doc[@for="StyleBuilderPage.ActivatePage"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        protected virtual void ActivatePage()
        {
            if (uiCreated == false)
            {
                uiCreated = true;

                // first set up the font appropriately
                ISite site = Site;
                if (site != null)
                {
                    StyleBuilderSite builderSite = (StyleBuilderSite)site.GetService(typeof(StyleBuilderSite));
                    Font = builderSite.GetUIFont();
                }

                // allow the page to create its ui
                CreateUI();

                if (!autoScaleBaseSize.IsEmpty)
                {
                    // now apply the scaling ratio to resize the ui based on the ui font
                    SizeF realSize = Form.GetAutoScaleSize(Font);
                    Size  newVar   = new Size((int)Math.Round(realSize.Width), (int)Math.Round(realSize.Height));
                    float percY    = ((float)newVar.Height) / ((float)autoScaleBaseSize.Height);
                    float percX    = ((float)newVar.Width) / ((float)autoScaleBaseSize.Width);

                    Control.ControlCollection controls = Controls;
                    int controlCount = controls.Count;

                    for (int i = 0; i < controlCount; i++)
                    {
                        controls[i].Scale(percX, percY);
                    }

                    autoScaleBaseSize = Size.Empty;
                }
            }
            Visible = true;
            if (firstActivate)
            {
                Debug.Assert(selectedStyles != null, "Page activated before SetObjects was called");

                LoadStyles();
                firstActivate = false;
            }
        }
        /// <include file='doc\StyleBuilderForm.uex' path='docs/doc[@for="StyleBuilderForm.Dispose"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                styleObject  = null;
                editingStyle = null;

                container.SetSite(null);
                container = null;

                preview = null;
                context = null;

                pages = null;

                builderSite = null;
            }
            base.Dispose(disposing);
        }
        /// <include file='doc\StyleBuilder.uex' path='docs/doc[@for="StyleBuilder.CloseBuilder"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public virtual void CloseBuilder()
        {
            // free the pages
            FreePageCache();

            Debug.Assert(pageList.Count == 0,
                         "Page list is not empty. How come?");
            pageList = null;

            // finally free the site
            if (site != null)
            {
                site.Close();
                site = null;
            }

            // and lastly do a garbage collect to release any references still hanging around
            // and tear down the parking window to destroy any window handles
            // still lurking in memory
            Application.Exit();
        }
 public virtual object GetService(Type service)
 {
     if (service.Equals(typeof(IStyleBuilderPreview)))
     {
         return(form.GetPreviewService());
     }
     else if (service.Equals(typeof(IUrlContext)))
     {
         return(form.GetUrlContextService());
     }
     else if (service.Equals(typeof(StyleBuilderSite)))
     {
         return(form.GetBuilderSite());
     }
     else
     {
         StyleBuilderSite builderSite = form.GetBuilderSite();
         if (builderSite != null)
         {
             return(builderSite.QueryService(service));
         }
     }
     return(null);
 }
        ///////////////////////////////////////////////////////////////////////////
        // Constructor

        /// <include file='doc\StyleBuilder.uex' path='docs/doc[@for="StyleBuilder.StyleBuilder"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        public StyleBuilder()
        {
            dialogParent = new DialogParentWindow();
            pageList     = new ArrayList(STD_PAGE_INFO.Length);
            site         = new StyleBuilderSite();
        }