private TabPage AddTabPage(string tabText = "", DashboardPanelCtrl dashboardPanel = null) { int i = 1; if (string.IsNullOrEmpty(tabText)) { tabText = "Tab " + i.ToString(); } while (tabControl.TabPages.ContainsKey(tabText)) { i++; tabText = "Tab " + i.ToString(); } if (dashboardPanel == null) { dashboardPanel = new DashboardPanelCtrl(); } TabPage tabPage = new TabPage(tabText); tabPage.Name = tabText; tabPage.ImageIndex = IsEditMode?1:-1; //Show the delete button if edit mode. tabPage.BackColor = SystemColors.Control; dashboardPanel.Dock = DockStyle.Fill; dashboardPanel.Name = tabText; dashboardPanel.IsEditMode = IsEditMode; tabPage.Controls.Add(dashboardPanel); tabControl.CreateControl(); tabControl.TabPages.Insert(IsEditMode?tabControl.TabCount - 1:tabControl.TabCount, tabPage); //Insert before the 'add' tab if in edit mode. tabControl.SelectedTab = tabPage; RefreshTabOrdering(); return(tabPage); }
///<summary>Any unsaved changes will be overwritten. Prompt the user to save changes before calling this method.</summary> public void SetDashboardLayout(List <DashboardLayout> layouts, bool invalidateFirst, GraphQuantityOverTime.OnGetColorFromSeriesGraphTypeArgs onGetSeriesColor = null, GraphQuantityOverTimeFilter.GetGraphPointsForHQArgs onGetODGraphPointsArgs = null) { //This may need to be uncommented if user is not being prompted to save changes in certain cases. //_hasUnsavedChanges=false; if (IsEditMode) { while (tabControl.TabCount > 1) //Leave the 'add' tab. { tabControl.TabPages.RemoveAt(0); } } else { while (tabControl.TabCount > 0) //Remove all tabs. { tabControl.TabPages.RemoveAt(0); } } //This will start cache threads. Cache.DashboardCache.RefreshLayoutsIfInvalid(layouts, false, invalidateFirst); this.SuspendLayout(); layouts.OrderBy(x => x.DashboardTabOrder).ToList().ForEach(x => { DashboardPanelCtrl dashboardPanel = new DashboardPanelCtrl(x); dashboardPanel.SetCellLayout(x.DashboardRows, x.DashboardColumns, x.Cells, onGetSeriesColor, onGetODGraphPointsArgs); AddTabPage(x.DashboardTabName, dashboardPanel); }); if (tabControl.TabCount >= 1) { tabControl.SelectedIndex = 0; } this.ResumeLayout(); }
///<summary>Gets the tabPage and DashboardPanelControl for the given tab page index.</summary> private bool GetDashboardPanel(int tabIndex, out TabPage tabPage, out DashboardPanelCtrl dashboardPanel) { tabPage = tabControl.TabPages[tabIndex]; dashboardPanel = null; if (tabPage.Controls.Count <= 0 || !(tabPage.Controls[0] is DashboardPanelCtrl)) { return(false); } dashboardPanel = (DashboardPanelCtrl)tabPage.Controls[0]; return(true); }
///<summary>Dictionary of charts to get converted to a bmp. ///It would be great if this could be replaced with sheets sometime in the future.</summary> public FormPrintImage(DashboardPanelCtrl dashPanel) { InitializeComponent(); _dashPanel = dashPanel; }