/// <include file='doc\StyleBuilderForm.uex' path='docs/doc[@for="StyleBuilderForm.OnSelChangePageSelector"]/*' />
        /// <devdoc>
        ///    <para>[To be supplied.]</para>
        /// </devdoc>
        protected virtual void OnSelChangePageSelector(object source, TreeViewEventArgs e)
        {
            TreeNode tnodeSel  = pageSelector.SelectedNode;
            int      treeIndex = tnodeSel.Index;
            int      pageIndex;

            // map the tree index of the page (its position in the selector) to its
            // index in the page array
            for (pageIndex = 0; pageIndex < pages.Length; pageIndex++)
            {
                if (pages[pageIndex].GetUIIndex() == treeIndex)
                {
                    break;
                }
            }

            Debug.Assert((pageIndex >= 0) && (pageIndex < pages.Length),
                         "could not find page corresponding to node in page selector");

            if (pageIndex == activePageIndex)
            {
                return;
            }

            StyleBuilderPageSite siteNew = pages[pageIndex];
            IStyleBuilderPage    pageNew = siteNew.GetPage();

            // make sure the new page's window is created
            IntPtr h = pageNew.GetPageControl().Handle;

            // load the style into the page
            siteNew.LoadPage(editingStyle);

            // deactivate the current page if there is one
            if (activePageIndex != -1)
            {
                StyleBuilderPageSite siteActive = pages[activePageIndex];
                if (siteActive.GetPage().DeactivatePage(false, true) == false)
                {
                    // the page cannot be deactivated
                    pageSelector.SelectedNode = pageSelector.Nodes[siteActive.GetUIIndex()];
                    return;
                }
                activePageIndex = -1;
            }

            // initialize the preview
            fSupportsPreview = pageNew.SupportsPreview();
            preview.ClearPreviewDocument(fSupportsPreview);
            mshtmlControl.Visible = fSupportsPreview;

            // initialize the state of the Help button
            helpButton.Enabled = pageNew.SupportsHelp();

            // activate the new page
            activePageIndex = pageIndex;
            pageNew.ActivatePage();
        }
 public Control GetPageControl()
 {
     Debug.Assert(inForm == true, "PageControl is invalid before being added to builder");
     return(page.GetPageControl());
 }