private void butEdit_Click(object sender, EventArgs e) { if (DockedControl == null) { return; } DashboardDockContainer holder = _dockedControl; if (_onEditClick != null) { _onEditClick(holder.Contr, new EventArgs()); } EventHandler onEditOk = _onEditOk; EventHandler onEditCancel = _onEditCancel; FormDashboardEditCell f = new FormDashboardEditCell(holder.Contr, IsEditMode); if (f.ShowDialog() == DialogResult.OK) { _hasUnsavedChanges = true; onEditOk(holder.Contr, new EventArgs()); } else { onEditCancel(holder.Contr, new EventArgs()); } _dockedControl = holder; }
private void AddCell(int columnIndex, int rowIndex, DashboardDockContainer controlHolder = null) { DashboardCellCtrl cell = new DashboardCellCtrl(controlHolder); cell.IsEditMode = IsEditMode; cell.Dock = DockStyle.Fill; cell.DeleteCellButtonClick += dashboardCell_DeleteCellButtonClick; cell.DeleteColumnButtonClick += dashboardCell_DeleteColumnButtonClick; cell.DeleteColumnButtonMouseEnter += dashboardCell_DeleteColumnButtonMouseEnter; cell.DeleteColumnButtonMouseLeave += dashboardCell_DeleteColumnButtonMouseLeave; cell.DeleteRowButtonClick += dashboardCell_DeleteRowButtonClick; cell.DeleteRowButtonMouseEnter += dashboardCell_DeleteRowButtonMouseEnter; cell.DeleteRowButtonMouseLeave += dashboardCell_DeleteRowButtonMouseLeave; tableLayoutPanel.Controls.Add(cell, columnIndex, rowIndex); }
public DashboardDockContainer GetDroppedControl(DragEventArgs e) { if (DockedControl != null) { return(null); } if (!e.Data.GetDataPresent(typeof(DashboardDockContainer))) { return(null); } DashboardDockContainer holder = (DashboardDockContainer)e.Data.GetData(typeof(DashboardDockContainer)); if (holder == null || holder.Contr == DockedControl) { return(null); } return(holder); }
public DashboardDockContainer CreateDashboardDockContainer(TableBase dbItem = null) { string json = ""; DashboardDockContainer ret = new DashboardDockContainer( this, this.graph, CanEdit?new EventHandler((s, ea) => { //Entering edit mode. //Set graph to loading mode to show the loading icon. graph.IsLoading = true; //Spawn the cache thread(s) but don't block. //Register for OnThreadExitLocal will invoke back to this thread when all the threads have exited and refill the form. DashboardCache.RefreshCellTypeIfInvalid(CellType, new DashboardFilter() { UseDateFilter = false }, false, false, OnThreadExitLocal); //Allow filtering in edit mode. this.ShowFilters = true; //Save a copy of the current settings in case user clicks cancel. json = GetFilterAndGraphSettings(); }):null, new EventHandler((s, ea) => { //Ok click. Just hide the filters. this.ShowFilters = false; }), new EventHandler((s, ea) => { //Cancel click. Just hide the filters and reset to previous settings. this.ShowFilters = false; SetFilterAndGraphSettings(json); }), new EventHandler((s, ea) => { //Spawn the init thread whenever this control gets dropped or dragged. Init(); }), new EventHandler((s, ea) => { //Refresh button was clicked, spawn the init thread and force cache refresh. Init(true); }), dbItem); return(ret); }
public void SetCellLayout(int rows, int columns, List <DashboardCell> cells, GraphQuantityOverTime.OnGetColorFromSeriesGraphTypeArgs onGetSeriesColor, GraphQuantityOverTimeFilter.GetGraphPointsForHQArgs onGetODGraphPointsArgs) { try { tableLayoutPanel.SuspendLayout(); tableLayoutPanel.Controls.Clear(); tableLayoutPanel.RowStyles.Clear(); tableLayoutPanel.ColumnStyles.Clear(); tableLayoutPanel.RowCount = rows; tableLayoutPanel.ColumnCount = columns; for (int rowIndex = 0; rowIndex < rows; rowIndex++) { tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent)); tableLayoutPanel.RowStyles[rowIndex].Height = 100 / (float)rows; } for (int columnIndex = 0; columnIndex < columns; columnIndex++) { tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent)); tableLayoutPanel.ColumnStyles[columnIndex].Width = 100 / (float)columns; } for (int rowIndex = 0; rowIndex < rows; rowIndex++) { for (int columnIndex = 0; columnIndex < columns; columnIndex++) { DashboardCell cell = cells.FirstOrDefault(x => x.CellColumn == columnIndex && x.CellRow == rowIndex); DashboardDockContainer cellHolder = null; if (cell != null) { //Currently all CellTypes return GraphQuantityOverTimeFilter. Add a switch here if we ever want to dock a different control type. cellHolder = new GraphQuantityOverTimeFilter(cell.CellType, cell.CellSettings, onGetSeriesColor, onGetODGraphPointsArgs).CreateDashboardDockContainer(cell); } AddCell(columnIndex, rowIndex, cellHolder); } } } finally { tableLayoutPanel.ResumeLayout(); } }
public DashboardCellCtrl(DashboardDockContainer controlHolder) { InitializeComponent(); _dockedControl = controlHolder; }