private void PrintTitle() { TableCell templateCell = titleDescriptor.TemplateCell; if (titleDescriptor.TemplateCell == null) { templateCell = CreateCell(Res.Get("ComponentsMisc,Matrix,Title")); } TableCellData resultCell = ResultTable.GetCellData(HeaderWidth, 0); templateCell.SaveState(); templateCell.GetData(); resultCell.RunTimeAssign(templateCell, true); resultCell.ColSpan = ResultTable.ColumnCount - HeaderWidth; templateCell.RestoreState(); // print left-top cell if (titleDescriptor.TemplateCell == null) { templateCell.Text = ""; } else { templateCell = Matrix[0, 0]; } resultCell = ResultTable.GetCellData(0, 0); templateCell.SaveState(); templateCell.GetData(); resultCell.RunTimeAssign(templateCell, true); templateCell.RestoreState(); resultCell.ColSpan = HeaderWidth; }
private void PrintHeaderCell(MatrixHeaderItem item, TableCellData resultCell, bool isEven) { TableCell templateCell = item.TemplateCell; if (templateCell != null) { if (FDesignTime) { if (!item.IsTotal) { templateCell.Text = item.Value.ToString(); } resultCell.RunTimeAssign(templateCell, true); } else { if (Matrix.DataSource != null) { Matrix.DataSource.CurrentRowNo = item.DataRowNo; } templateCell.SetValue(item.Value); if (!item.IsTotal) { templateCell.Text = templateCell.Format.FormatValue(item.Value); } templateCell.SaveState(); templateCell.GetData(); if (String.IsNullOrEmpty(templateCell.Hyperlink.Expression) && (templateCell.Hyperlink.Kind == HyperlinkKind.DetailReport || templateCell.Hyperlink.Kind == HyperlinkKind.DetailPage || templateCell.Hyperlink.Kind == HyperlinkKind.Custom)) { templateCell.Hyperlink.Value = templateCell.Text; } if (isEven) { templateCell.ApplyEvenStyle(); } resultCell.RunTimeAssign(templateCell, true); templateCell.RestoreState(); } } else { templateCell = CreateCell(item.IsTotal ? Res.Get("ComponentsMisc,Matrix,Total") : item.Value.ToString()); resultCell.RunTimeAssign(templateCell, true); } }
private void PrintDataTemplate() { CrossViewCellDescriptor crossViewCellDescriptor; int top = headerHeight; int left = headerWidth; TableCell templateCell = null; TableCellData resultCell = null; for (int i = 0; i < CrossView.Data.columnTerminalIndexes.Length; i++) { for (int j = 0; j < CrossView.Data.rowTerminalIndexes.Length; j++) { crossViewCellDescriptor = CrossView.Data.Cells[i * CrossView.Data.rowTerminalIndexes.Length + j]; resultCell = ResultTable.GetCellData(left + i, top + j); templateCell = crossViewCellDescriptor.TemplateCell; if (templateCell == null) { templateCell = CreateDataCell(); } templateCell.Text = "0"; resultCell.RunTimeAssign(templateCell, true); } } }
private void PrintResultData() { CrossViewCellDescriptor crossViewCellDescriptor; int top = headerHeight; int left = headerWidth; TableCell templateCell = null; TableCellData resultCell = null; CrossViewMeasureCell cubeMeasureCell; for (int i = 0; i < CrossView.Data.DataColumnCount; i++) { for (int j = 0; j < CrossView.Data.DataRowCount; j++) { cubeMeasureCell = CrossView.CubeSource.GetMeasureCell(i, j); crossViewCellDescriptor = CrossView.Data.Cells[0]; // todoCUBE temp 0 !!! resultCell = ResultTable.GetCellData(left + i, top + j); templateCell = crossViewCellDescriptor.TemplateCell; if (templateCell == null) { templateCell = CreateDataCell(); } templateCell.Text = cubeMeasureCell.Text; resultCell.RunTimeAssign(templateCell, true); } } }
private void PrintXAxisFieldsCaption() { int top = (CrossView.ShowTitle ? 1 : 0); int templateTop = titleDescriptor.TemplateRow != null ? 1 : 0; string captions = ""; for (int i = 0; i < CrossView.Data.XAxisFieldsCount; i++) { CrossViewHeaderDescriptor descr = crossView.Data.GetRowDescriptor(i); if (captions != "") { captions += ", "; } captions += descr.GetName(); } TableCell templateCell = xAxisFieldCaptionDescriptor.TemplateCell; if (xAxisFieldCaptionDescriptor.TemplateCell == null) { templateCell = CreateCell(captions); } TableCellData resultCell = ResultTable.GetCellData(HeaderWidth, top); templateCell.SaveState(); templateCell.GetData(); resultCell.RunTimeAssign(templateCell, true); resultCell.ColSpan = ResultTable.ColumnCount - HeaderWidth; templateCell.RestoreState(); }
private void PrintCorner() { int left = 0; int top = (CrossView.ShowTitle ? 1 : 0); int templateTop = titleDescriptor.TemplateRow != null ? 1 : 0; if (CrossView.ShowYAxisFieldsCaption) { for (int i = 0; i < HeaderWidth; i++) { TableCell templateCell = null; CrossViewHeaderDescriptor descr = crossView.Data.GetColumnDescriptor(i); if (descr.TemplateColumn != null) { templateCell = CrossView[0, templateTop]; } else { templateCell = CreateCell(descr.GetName()); } TableCellData resultCell = ResultTable.GetCellData(left, top); templateCell.SaveState(); templateCell.GetData(); resultCell.RunTimeAssign(templateCell, true); templateCell.RestoreState(); resultCell.RowSpan = HeaderHeight - top; resultCell.Text = descr.GetName(); left++; } } else { TableCell templateCell = CreateCell(""); TableCellData resultCell = ResultTable.GetCellData(left, top); templateCell.SaveState(); templateCell.GetData(); resultCell.RunTimeAssign(templateCell, true); templateCell.RestoreState(); resultCell.ColSpan = HeaderWidth; resultCell.RowSpan = HeaderHeight - top; } }
public bool YAxisDrawCellHandler(CrossViewAxisDrawCell crossViewAxisDrawCell) { CrossViewHeaderDescriptor crossViewHeaderDescriptor = CrossView.Data.Rows[0]; // temp - 0 todoCUBE TableCellData resultCell = ResultTable.GetCellData(axisLeft + crossViewAxisDrawCell.Level, axisTop + crossViewAxisDrawCell.Cell); resultCell.ColSpan = crossViewAxisDrawCell.SizeLevel; resultCell.RowSpan = crossViewAxisDrawCell.SizeCell; TableCell templateCell = crossViewHeaderDescriptor.TemplateCell; if (templateCell != null) { templateCell.Text = crossViewAxisDrawCell.Text; } else { templateCell = CreateCell(crossViewAxisDrawCell.Text); } resultCell.RunTimeAssign(templateCell, true); return(false); }
private void PrintYAxisTemplate() { int left = 0; int top = headerHeight; for (int i = 0; i < CrossView.Data.Rows.Count; i++) { CrossViewHeaderDescriptor crossViewHeaderDescriptor = CrossView.Data.Rows[i]; TableCellData resultCell = ResultTable.GetCellData(left + crossViewHeaderDescriptor.level, top + crossViewHeaderDescriptor.cell); resultCell.ColSpan = crossViewHeaderDescriptor.levelsize; resultCell.RowSpan = crossViewHeaderDescriptor.cellsize; TableCell templateCell = crossViewHeaderDescriptor.TemplateCell; if (templateCell != null) { templateCell.Text = "[" + crossViewHeaderDescriptor.GetName() + "]"; } else { templateCell = CreateCell("[" + crossViewHeaderDescriptor.GetName() + "]"); } resultCell.RunTimeAssign(templateCell, true); } }
private void PrintXAxisTemplate() { int left = headerWidth; int top = (CrossView.ShowTitle ? 1 : 0) + (CrossView.ShowXAxisFieldsCaption ? 1 : 0); for (int i = 0; i < CrossView.Data.Columns.Count; i++) { CrossViewHeaderDescriptor crossViewHeaderDescriptor = CrossView.Data.Columns[i]; TableCellData resultCell = ResultTable.GetCellData(left + crossViewHeaderDescriptor.cell, top + crossViewHeaderDescriptor.level); resultCell.ColSpan = crossViewHeaderDescriptor.cellsize; resultCell.RowSpan = crossViewHeaderDescriptor.levelsize; TableCell templateCell = crossViewHeaderDescriptor.TemplateCell; if (templateCell != null) { templateCell.Text = "[" + crossViewHeaderDescriptor.GetName() + "]"; } else { templateCell = CreateCell("[" + crossViewHeaderDescriptor.GetName() + "]"); } resultCell.RunTimeAssign(templateCell, true); } }
private void PrintCorner() { int left = 0; int top = Matrix.ShowTitle ? 1 : 0; int templateTop = titleDescriptor.TemplateRow != null ? 1 : 0; List <MatrixDescriptor> descrList = new List <MatrixDescriptor>(); descrList.AddRange(Matrix.Data.Rows.ToArray()); if (Matrix.Data.Cells.Count > 1 && !Matrix.CellsSideBySide) { descrList.Add(cellHeaderDescriptor); } foreach (MatrixDescriptor descr in descrList) { TableCell templateCell = null; if (descr.TemplateColumn != null) { templateCell = Matrix[descr.TemplateColumn.Index, templateTop]; } else { templateCell = CreateCell(ExtractColumnName(descr.Expression)); } TableCellData resultCell = ResultTable.GetCellData(left, top); templateCell.SaveState(); templateCell.GetData(); resultCell.RunTimeAssign(templateCell, true); templateCell.RestoreState(); resultCell.RowSpan = HeaderHeight - top; left++; } }
private void PrintData() { // use two passes to calc cell values. This is necessary because this calculation // replaces an array of cell values by the single (aggregated) value. // At the first pass we calc total values only (so they include all cell values, not aggregated ones); // at the second pass we calc other values except total. PrintData_CalcTotals(1); PrintData_CalcTotals(2); // calc percents PrintData_CalcPercents(); // fire AfterTotals event Matrix.OnAfterTotals(EventArgs.Empty); List <MatrixHeaderItem> columnTerminalItems = Matrix.Data.Columns.RootItem.GetTerminalItems(); List <MatrixHeaderItem> rowTerminalItems = Matrix.Data.Rows.RootItem.GetTerminalItems(); int dataCount = Matrix.Data.Cells.Count; int top = HeaderHeight; Point bodyLocation = GetBodyLocation(); bool firstTimePrintingData = true; cellValues = new object[dataCount]; Matrix.RowIndex = 0; foreach (MatrixHeaderItem rowItem in rowTerminalItems) { int left = HeaderWidth; Matrix.RowValues = rowItem.Values; Matrix.ColumnIndex = 0; foreach (MatrixHeaderItem columnItem in columnTerminalItems) { Matrix.ColumnValues = columnItem.Values; for (int cellIndex = 0; cellIndex < dataCount; cellIndex++) { TableCell templateCell = null; TableCellData resultCell = null; MatrixCellDescriptor descr = Matrix.Data.Cells[cellIndex]; if (Matrix.CellsSideBySide) { if (columnItem.TemplateColumn != null && rowItem.TemplateRow != null && descr.TemplateColumn != null) { templateCell = Matrix[ columnItem.TemplateColumn.Index + (descr.TemplateColumn.Index - bodyLocation.X), rowItem.TemplateRow.Index]; } else { templateCell = CreateDataCell(); } resultCell = ResultTable.GetCellData(left + cellIndex, top); } else { if (columnItem.TemplateColumn != null && rowItem.TemplateRow != null && descr.TemplateColumn != null) { templateCell = Matrix[columnItem.TemplateColumn.Index, rowItem.TemplateRow.Index + (descr.TemplateRow.Index - bodyLocation.Y)]; } else { templateCell = CreateDataCell(); } resultCell = ResultTable.GetCellData(left, top + cellIndex); } if (designTime) { if (firstTimePrintingData) { templateCell.Text = "[" + ExtractColumnName(descr.Expression) + "]"; } else { templateCell.Text = ""; } resultCell.RunTimeAssign(templateCell, true); } else { object value = Matrix.Data.GetValue(columnItem.Index, rowItem.Index, cellIndex); cellValues[cellIndex] = value; templateCell.Text = templateCell.FormatValue(value); templateCell.SaveState(); if (String.IsNullOrEmpty(templateCell.Hyperlink.Expression) && (templateCell.Hyperlink.Kind == HyperlinkKind.DetailReport || templateCell.Hyperlink.Kind == HyperlinkKind.DetailPage || templateCell.Hyperlink.Kind == HyperlinkKind.Custom)) { string hyperlinkValue = ""; string separator = templateCell.Hyperlink.ValuesSeparator; foreach (object obj in Matrix.ColumnValues) { hyperlinkValue += obj.ToString() + separator; } foreach (object obj in Matrix.RowValues) { hyperlinkValue += obj.ToString() + separator; } templateCell.Hyperlink.Value = hyperlinkValue.Substring(0, hyperlinkValue.Length - separator.Length); } int evenStyleIndex = Matrix.MatrixEvenStylePriority == MatrixEvenStylePriority.Rows ? Matrix.RowIndex : Matrix.ColumnIndex; if ((evenStyleIndex + 1) % 2 == 0) { templateCell.ApplyEvenStyle(); } templateCell.GetData(); resultCell.RunTimeAssign(templateCell, true); templateCell.RestoreState(); } } firstTimePrintingData = false; Matrix.ColumnIndex++; if (Matrix.CellsSideBySide) { if (Matrix.KeepCellsSideBySide) { ResultTable.Columns[left].KeepColumns = dataCount; } left += dataCount; } else { left++; } } Matrix.RowIndex++; if (Matrix.CellsSideBySide) { top++; } else { top += dataCount; } } }
private void PrintRowHeader(MatrixHeaderItem root, int left, int top, int level) { int dataHeight = 1; int width = HeaderWidth; if (Matrix.Data.Cells.Count > 1 && !Matrix.CellsSideBySide) { dataHeight = Matrix.Data.Cells.Count; width--; } for (int index = 0; index < root.Items.Count; index++) { MatrixHeaderItem item = root.Items[index]; Matrix.RowValues = item.Values; TableCellData resultCell = ResultTable.GetCellData(left, top); int span = item.Span * dataHeight; if (Matrix.SplitRows) { MatrixHeaderItem duplicate = new MatrixHeaderItem(root); duplicate.IsSplitted = true; duplicate.Value = item.Value; duplicate.TemplateRow = item.TemplateRow; duplicate.TemplateCell = item.TemplateCell; duplicate.TemplateColumn = item.TemplateColumn; for (int i = 1; i < span; i++) { root.Items.Insert(index + 1, duplicate); } span = 1; } resultCell.RowSpan = span; if (item.IsTotal) { resultCell.ColSpan = width - left; // correct FEvenStyleIndices for (int i = level + 1; i < evenStyleIndices.Length; i++) { evenStyleIndices[i]++; } } PrintHeaderCell(item, resultCell, evenStyleIndices[level] % 2 != 0); PrintRowHeader(item, left + resultCell.ColSpan, top, level + 1); if (item.PageBreak && top > HeaderHeight) { ResultTable.Rows[top].PageBreak = true; } top += span; evenStyleIndices[level]++; } // print cell header if (root.Items.Count == 0 && dataHeight > 1) { foreach (MatrixCellDescriptor descr in Matrix.Data.Cells) { TableCell templateCell = null; TableCellData resultCell = ResultTable.GetCellData(left, top); if (root.TemplateRow != null && descr.TemplateRow != null && cellHeaderDescriptor.TemplateColumn != null && cellHeaderDescriptor.TemplateRow != null) { templateCell = Matrix[cellHeaderDescriptor.TemplateColumn.Index, root.TemplateRow.Index + (descr.TemplateRow.Index - cellHeaderDescriptor.TemplateRow.Index)]; } else { templateCell = CreateCell(ExtractColumnName(descr.Expression)); } templateCell.SaveState(); templateCell.GetData(); resultCell.RunTimeAssign(templateCell, true); templateCell.RestoreState(); top++; } } }
private void PrintColumnHeader(MatrixHeaderItem root, int left, int top, int level) { int dataWidth = 1; int height = HeaderHeight; if (Matrix.Data.Cells.Count > 1 && Matrix.CellsSideBySide) { dataWidth = Matrix.Data.Cells.Count; height--; } foreach (MatrixHeaderItem item in root.Items) { Matrix.ColumnValues = item.Values; TableCellData resultCell = ResultTable.GetCellData(left, top); int span = item.Span * dataWidth; resultCell.ColSpan = span; if (item.IsTotal) { resultCell.RowSpan = height - top; // correct FEvenStyleIndices for (int i = level + 1; i < evenStyleIndices.Length; i++) { evenStyleIndices[i]++; } } PrintHeaderCell(item, resultCell, evenStyleIndices[level] % 2 != 0); PrintColumnHeader(item, left, top + resultCell.RowSpan, level + 1); if (item.PageBreak && left > HeaderWidth) { ResultTable.Columns[left].PageBreak = true; } left += span; evenStyleIndices[level]++; } // print cell header if (root.Items.Count == 0 && dataWidth > 1) { foreach (MatrixCellDescriptor descr in Matrix.Data.Cells) { TableCell templateCell = null; TableCellData resultCell = ResultTable.GetCellData(left, top); if (root.TemplateColumn != null && descr.TemplateColumn != null && cellHeaderDescriptor.TemplateColumn != null && cellHeaderDescriptor.TemplateRow != null) { templateCell = Matrix[ root.TemplateColumn.Index + (descr.TemplateColumn.Index - cellHeaderDescriptor.TemplateColumn.Index), cellHeaderDescriptor.TemplateRow.Index]; } else { templateCell = CreateCell(ExtractColumnName(descr.Expression)); } templateCell.SaveState(); templateCell.GetData(); resultCell.RunTimeAssign(templateCell, true); templateCell.RestoreState(); left++; } } }
private void PrintRowHeader(MatrixHeaderItem root, int left, int top) { int dataHeight = 1; int width = HeaderWidth; if (Matrix.Data.Cells.Count > 1 && !Matrix.CellsSideBySide) { dataHeight = Matrix.Data.Cells.Count; width--; } int index = 1; foreach (MatrixHeaderItem item in root.Items) { Matrix.RowValues = item.Values; TableCellData resultCell = ResultTable.GetCellData(left, top); int span = item.Span * dataHeight; resultCell.RowSpan = span; if (item.IsTotal) { resultCell.ColSpan = width - left; } PrintHeaderCell(item, resultCell, index % 2 == 0); PrintRowHeader(item, left + resultCell.ColSpan, top); if (item.PageBreak && top > HeaderHeight) { ResultTable.Rows[top].PageBreak = true; } top += span; index++; } // print cell header if (root.Items.Count == 0 && dataHeight > 1) { foreach (MatrixCellDescriptor descr in Matrix.Data.Cells) { TableCell templateCell = null; TableCellData resultCell = ResultTable.GetCellData(left, top); if (root.TemplateRow != null && descr.TemplateRow != null && FCellHeaderDescriptor.TemplateColumn != null && FCellHeaderDescriptor.TemplateRow != null) { templateCell = Matrix[FCellHeaderDescriptor.TemplateColumn.Index, root.TemplateRow.Index + (descr.TemplateRow.Index - FCellHeaderDescriptor.TemplateRow.Index)]; } else { templateCell = CreateCell(ExtractColumnName(descr.Expression)); } templateCell.SaveState(); templateCell.GetData(); resultCell.RunTimeAssign(templateCell, true); templateCell.RestoreState(); top++; } } }