/////////////////////////////////////////////////////////////////////////// // Implementation private void CreatePage() { Debug.Assert(page == null, "Page should never have to be recreated"); page = (IStyleBuilderPage)Activator.CreateInstance(pageClass, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, null, null); }
/// <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 void FreePage() { if (page != null) { if (page.GetPageControl() != null) { page.GetPageControl().Dispose(); } page = null; } }
/// <include file='doc\StyleBuilderForm.uex' path='docs/doc[@for="StyleBuilderForm.PreProcessMessage"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> public override bool PreProcessMessage(ref Message msg) { if (activePageIndex != -1) { IStyleBuilderPage activePage = pages[activePageIndex].GetPage(); if (activePage.ProcessPageMessage(ref msg) == true) { return(true); } } return(base.PreProcessMessage(ref msg)); }
/// <include file='doc\StyleBuilderForm.uex' path='docs/doc[@for="StyleBuilderForm.OnHelpRequested"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected override void OnHelpRequested(HelpEventArgs e) { if (activePageIndex != -1) { StyleBuilderPageSite siteActive = pages[activePageIndex]; IStyleBuilderPage pageActive = siteActive.GetPage(); if (pageActive.SupportsHelp()) { pageActive.Help(); } } }
protected int uiIndex; // the page's index within the form UI /////////////////////////////////////////////////////////////////////////// // Constructor public StyleBuilderPageSite(Type pageClass) { Debug.Assert(pageClass != null, "invalid page class passed to StyleBuilderPageSite"); this.pageClass = pageClass; page = null; form = null; inForm = false; loaded = false; dirty = false; uiIndex = -1; }