public BackstageViewPage(UserControl page, string linkText, BackstageViewPage parent = null, bool advanced = false) { Show = true; Page = page; LinkText = linkText; Parent = parent; Advanced = advanced; }
public BackstageViewPage(Type pageType, string linkText, BackstageViewPage parent = null, bool advanced = false) { Show = true; PageType = pageType; LinkText = linkText; Parent = parent; Advanced = advanced; }
private BackstageViewPage AddBackstageViewPage(UserControl userControl, string headerText, BackstageViewPage Parent = null, bool advanced = false) { try { return backstageView.AddPage(userControl, headerText, Parent, advanced); } catch (Exception ex) { log.Error(ex); return null; } }
private BackstageViewPage AddBackstageViewPage(UserControl userControl, string headerText, BackstageViewPage Parent = null, bool advanced = false) { try { log.Debug("adding page "+ headerText); var obj = backstageView.AddPage(userControl, headerText, Parent, advanced); log.Debug("done page " + headerText); return obj; } catch (Exception ex) { log.Error(ex); return null; } }
private void popoutForm_FormClosing(object sender, FormClosingEventArgs e) { // get the page back var temp = ((Form)sender).Tag as BackstageViewPage; // add back to where it belongs this.pnlPages.Controls.Add(temp.Page); // clear the controls, so we dont dispose the good control when it closes ((Form)sender).Controls.Clear(); popoutPage = null; }
private bool PageHasChildren(BackstageViewPage parent) { // check for children foreach (BackstageViewPage child in _items) { if (child.GetType() == typeof(BackstageViewPage)) { if (((BackstageViewPage)child).Parent == parent) { return(true); } } } return(false); }
private void CreateLinkButton(BackstageViewPage page, bool haschild = false, bool child = false) { if (!page.Show) { return; } string label = page.LinkText; int heightextra = 0; if (haschild) { label = ">> " + label; } if (child) { int count = label.Split('\n').Count(); label = " " + label.Replace("\n", "\n "); heightextra = 15 * (count - 1); } var lnkButton = new BackstageViewButton { Text = label, Tag = page, Top = ButtonTopPos, // Top = _items.TakeWhile(i => i != page).Sum(i => i.Spacing), Width = this.pnlMenu.Width, Height = ButtonHeight + heightextra, ContentPageColor = this.BackColor, PencilBorderColor = _buttonsAreaPencilColor, SelectedTextColor = _selectedTextColor, UnSelectedTextColor = _unSelectedTextColor, HighlightColor1 = _highlightColor1, HighlightColor2 = _highlightColor2, //Dock = DockStyle.Bottom }; pnlMenu.Controls.Add(lnkButton); lnkButton.Click += this.ButtonClick; lnkButton.DoubleClick += lnkButton_DoubleClick; ButtonTopPos += lnkButton.Height; pnlMenu.Invalidate(); }
/// <summary> /// Add a page (tab) to this backstage view. Will be added at the end/bottom /// </summary> public BackstageViewPage AddPage(UserControl userControl, string headerText, BackstageViewPage Parent, bool advanced) { var page = new BackstageViewPage(userControl, headerText, Parent, advanced) { Page = { //Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top, Location = new Point(0, 0), Dock = DockStyle.Fill, Visible = false, } }; _items.Add(page); page.Page.Visible = false; this.pnlPages.Controls.Add(page.Page); return page; }
private void CreateLinkButton(BackstageViewPage page, bool haschild = false, bool child = false) { string label = page.LinkText; if (haschild) { label = ">> " + label; } if (child) { label = " " + label; } var lnkButton = new BackstageViewButton { Text = label, Tag = page, Top = ButtonTopPos, // Top = _items.TakeWhile(i => i != page).Sum(i => i.Spacing), Width = this.pnlMenu.Width, Height = ButtonHeight, ContentPageColor = this.BackColor, PencilBorderColor = _buttonsAreaPencilColor, SelectedTextColor = _selectedTextColor, UnSelectedTextColor = _unSelectedTextColor, HighlightColor1 = _highlightColor1, HighlightColor2 = _highlightColor2, //Dock = DockStyle.Bottom }; pnlMenu.Controls.Add(lnkButton); lnkButton.Click += this.ButtonClick; lnkButton.DoubleClick += lnkButton_DoubleClick; ButtonTopPos += lnkButton.Height; }
public int IndexOf(BackstageViewPage itemType) { return List.IndexOf(itemType); }
public void Insert(int index, BackstageViewPage itemType) { List.Insert(index, itemType); }
public void Remove(BackstageViewPage itemType) { List.Remove(itemType); }
/// <summary> /// Add a page (tab) to this backstage view. Will be added at the end/bottom /// </summary> public BackstageViewPage AddPage(Type userControl, string headerText, BackstageViewPage Parent, bool advanced) { var page = new BackstageViewPage(userControl, headerText, Parent, advanced); _items.Add(page); return page; }
private bool PageHasChildren(BackstageViewPage parent) { // check for children foreach (BackstageViewPage child in _items) { if (child.GetType() == typeof(BackstageViewPage)) { if (((BackstageViewPage)child).Parent == parent) { return true; } } } return false; }
public int IndexOf(BackstageViewPage itemType) { return(List.IndexOf(itemType)); }
public void DrawMenu(BackstageViewPage CurrentPage, bool force = false) { if (!force) { if (_activePage == CurrentPage || CurrentPage == null) { return; } } pnlMenu.Visible = false; pnlMenu.SuspendLayout(); pnlMenu.Controls.Clear(); // reset back to 0 ButtonTopPos = 0; foreach (BackstageViewItem page in _items) { if (page.GetType() == typeof(BackstageViewPage)) { // its a base item. we want it if (((BackstageViewPage)page).Parent == null) { bool children = PageHasChildren(page); CreateLinkButton((BackstageViewPage)page, children); // remember whats expanded if (CurrentPage == page && children) { if (expanded.Contains((BackstageViewPage)page)) { expanded.Remove((BackstageViewPage)page); } else { expanded.Add((BackstageViewPage)page); } } // check for children foreach (BackstageViewItem childrenpage in _items) { if (childrenpage.GetType() == typeof(BackstageViewPage)) { if (((BackstageViewPage)childrenpage).Parent == ((BackstageViewPage)page)) { // check if current page has a parent thats not expanded if (CurrentPage == childrenpage && !expanded.Contains((BackstageViewPage)page)) { expanded.Add((BackstageViewPage)page); DrawMenu(CurrentPage, true); return; } // draw all the siblings if (expanded.Contains((BackstageViewPage)page)) { CreateLinkButton((BackstageViewPage)childrenpage, false, true); } } } } continue; } } else { ButtonTopPos += page.Spacing; } } pnlMenu.ResumeLayout(false); pnlMenu.PerformLayout(); pnlMenu.Visible = true; }
public BackstageViewPage(UserControl page, string linkText, BackstageViewPage parent = null) { Page = page; LinkText = linkText; Parent = parent; }
/// <summary> /// Add a page (tab) to this backstage view. Will be added at the end/bottom /// </summary> public BackstageViewPage AddPage(UserControl userControl, string headerText, BackstageViewPage Parent) { var page = new BackstageViewPage(userControl, headerText, Parent) { Page = { //Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top, Location = new Point(0, 0), Dock = DockStyle.Fill, Visible = false, } }; _items.Add(page); //CreateLinkButton(page); //DrawMenu(page); page.Page.Visible = false; this.pnlPages.Controls.Add(page.Page); if (_activePage == null) { // _activePage = page; // ActivatePage(page); } return page; }
private void CreateLinkButton(BackstageViewPage page, bool haschild = false, bool child = false) { if (!page.Show) return; string label = page.LinkText; int heightextra = 0; if (haschild) { label = ">> " + label; } if (child) { int count = label.Split('\n').Count(); label = " " + label.Replace("\n", "\n "); heightextra = 15 * (count - 1); } var lnkButton = new BackstageViewButton { Text = label, Tag = page, Top = ButtonTopPos, // Top = _items.TakeWhile(i => i != page).Sum(i => i.Spacing), Width = this.pnlMenu.Width, Height = ButtonHeight + heightextra, ContentPageColor = this.BackColor, PencilBorderColor = _buttonsAreaPencilColor, SelectedTextColor = _selectedTextColor, UnSelectedTextColor = _unSelectedTextColor, HighlightColor1 = _highlightColor1, HighlightColor2 = _highlightColor2, //Dock = DockStyle.Bottom }; pnlMenu.Controls.Add(lnkButton); lnkButton.Click += this.ButtonClick; lnkButton.DoubleClick += lnkButton_DoubleClick; ButtonTopPos += lnkButton.Height; }
public int Add(BackstageViewPage itemType) { return(List.Add(itemType)); }
public void DrawMenu(BackstageViewPage CurrentPage, bool force = false) { if (!force) { if (_activePage == CurrentPage || CurrentPage == null) { bool children = PageHasChildren(CurrentPage); if (!children) { return; } } } pnlMenu.Visible = false; pnlMenu.SuspendLayout(); pnlMenu.Controls.Clear(); // reset back to 0 ButtonTopPos = 0; foreach (BackstageViewPage page in _items) { if (page.GetType() == typeof(BackstageViewPage)) { // skip advanced pages if we are not advanced if (page.Advanced && !Advanced) { continue; } // its a base item. we want it if (((BackstageViewPage)page).Parent == null) { bool children = PageHasChildren(page); CreateLinkButton((BackstageViewPage)page, children); // remember whats expanded if (CurrentPage == page && children) { if (expanded.Contains((BackstageViewPage)page)) { expanded.Remove((BackstageViewPage)page); } else { expanded.Add((BackstageViewPage)page); } } // check for children foreach (BackstageViewPage childrenpage in _items) { if (childrenpage.GetType() == typeof(BackstageViewPage)) { if (((BackstageViewPage)childrenpage).Parent == ((BackstageViewPage)page)) { // check if current page has a parent thats not expanded if (CurrentPage == childrenpage && !expanded.Contains((BackstageViewPage)page)) { expanded.Add((BackstageViewPage)page); DrawMenu(CurrentPage, true); return; } // draw all the siblings if (expanded.Contains((BackstageViewPage)page) || this.DesignMode) { CreateLinkButton((BackstageViewPage)childrenpage, false, true); } } } } continue; } } else { ButtonTopPos += page.Spacing; } } pnlMenu.ResumeLayout(false); pnlMenu.PerformLayout(); pnlMenu.Visible = true; }
public bool Contains(BackstageViewPage itemType) { return List.Contains(itemType); }
/* * Experimental - double clicking a button will spawn it out into a new form * Care must be given to lifecycle here - two pages can now be interacted with * 'simultaneously' */ private void lnkButton_DoubleClick(object sender, EventArgs e) { var backstageViewButton = ((BackstageViewButton)sender); var associatedPage = backstageViewButton.Tag as BackstageViewPage; var popoutForm = new Form(); popoutForm.FormClosing += popoutForm_FormClosing; int maxright = 0, maxdown = 0; foreach (Control ctl in associatedPage.Page.Controls) { maxright = Math.Max(ctl.Right, maxright); maxdown = Math.Max(ctl.Bottom, maxdown); } // set the height to 0, so we can derive the header height in the next step popoutForm.Height = 0; popoutForm.Size = new Size(maxright + 20, maxdown + 20 + popoutForm.Height); popoutForm.Controls.Add(associatedPage.Page); popoutForm.Tag = associatedPage; popoutForm.Text = associatedPage.LinkText; popoutPage = associatedPage; popoutForm.BackColor = this.BackColor; popoutForm.ForeColor = this.ForeColor; popoutForm.Show(this); }
public int Add(BackstageViewPage itemType) { return List.Add(itemType); }
public void ActivatePage(BackstageViewPage associatedPage) { if (associatedPage == null) { if (associatedPage.Page == null) return; if (_activePage == null) DrawMenu(null, true); return; } MissionPlanner.Utilities.Tracking.AddPage(associatedPage.Page.GetType().ToString(), associatedPage.LinkText); this.SuspendLayout(); associatedPage.Page.SuspendLayout(); DrawMenu(associatedPage, false); // Deactivate old page if (_activePage != null && _activePage.Page is IDeactivate) { ((IDeactivate)(_activePage.Page)).Deactivate(); } // deactivate the old page - obsolete way of notifying activation //_activePage.Page.Close(); foreach (BackstageViewPage p in Pages) { if (p.Page.Visible != false) p.Page.Visible = false; } try { // if the button was on an expanded tab. when we leave it no longer exits if (_activePage != null) { var oldButton = this.pnlMenu.Controls.OfType<BackstageViewButton>().Single(b => b.Tag == _activePage); oldButton.IsSelected = false; } } catch { } // new way of notifying activation. Goal is to get rid of BackStageViewContentPanel // so plain old user controls can be added if (associatedPage.Page is IActivate) { ((IActivate)(associatedPage.Page)).Activate(); } //this.PerformLayout(); associatedPage.Page.ResumeLayout(); this.ResumeLayout(); // show it associatedPage.Page.Visible = true; try { var newButton = this.pnlMenu.Controls.OfType<BackstageViewButton>().Single(b => b.Tag == associatedPage); newButton.IsSelected = true; } catch { } _activePage = associatedPage; }
public void DrawMenu(BackstageViewPage CurrentPage, bool force = false) { if (!force) { if (_activePage == CurrentPage || CurrentPage == null) { bool children = PageHasChildren(CurrentPage); if (!children) { return; } } } pnlMenu.Controls.Clear(); // reset back to 0 ButtonTopPos = 0; foreach (BackstageViewPage page in _items) { if (page.GetType() == typeof(BackstageViewPage)) { // skip advanced pages if we are not advanced if (page.Advanced && !Advanced) { continue; } // its a base item. we want it if (((BackstageViewPage)page).Parent == null) { bool children = PageHasChildren(page); CreateLinkButton((BackstageViewPage)page, children); // remember whats expanded if (CurrentPage == page && children) { if (expanded.Contains((BackstageViewPage)page)) { expanded.Remove((BackstageViewPage)page); } else { expanded.Add((BackstageViewPage)page); } } // check for children foreach (BackstageViewPage childrenpage in _items) { if (childrenpage.GetType() == typeof(BackstageViewPage)) { if (((BackstageViewPage)childrenpage).Parent == ((BackstageViewPage)page)) { // check if current page has a parent thats not expanded if (CurrentPage == childrenpage && !expanded.Contains((BackstageViewPage)page)) { expanded.Add((BackstageViewPage)page); DrawMenu(CurrentPage, true); return; } // draw all the siblings if (expanded.Contains((BackstageViewPage)page) || this.DesignMode) { CreateLinkButton((BackstageViewPage)childrenpage, false, true); } } } } continue; } } else { ButtonTopPos += page.Spacing; } } pnlMenu.Invalidate(); }
public void ActivatePage(BackstageViewPage associatedPage) { if (associatedPage == null) { if (_activePage == null) { DrawMenu(null, true); } return; } Tracking?.Invoke(associatedPage.Page.GetType().ToString(), associatedPage.LinkText); var start = DateTime.Now; this.SuspendLayout(); associatedPage.Page.SuspendLayout(); DrawMenu(associatedPage, false); // Deactivate old page if (_activePage != null && _activePage.Page is IDeactivate) { try { ((IDeactivate)(_activePage.Page)).Deactivate(); } catch (Exception ex) { log.Error(ex); } } // deactivate the old page - obsolete way of notifying activation //_activePage.Page.Close(); if (_activePage != null && _activePage.Page != null) { _activePage.Page.Visible = false; } try { // if the button was on an expanded tab. when we leave it no longer exits if (_activePage != null) { var oldButton = this.pnlMenu.Controls.OfType <BackstageViewButton>().Single(b => b.Tag == _activePage); oldButton.IsSelected = false; } } catch (Exception ex) { log.Error(ex); } associatedPage.Page.ResumeLayout(false); this.ResumeLayout(false); // show it associatedPage.Page.Visible = true; if (!pnlPages.Controls.Contains(associatedPage.Page)) { this.pnlPages.Controls.Add(associatedPage.Page); } // new way of notifying activation. Goal is to get rid of BackStageViewContentPanel // so plain old user controls can be added if (associatedPage.Page is IActivate) { ((IActivate)(associatedPage.Page)).Activate(); } try { var newButton = this.pnlMenu.Controls.OfType <BackstageViewButton>().Single(b => b.Tag == associatedPage); newButton.IsSelected = true; } catch (Exception ex) { log.Error(ex); } var end = DateTime.Now; log.DebugFormat("{0} {1} {2}", associatedPage.Page.GetType().ToString(), associatedPage.LinkText, (end - start).TotalMilliseconds); _activePage = associatedPage; }
public bool Contains(BackstageViewPage itemType) { return(List.Contains(itemType)); }