예제 #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 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;
                }
            }
        }