/// <summary>Constructor.</summary> /// <param name="sheetView">The sheet to paint.</param> /// <param name="sheetEditor">The optional cell editor instance.</param> /// <param name="sheetSelection">The optional cell selection instance.</param> public DefaultCellPainter(SheetWidget sheetView, ISheetEditor sheetEditor = null, ISheetSelection sheetSelection = null) { sheet = sheetView; editor = sheetEditor; selection = sheetSelection; }
/// <summary>Populate the grid control with data.</summary> public void PopulateGrid() { if (!string.IsNullOrEmpty(tableDropDown.SelectedValue)) { // Note that the filter contains the zone filter and experiment filter but not simulation filter. IEnumerable <string> simulationNames = null; if (ExperimentFilter != null) { // fixme: this makes some serious assumptions about how the query is generated in the data store layer... simulationNames = ExperimentFilter.GenerateSimulationDescriptions().Select(s => s.Name); } else if (SimulationFilter == null) { simulationNames = null; } else { simulationNames = new string[] { SimulationFilter.Name } }; string filter = rowFilterEditBox.Text; if (ZoneFilter != null) { // More assumptions about column names filter = AppendToFilter(filter, $"[Zone] = '{ZoneFilter.Name}'"); } // Create sheet control if (tableDropDown.SelectedValue != null) { try { // Cleanup existing sheet instances before creating new ones. CleanupSheet(); dataProvider = new PagedDataProvider(dataStore.Reader, checkpointDropDown.SelectedValue, tableDropDown.SelectedValue, simulationNames, columnFilterEditBox.Text, filter); dataProvider.PagingStart += (sender, args) => explorerPresenter.MainPresenter.ShowWaitCursor(true); dataProvider.PagingEnd += (sender, args) => explorerPresenter.MainPresenter.ShowWaitCursor(false); sheet = new SheetWidget() { DataProvider = dataProvider, NumberFrozenRows = dataProvider.NumHeadingRows, NumberFrozenColumns = dataProvider.NumPriorityColumns }; #if NETFRAMEWORK sheet.RowHeight = 20; #endif cellSelector = new SingleCellSelect(sheet); var scrollbars = new SheetScrollBars(sheet); sheet.CellPainter = new DefaultCellPainter(sheet, sheetSelection: cellSelector); sheetContainer.Add(scrollbars.MainWidget); statusLabel.Text = $"Number of rows: {dataProvider.RowCount - dataProvider.NumHeadingRows}"; } catch (Exception err) { explorerPresenter.MainPresenter.ShowError(err.ToString()); } } } }