示例#1
0
        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);
            }
        }
示例#2
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;
            }
        }
示例#3
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);
        }
示例#4
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);
            }
        }
示例#5
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);
            }
        }
示例#6
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++;
            }
        }
        private void ParseTableCellData(CablePresenter cable, TableCellData tableCellData, IEnumerable <InsulatedBillet> currentBilletsList,
                                        CablePropertySet?cableProps = null, char splitter = ' ')
        {
            if (decimal.TryParse(tableCellData.ColumnHeaderData, NumberStyles.Any, _cultureInfo, out decimal elementsCount) &&
                decimal.TryParse(tableCellData.RowHeaderData, NumberStyles.Any, _cultureInfo, out decimal conductorAreaInSqrMm))
            {
                decimal height = 0m;
                decimal width  = 0m;
                decimal?maxCoverDiameter;
                if (decimal.TryParse(tableCellData.CellData, NumberStyles.Any, _cultureInfo, out decimal diameterValue))
                {
                    maxCoverDiameter = diameterValue;
                }
                else
                {
                    var cableSizes = tableCellData.CellData.Split(splitter);
                    if (cableSizes.Length < 2)
                    {
                        return;
                    }
                    if (cableSizes.Length == 2 &&
                        decimal.TryParse(cableSizes[0], NumberStyles.Any, _cultureInfo, out height) &&
                        decimal.TryParse(cableSizes[1], NumberStyles.Any, _cultureInfo, out width))
                    {
                        maxCoverDiameter = null;
                    }
                    else
                    {
                        throw new Exception("Wrong format table cell data!");
                    }
                }
                var billet = (from b in currentBilletsList
                              where b.Conductor.AreaInSqrMm == conductorAreaInSqrMm
                              select b).First();
                cable.ElementsCount    = elementsCount;
                cable.MaxCoverDiameter = maxCoverDiameter;
                cable.Title            = _cableNameBuilder.GetCableTitle(cable, billet.Conductor.AreaInSqrMm, cableProps);

                var cablePresenterId = _cableTableProvider.AddItem(cable);

                _listCableBilletsPresenter.AddItem(new ListCableBilletsPresenter {
                    CableId = cablePresenterId, BilletId = billet.Id
                });

                var intProp = 0b_0000000001;

                for (int j = 0; j < cablePropertiesCount; j++)
                {
                    var Prop = (CablePropertySet)intProp;

                    if ((cableProps & Prop) == Prop)
                    {
                        var propertyObj = cablePropertiesList.Where(p => p.BitNumber == intProp).First();
                        _listCablePropertiesPresenter.AddItem(new ListCablePropertiesPresenter {
                            PropertyId = propertyObj.Id, CableId = cablePresenterId
                        });
                    }
                    intProp <<= 1;
                }

                if (!maxCoverDiameter.HasValue)
                {
                    _FlatCableSizePresenter.AddItem(new FlatCableSizePresenter {
                        CableId = cablePresenterId, Height = height, Width = width
                    });
                }
            }
            else
            {
                throw new Exception($"Не удалось распарсить ячейку таблицы!");
            }
        }
        public void Draw(SKCanvas canvas, int width, int height)
        {
            canvas.Clear(BackgroundColor);

            if (TableCellData.Count > 0 && TableCellData[0].Count > 0)
            {
                //Figure out how many rows to draw
                int number_of_table_rows = TableCellData.Count;
                if (DisplayHeaderRow)
                {
                    number_of_table_rows++;
                }

                //Figure out how many columns to draw
                int number_of_table_columns = TableCellData[0].Count;

                //Verify that all columns have the same count
                bool column_count_ok = TableCellData.All(x => x.Count == number_of_table_columns);
                if (column_count_ok && Margin >= 0)
                {
                    if (FitCellSizesToLargestText)
                    {
                        float largest_width  = GetLargestTextSize() * 1.25f;
                        float largest_height = Math.Max(TableColumnHeaderTextSize, TableCellContentTextSize) * 1.5f;
                        width  = Convert.ToInt32((largest_width * number_of_table_columns) + (2 * Margin));
                        height = Convert.ToInt32((largest_height * number_of_table_rows) + (2 * Margin));

                        CalculatedWidth  = width;
                        CalculatedHeight = height;
                    }

                    //Account for margins
                    float actual_display_width  = width - (2 * Margin);
                    float actual_display_height = height - (2 * Margin);
                    float actual_top_ypos       = Margin;
                    float actual_bottom_ypos    = height - Margin;
                    float actual_left_xpos      = Margin;
                    float actual_right_xpos     = width - Margin;

                    float column_width      = Convert.ToSingle(actual_display_width) / number_of_table_columns;
                    float row_height        = Convert.ToSingle(actual_display_height) / number_of_table_rows;
                    float half_column_width = column_width / 2.0f;
                    float half_row_height   = row_height / 2.0f;

                    var backgrounds = GetCellBackgroundColors();
                    var foregrounds = GetCellTextColors();

                    //Draw the cell backgrounds
                    for (int r = 0; r < number_of_table_rows; r++)
                    {
                        for (int c = 0; c < number_of_table_columns; c++)
                        {
                            if (backgrounds[r, c] != SKColor.Empty)
                            {
                                float cell_xpos = actual_left_xpos + (column_width * c);
                                float cell_ypos = actual_top_ypos + (row_height * r);

                                using (var paint = new SKPaint()
                                {
                                    Style = SKPaintStyle.StrokeAndFill,
                                    StrokeWidth = GridLinesStrokeWidth,
                                    Color = backgrounds[r, c],
                                    IsAntialias = true
                                })
                                {
                                    canvas.DrawRect(new SKRect(cell_xpos, cell_ypos, cell_xpos + column_width,
                                                               cell_ypos + row_height), paint);
                                }
                            }
                        }
                    }

                    //Draw the grid lines
                    if (GridLineSettings == GridLinesType.AllGridLines)
                    {
                        using (var paint = new SKPaint()
                        {
                            Style = SKPaintStyle.Stroke,
                            StrokeWidth = GridLinesStrokeWidth,
                            Color = GridLinesColor,
                            IsAntialias = true
                        })
                        {
                            //Start with drawing lines to separate columns
                            float xpos = actual_left_xpos;
                            for (int i = 0; i < (number_of_table_columns + 1); i++)
                            {
                                canvas.DrawLine(xpos, actual_top_ypos, xpos, actual_bottom_ypos, paint);
                                xpos += column_width;
                            }

                            //Now let's draw lines to separate the rows
                            float ypos = actual_top_ypos;
                            for (int i = 0; i < (number_of_table_rows + 1); i++)
                            {
                                canvas.DrawLine(actual_left_xpos, ypos, actual_right_xpos, ypos, paint);
                                ypos += row_height;
                            }
                        }
                    }

                    //Now draw the header text for each column
                    if (DisplayHeaderRow)
                    {
                        using (var paint = new SKPaint()
                        {
                            Color = TableColumnHeaderTextColor,
                            TextSize = TableColumnHeaderTextSize,
                            IsAntialias = true,
                            IsStroke = false
                        })
                        {
                            //Iterate over each column
                            float xpos          = actual_left_xpos;
                            float cell_x_center = 0;
                            float cell_y_center = actual_top_ypos + half_row_height;
                            for (int i = 0; i < TableColumnHeaders.Count; i++)
                            {
                                //Change the text color if necessary
                                if (foregrounds[0, i] != SKColors.Empty)
                                {
                                    paint.Color = foregrounds[0, i];
                                }

                                //Measure the text we are about to display
                                var bounds = new SKRect();
                                var text   = TableColumnHeaders[i];
                                if (!string.IsNullOrEmpty(text))
                                {
                                    paint.MeasureText(text, ref bounds);

                                    //Calculate the center of this cell
                                    cell_x_center = xpos + half_column_width;

                                    //Determine where to draw the text
                                    float text_x = cell_x_center - (bounds.Width / 2.0f);
                                    float text_y = cell_y_center + (bounds.Height / 2.0f);

                                    //Draw the text
                                    canvas.DrawText(text, text_x, text_y, paint);
                                }

                                //Increment the x value to go to the next column
                                xpos += column_width;

                                //Revert the text color back to the default setting
                                paint.Color = TableColumnHeaderTextColor;
                            }
                        }
                    }

                    //Now let's draw the actual table data
                    using (var paint = new SKPaint()
                    {
                        Color = TableCellContentTextColor,
                        TextSize = TableCellContentTextSize,
                        IsAntialias = true,
                        IsStroke = false
                    })
                    {
                        float xpos          = actual_left_xpos;
                        float ypos          = (DisplayHeaderRow) ? actual_top_ypos + row_height : actual_top_ypos;
                        float cell_x_center = 0;
                        float cell_y_center = 0;

                        for (int r = 0; r < TableCellData.Count; r++)
                        {
                            xpos          = actual_left_xpos;
                            cell_y_center = ypos + half_row_height;

                            for (int c = 0; c < number_of_table_columns; c++)
                            {
                                //Change the text color if necessary
                                var foregrounds_r = r;
                                if (DisplayHeaderRow)
                                {
                                    foregrounds_r++;
                                }
                                if (foregrounds[foregrounds_r, c] != SKColors.Empty)
                                {
                                    paint.Color = foregrounds[foregrounds_r, c];
                                }

                                //Measure the text we are about to display
                                var bounds = new SKRect();
                                var text   = TableCellData[r][c].ToString();
                                if (!string.IsNullOrEmpty(text))
                                {
                                    paint.MeasureText(text, ref bounds);

                                    //Calculate the center of this cell
                                    cell_x_center = xpos + half_column_width;

                                    //Determine where to draw the text
                                    float text_x = cell_x_center - (bounds.Width / 2.0f);
                                    float text_y = cell_y_center + (bounds.Height / 2.0f);

                                    //Draw the text
                                    canvas.DrawText(text, text_x, text_y, paint);
                                }

                                //Increment the x value to go to the next column
                                xpos += column_width;

                                //Revert the color back to the default
                                paint.Color = TableCellContentTextColor;
                            }

                            ypos += row_height;
                        }
                    }
                }
            }
        }
        public (int, int) GetGridCoordinatesFromCanvasCoordinates(int screen_x, int screen_y)
        {
            int row    = 0;
            int col    = 0;
            int width  = 0;
            int height = 0;

            if (TableCellData.Count > 0 && TableCellData[0].Count > 0)
            {
                //Figure out how many rows
                int number_of_table_rows = TableCellData.Count;
                if (DisplayHeaderRow)
                {
                    number_of_table_rows++;
                }

                //Figure out how many columns
                int number_of_table_columns = TableCellData[0].Count;

                //Verify that all columns have the same count
                bool column_count_ok = TableCellData.All(x => x.Count == number_of_table_columns);
                if (column_count_ok && Margin >= 0)
                {
                    if (FitCellSizesToLargestText)
                    {
                        float largest_width  = GetLargestTextSize() * 1.25f;
                        float largest_height = Math.Max(TableColumnHeaderTextSize, TableCellContentTextSize) * 1.5f;
                        width  = Convert.ToInt32((largest_width * number_of_table_columns) + (2 * Margin));
                        height = Convert.ToInt32((largest_height * number_of_table_rows) + (2 * Margin));

                        CalculatedWidth  = width;
                        CalculatedHeight = height;
                    }

                    //Account for margins
                    float actual_display_width  = width - (2 * Margin);
                    float actual_display_height = height - (2 * Margin);
                    float actual_top_ypos       = Margin;
                    float actual_bottom_ypos    = height - Margin;
                    float actual_left_xpos      = Margin;
                    float actual_right_xpos     = width - Margin;

                    float column_width      = Convert.ToSingle(actual_display_width) / number_of_table_columns;
                    float row_height        = Convert.ToSingle(actual_display_height) / number_of_table_rows;
                    float half_column_width = column_width / 2.0f;
                    float half_row_height   = row_height / 2.0f;

                    float transformed_x = screen_x;
                    float transformed_y = screen_y;

                    transformed_x -= actual_left_xpos;
                    transformed_y -= actual_top_ypos;
                    if (DisplayHeaderRow)
                    {
                        transformed_y -= row_height;
                    }

                    transformed_x /= column_width;
                    transformed_y /= row_height;
                    transformed_x  = Convert.ToSingle(Math.Floor(transformed_x));
                    transformed_y  = Convert.ToSingle(Math.Floor(transformed_y));
                    row            = Convert.ToInt32(transformed_y);
                    col            = Convert.ToInt32(transformed_x);
                }
            }

            return(row, col);
        }
示例#10
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;
                }
            }
        }
示例#11
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++;
                }
            }
        }
示例#12
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++;
                }
            }
        }
示例#13
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++;
                }
            }
        }