Пример #1
0
        // -----------------------------------------------------------------------------------------
        public void CreateDetailContentTableConventional(ReportStandardPagesMaker PagesMaker, double LocalNestingMargin, string GroupKey,
                                                         Table Detail, TableAppearance Look)
        {
            var AvailableWidth = this.WorkingPageContentWidth - LocalNestingMargin;

            // Determine total column/field-def header rows and their widths needed per row.
            var MultiLineRows    = new List <List <Capsule <FieldDefinition, double> > >();
            var NewMultiLineCols = new List <Capsule <FieldDefinition, double> >();

            MultiLineRows.Add(NewMultiLineCols);
            var ConsumedWidth     = 0.0;
            var WidthAdjustFactor = 1.0;

            foreach (var FieldDef in Detail.Definition.FieldDefinitions)
            {
                var ColumnWidth = FieldDef.GetEstimatedColumnPixelsWidth(5);
                ConsumedWidth += ColumnWidth;

                if (ConsumedWidth > AvailableWidth)
                {
                    WidthAdjustFactor = AvailableWidth / (ConsumedWidth - ColumnWidth);
                    foreach (var RowCols in NewMultiLineCols)
                    {
                        RowCols.Value1 = RowCols.Value1 * WidthAdjustFactor;
                    }

                    NewMultiLineCols = new List <Capsule <FieldDefinition, double> >();
                    MultiLineRows.Add(NewMultiLineCols);
                    ConsumedWidth = ColumnWidth;
                }

                NewMultiLineCols.Add(Capsule.Create(FieldDef, ColumnWidth));
            }

            WidthAdjustFactor = AvailableWidth / ConsumedWidth;
            foreach (var RowCols in NewMultiLineCols)
            {
                RowCols.Value1 = RowCols.Value1 * WidthAdjustFactor;
            }

            // Create list-header panel creator (to be re-used on each page-break)
            Func <FrameworkElement> ListHeaderCreator =
                (() =>
            {
                var HeaderPanel = new StackPanel();

                foreach (var RowCols in MultiLineRows)
                {
                    var RowPanel = new StackPanel();
                    RowPanel.Orientation = Orientation.Horizontal;

                    foreach (var FieldColumn in RowCols)
                    {
                        var LabelCell = CreateListCell(FieldColumn.Value0.NameCaption, FieldColumn.Value1,
                                                       HorizontalAlignment.Left, VerticalAlignment.Stretch,
                                                       this.Configuration.FmtFieldLabelBackground, this.Configuration.FmtListRowLinesForeground,
                                                       this.Configuration.FmtDetailFieldLabel, LINES_LISTROW_THICKNESS);

                        RowPanel.Children.Add(LabelCell);
                    }

                    HeaderPanel.Children.Add(RowPanel);
                }

                return(HeaderPanel);
            });

            PagesMaker.PageBreakStartCreator = ListHeaderCreator;

            // Start creating the main header
            var MainHeaderPanel = ListHeaderCreator();

            PagesMaker.AppendContent(MainHeaderPanel, false, GroupKey);

            // Generate list-rows
            foreach (var Record in Detail)
            {
                var RecordRowsPanel = new StackPanel();

                if (MultiLineRows.Count > 1)
                {
                    var LineSeparator = new Border {
                        Height = 0.5, Background = Brushes.DimGray
                    };
                    RecordRowsPanel.Children.Add(LineSeparator);
                }

                foreach (var RowCols in MultiLineRows)
                {
                    var RowPanel = new StackPanel();
                    RowPanel.Orientation = Orientation.Horizontal;

                    foreach (var FieldColumn in RowCols)
                    {
                        var Alignment = (FieldColumn.Value0.FieldType is BasicDataType
                                         ? ((BasicDataType)FieldColumn.Value0.FieldType).DisplayAlignment
                                         : TextAlignment.Left).ToHorizontalAlignment();

                        var Value = (FieldColumn.Value0.FieldType.IsEqual(DataType.DataTypePicture)
                                     ? (object)(Record.GetStoredValue(FieldColumn.Value0) as ImageAssignment).Get(ias => ias.Image)
                                     : Record.GetStoredValueForDisplay(FieldColumn.Value0));

                        var ValueCell = CreateListCell(Value, FieldColumn.Value1,
                                                       Alignment, VerticalAlignment.Stretch,
                                                       this.Configuration.FmtFieldValueBackground, this.Configuration.FmtListRowLinesForeground,
                                                       this.Configuration.FmtDetailFieldLabel, LINES_LISTROW_THICKNESS);

                        RowPanel.Children.Add(ValueCell);
                    }

                    RecordRowsPanel.Children.Add(RowPanel);
                }

                PagesMaker.AppendContent(RecordRowsPanel, false, GroupKey);

                /*? Separation by little filler
                 * if (MultiLineRows.Count > 1)
                 * {
                 *  var Filler = new Border();
                 *  Filler.Height = INTER_SEGMENTS_FILLING / 4.0;
                 *  PagesMaker.AppendContent(Filler);
                 * } */
            }

            // Reset page-break header creator
            PagesMaker.PageBreakStartCreator = null;
        }