/// <include file='doc\StyleBuilder.uex' path='docs/doc[@for="StyleBuilder.AddPage"]/*' /> /// <devdoc> /// Add the specified page to the list of pages /// </devdoc> protected void AddPage(Type pageClass) { StyleBuilderPageSite pageNew = null; if (pageCache != null) { // check if the page already exists in the cache for (int i = 0; i < pageCache.Count; i++) { StyleBuilderPageSite pageExisting = (StyleBuilderPageSite)pageCache[i]; if (pageClass.Equals(pageExisting.GetPageClass())) { pageNew = pageExisting; pageCache.RemoveAt(i); break; } } } // create the page if it doesn't exist in the cache if (pageNew == null) { pageNew = new StyleBuilderPageSite(pageClass); } pageList.Add(pageNew); }
/// <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(); }
/// <include file='doc\StyleBuilderForm.uex' path='docs/doc[@for="StyleBuilderForm.OnClickBtnCancel"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected virtual void OnClickBtnCancel(object source, EventArgs e) { if (activePageIndex != -1) { StyleBuilderPageSite siteActive = pages[activePageIndex]; siteActive.GetPage().DeactivatePage(true, false); activePageIndex = -1; } Close(); DialogResult = DialogResult.Cancel; }
/// <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(); } } }
/// <include file='doc\StyleBuilderForm.uex' path='docs/doc[@for="StyleBuilderForm.OnClickBtnOK"]/*' /> /// <devdoc> /// <para>[To be supplied.]</para> /// </devdoc> protected virtual void OnClickBtnOK(object source, EventArgs e) { if (activePageIndex != -1) { StyleBuilderPageSite siteActive = pages[activePageIndex]; if (siteActive.GetPage().DeactivatePage(true, true) == false) { // the page cannot be deactivated return; } activePageIndex = -1; } SavePages(); if (styleType == STYLE_TYPE_STRING) { SaveStringStyle(); } Close(); DialogResult = DialogResult.OK; }
/// <include file='doc\StyleBuilder.uex' path='docs/doc[@for="StyleBuilder.GetPages"]/*' /> /// <devdoc> /// Returns the current page list /// </devdoc> internal StyleBuilderPageSite[] GetPages() { StyleBuilderPageSite[] pageArray = new StyleBuilderPageSite[pageList.Count]; pageList.CopyTo(pageArray, 0); return(pageArray); }