public void BuildTemplate() { bool noColumns = Matrix.Data.Columns.Count == 0; bool noRows = Matrix.Data.Rows.Count == 0; bool noCells = Matrix.Data.Cells.Count == 0; // create temporary descriptors if (noColumns) { Matrix.Data.Columns.Add(noColumnsDescriptor); } if (noRows) { Matrix.Data.Rows.Add(noRowsDescriptor); } if (noCells) { Matrix.Data.Cells.Add(noCellsDescriptor); } UpdateTemplateSizes(); // prepare data for the result table string[] columnValues = new string[Matrix.Data.Columns.Count]; string[] rowValues = new string[Matrix.Data.Rows.Count]; object[] cellValues = new object[Matrix.Data.Cells.Count]; for (int i = 0; i < Matrix.Data.Columns.Count; i++) { columnValues[i] = "[" + ExtractColumnName(Matrix.Data.Columns[i].Expression) + "]"; } for (int i = 0; i < Matrix.Data.Rows.Count; i++) { rowValues[i] = "[" + ExtractColumnName(Matrix.Data.Rows[i].Expression) + "]"; } Matrix.Data.Clear(); Matrix.Data.AddValue(columnValues, rowValues, cellValues, 0); // create the result table designTime = true; resultTable = new TableResult(); InitResultTable(true); PrintHeaders(); PrintData(); // copy the result table to the Matrix Matrix.ColumnCount = ResultTable.ColumnCount; Matrix.RowCount = ResultTable.RowCount; Matrix.FixedColumns = HeaderWidth; Matrix.FixedRows = HeaderHeight; Matrix.CreateUniqueNames(); for (int x = 0; x < Matrix.ColumnCount; x++) { Matrix.Columns[x].Assign(ResultTable.Columns[x]); } for (int y = 0; y < Matrix.RowCount; y++) { Matrix.Rows[y].Assign(ResultTable.Rows[y]); } for (int x = 0; x < Matrix.ColumnCount; x++) { for (int y = 0; y < Matrix.RowCount; y++) { TableCell cell = Matrix[x, y]; cell.AssignAll(ResultTable[x, y]); cell.SetFlags(Flags.CanEdit, true); } } UpdateDescriptors(); resultTable.Dispose(); // clear temporary descriptors, set hints if (noColumns) { SetHint(Matrix[HeaderWidth, Matrix.ShowTitle ? 1 : 0], Res.Get("ComponentsMisc,Matrix,NewColumn")); Matrix.Data.Columns.Clear(); } else { noColumnsDescriptor.TemplateColumn = Matrix.Data.Columns[0].TemplateColumn; noColumnsDescriptor.TemplateRow = Matrix.Data.Columns[0].TemplateRow; noColumnsDescriptor.TemplateCell = Matrix.Data.Columns[0].TemplateCell; } if (noRows) { SetHint(Matrix[0, HeaderHeight], Res.Get("ComponentsMisc,Matrix,NewRow")); Matrix.Data.Rows.Clear(); } else { noRowsDescriptor.TemplateColumn = Matrix.Data.Rows[0].TemplateColumn; noRowsDescriptor.TemplateRow = Matrix.Data.Rows[0].TemplateRow; noRowsDescriptor.TemplateCell = Matrix.Data.Rows[0].TemplateCell; } if (noCells) { SetHint(Matrix[HeaderWidth, HeaderHeight], Res.Get("ComponentsMisc,Matrix,NewCell")); Matrix.Data.Cells.Clear(); } else { noCellsDescriptor.TemplateColumn = Matrix.Data.Cells[0].TemplateColumn; noCellsDescriptor.TemplateRow = Matrix.Data.Cells[0].TemplateRow; noCellsDescriptor.TemplateCell = Matrix.Data.Cells[0].TemplateCell; } }
public void BuildTemplate() { // create temporary descriptors if (!CrossView.Data.SourceAssigned) { CrossView.Data.columnDescriptorsIndexes = new int[] { 0 }; CrossView.Data.rowDescriptorsIndexes = new int[] { 0 }; CrossView.Data.columnTerminalIndexes = new int[] { 0 }; CrossView.Data.rowTerminalIndexes = new int[] { 0 }; CrossView.Data.Columns.Add(noColumnsDescriptor); CrossView.Data.Rows.Add(noRowsDescriptor); CrossView.Data.Cells.Add(noCellsDescriptor); } UpdateTemplateSizes(); // create the result table designTime = true; resultTable = new TableResult(); InitTemplateTable(); PrintHeaders(); PrintXAxisTemplate(); PrintYAxisTemplate(); PrintDataTemplate(); // copy the result table to the Matrix CrossView.ColumnCount = ResultTable.ColumnCount; CrossView.RowCount = ResultTable.RowCount; CrossView.FixedColumns = HeaderWidth; CrossView.FixedRows = HeaderHeight; CrossView.CreateUniqueNames(); for (int x = 0; x < CrossView.ColumnCount; x++) { CrossView.Columns[x].Assign(ResultTable.Columns[x]); } for (int y = 0; y < CrossView.RowCount; y++) { CrossView.Rows[y].Assign(ResultTable.Rows[y]); } for (int x = 0; x < CrossView.ColumnCount; x++) { for (int y = 0; y < CrossView.RowCount; y++) { TableCell cell = CrossView[x, y]; cell.AssignAll(ResultTable[x, y]); cell.SetFlags(Flags.CanEdit, true); } } UpdateDescriptors(); resultTable.Dispose(); // clear temporary descriptors, set hints if (!CrossView.Data.SourceAssigned) { SetHint(CrossView[HeaderWidth, (CrossView.ShowTitle ? 1 : 0) + (CrossView.ShowXAxisFieldsCaption ? 1 : 0)], Res.Get("ComponentsMisc,CrossView,SetSource")); CrossView.Data.Columns.Clear(); SetHint(CrossView[0, HeaderHeight], Res.Get("ComponentsMisc,CrossView,SetSource")); CrossView.Data.Rows.Clear(); SetHint(CrossView[HeaderWidth, HeaderHeight], Res.Get("ComponentsMisc,CrossView,SetSource")); CrossView.Data.Cells.Clear(); CrossView.Data.columnDescriptorsIndexes = new int[0]; CrossView.Data.rowDescriptorsIndexes = new int[0]; CrossView.Data.columnTerminalIndexes = new int[0]; CrossView.Data.rowTerminalIndexes = new int[0]; } else { noColumnsDescriptor.TemplateColumn = CrossView.Data.Columns[0].TemplateColumn; noColumnsDescriptor.TemplateRow = CrossView.Data.Columns[0].TemplateRow; noColumnsDescriptor.TemplateCell = CrossView.Data.Columns[0].TemplateCell; noRowsDescriptor.TemplateColumn = CrossView.Data.Rows[0].TemplateColumn; noRowsDescriptor.TemplateRow = CrossView.Data.Rows[0].TemplateRow; noRowsDescriptor.TemplateCell = CrossView.Data.Rows[0].TemplateCell; noCellsDescriptor.TemplateColumn = CrossView.Data.Cells[0].TemplateColumn; noCellsDescriptor.TemplateRow = CrossView.Data.Cells[0].TemplateRow; noCellsDescriptor.TemplateCell = CrossView.Data.Cells[0].TemplateCell; } }