public void UpdateDisplay(string variableId) { string[] components = variableId.Split('_'); if (components.Length == 3) { SpreadsheetComponentCell cell = GetComponentCell(variableId); if (cell != null) { cell.UpdateDisplay(); } } else if (components.Length == 2) { // column / row header if (components[1][0] == 'c') { string columnId = components[1].Substring(1); int col = data.GetColumnIndexFromColumnId(columnId); UpdateColumn(col); } else if (components[1][0] == 'r') { string rowId = components[1].Substring(1); int row = data.GetRowIndexFromRowId(rowId); UpdateRow(row); } } }
public AbstractComponentData GetData() { if (grid.SelectedCells.Count == 0) { return(null); } else if (grid.SelectedCells.Count == 1) { DataGridCellInfo cellInfo = grid.SelectedCells[0]; SpreadsheetComponentCell cell = cellInfo.Column.GetCellContent(cellInfo.Item) as SpreadsheetComponentCell; return(cell.data); } else { PointInt rangeStart = new PointInt(grid.Columns.Count, grid.Items.Count); PointInt rangeEnd = new PointInt(-1, -1); foreach (DataGridCellInfo cellInfo in grid.SelectedCells) { PointInt position = GetCellPositionFromCellInfo(cellInfo); rangeStart.X = Math.Min(rangeStart.X, position.X); rangeStart.Y = Math.Min(rangeStart.Y, position.Y); rangeEnd.X = Math.Max(rangeEnd.X, position.X); rangeEnd.Y = Math.Max(rangeEnd.Y, position.Y); } string startId = data.cells[rangeStart.Y][rangeStart.X].id; string endId = data.cells[rangeEnd.Y][rangeEnd.X].id; SpreadsheetRangeData rangeData = new SpreadsheetRangeData(this.valueStore, this.data, startId, endId); return(rangeData); } }
void UpdateRow(int row) { DataGridRow gridRow = grid.GetRow(row); if (gridRow == null) { return; } if (data.rowDatas[row].HasCustomLabel()) { gridRow.Header = data.rowDatas[row].label; } else { gridRow.Header = ""; gridRow.Header = GetRowName(row); } for (int col = 0; col < grid.Columns.Count; col++) { DataGridCell cell = grid.GetCell(row, col); if (cell != null) { SpreadsheetComponentCell component = cell.Content as SpreadsheetComponentCell; component.UpdateDisplay(); } } gridRow.Tag = data.rowDatas[row].HasExpression(); // use Tag to store IsReadOnly information }
protected override FrameworkElement GenerateEditingElement(DataGridCell cell, object dataItem) { var el = new SpreadsheetComponentCell(); //el.textBox.IsHitTestVisible = true; el.IsEditing = true; var bb = this.Binding as Binding; var b = new Binding { Path = bb.Path, Source = dataItem, Mode = BindingMode.TwoWay }; el.SetBinding(SpreadsheetComponentCell.DataProperty, b); return(el); }
private void gridDelete_Executed(object sender, ExecutedRoutedEventArgs e) { if (grid.SelectedCells.Count == 1) { DataGridCellInfo cellInfo = grid.SelectedCells[0]; SpreadsheetComponentCell cell = cellInfo.Column.GetCellContent(cellInfo.Item) as SpreadsheetComponentCell; if (cell.data.dataTableData != null) { MessageBoxResult result = MessageBox.Show("Do you want to delete the entire Data Table?", "Delete Data Table", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { Command.DeleteDatatable.Execute(cell.data.dataTableData, Application.Current.MainWindow); } } } }
public IConnectable GetConnector(string variableId) { if (DataHelper.IsSpreadsheetRangeId(variableId)) { return(this); } else { string[] components = variableId.Split('_'); if (components.Length == 3) { // cell SpreadsheetComponentCell cell = GetComponentCell(variableId); if (cell != null) { return(cell.textBox); } } else if (components.Length == 2) { // column / row header if (components[1][0] == 'c') { // column header DataGridColumnHeader header = GetColumnHeader(variableId); if (header != null) { return(UIHelper.FindVisualChild <SpreadsheetHeaderExpressionText>(header)); } } else if (components[1][0] == 'r') { // row header DataGridRowHeader header = GetRowHeader(variableId); if (header != null) { return(UIHelper.FindVisualChild <SpreadsheetHeaderExpressionText>(header)); } } } } return(null); }
private static void OnIsRowReadOnlyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { SpreadsheetComponentCell obj = ((SpreadsheetComponentCell)d); obj.IsReadOnly = (bool)e.NewValue || obj.IsColumnReadOnly; }
private static void OnIsEditingChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { SpreadsheetComponentCell obj = ((SpreadsheetComponentCell)d); obj.IsFocusable = !obj.IsReadOnly && (bool)e.NewValue; // IsFocusable = !IsReadOnly && IsEditing }