Exemplo n.º 1
0
        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;
        }
Exemplo n.º 2
0
        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);
                }
            }
        }
Exemplo n.º 3
0
        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);
                }
            }
        }
Exemplo n.º 4
0
        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();
        }
Exemplo n.º 5
0
        private List <TableCellData> GetAggregateCells(TableCell aggregateCell)
        {
            List <TableCellData> list = new List <TableCellData>();

            // columnIndex, rowIndex is a place where we will print a result.
            // To collect aggregate values that will be used to calculate a result, we need to go
            // to the left and top from this point and collect every cell which OriginalCell is equal to
            // the aggregateCell value. We have to stop when we meet the same row or column.

            int         columnIndex     = PrintingCell.Address.X;
            int         rowIndex        = PrintingCell.Address.Y;
            TableColumn startColumn     = ResultTable.Columns[columnIndex];
            TableRow    startRow        = ResultTable.Rows[rowIndex];
            TableColumn aggregateColumn = Columns[aggregateCell.Address.X];
            TableRow    aggregateRow    = Rows[aggregateCell.Address.Y];

            // check if result is in the same row/column as aggregate cell
            bool sameRow    = startRow.OriginalComponent == aggregateRow.OriginalComponent;
            bool sameColumn = startColumn.OriginalComponent == aggregateColumn.OriginalComponent;

            for (int y = rowIndex; y >= 0; y--)
            {
                if (y != rowIndex && ResultTable.Rows[y].OriginalComponent == startRow.OriginalComponent)
                {
                    break;
                }

                for (int x = columnIndex; x >= 0; x--)
                {
                    if (x != columnIndex && ResultTable.Columns[x].OriginalComponent == startColumn.OriginalComponent)
                    {
                        break;
                    }

                    TableCellData cell = ResultTable.GetCellData(x, y);
                    if (cell.OriginalCell == aggregateCell)
                    {
                        list.Add(cell);
                    }

                    if (sameColumn)
                    {
                        break;
                    }
                }

                if (sameRow)
                {
                    break;
                }
            }

            return(list);
        }
Exemplo n.º 6
0
        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;
            }
        }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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);
            }
        }
Exemplo n.º 9
0
        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);
            }
        }
Exemplo n.º 10
0
        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++;
            }
        }
Exemplo n.º 11
0
        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;
                }
            }
        }
Exemplo n.º 12
0
        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++;
                }
            }
        }
Exemplo n.º 13
0
        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++;
                }
            }
        }
Exemplo n.º 14
0
        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++;
                }
            }
        }