Exemplo n.º 1
0
        /// <summary>
        /// Exposes to the user a data editor, for the the supplied Detail Table, Designator and Custom-Look, and returns indication of change.
        /// </summary>
        public static bool Edit(Table DetailTable, TableDetailDesignator Designator, TableAppearance CustomLook = null, bool ForceSingleRecord = false)
        {
            if (DetailTable.Definition.FieldDefinitions.Count < 1)
            {
                if (Display.DialogMessage("Warning!", "No declared fields in the '" + DetailTable.Definition.Name + "' Table-Structure.\n\n" +
                                          "Do you want to declare them for " + (Designator.Owner.IsGlobal ? "all Ideas of type '" : "the Idea '") +
                                          ((IIdentifiableElement)Designator.Owner.Owner).Name + "' ?",
                                          EMessageType.Warning, MessageBoxButton.YesNo)
                    != MessageBoxResult.Yes)
                {
                    return(false);
                }

                var EditResult = DomainServices.EditDetailDesignator(Designator, Designator.Owner.IsGlobal, Designator.EditEngine);
                if (!EditResult.Item1.IsTrue())
                {
                    return(false);
                }
            }

            var WorkTable = DetailTable.CreateClone(ECloneOperationScope.Deep, null);
            var Editor    = new DetailTableEditor(WorkTable, Designator, CustomLook.NullDefault(new TableAppearance()), ForceSingleRecord);

            DialogOptionsWindow EditingWindow = null;   // Do not declare as static to allow multiple dialogs open!
            var Changed = Display.OpenContentDialogWindow <DetailTableEditor>(ref EditingWindow, "Edit data of table '" + WorkTable.Designation.Name + "'", Editor).IsTrue();

            if (Editor.ApplyChanges)
            {
                DetailTable.UpdateContentFrom(WorkTable);
            }

            return(Editor.ApplyChanges); //? || Changed);
        }
 // -----------------------------------------------------------------------------------------
 public void CreateDetailContent(Table Detail, TableAppearance Look)
 {
     if (Look.Layout == ETableLayoutStyle.Transposed)    // Mostly used by custom-fields
     {
         CreateDetailContentTableTransposed(Detail, Look);
     }
     else
     {
         CreateDetailContentTableConventional(Detail, Look);
     }
 }
Exemplo n.º 3
0
 // -----------------------------------------------------------------------------------------
 public void CreateDetailContent(ReportStandardPagesMaker PagesMaker, double LocalNestingMargin, string GroupKey,
                                 Table Detail, TableAppearance Look)
 {
     if (Look.Layout == ETableLayoutStyle.Transposed)    // Mostly used by custom-fields
     {
         CreateDetailContentTableTransposed(PagesMaker, LocalNestingMargin, GroupKey, Detail, Look);
     }
     else
     {
         CreateDetailContentTableConventional(PagesMaker, LocalNestingMargin, GroupKey, Detail, Look);
     }
 }
        // -----------------------------------------------------------------------------------------
        public void CreateDetailContentTableConventional(Table Detail, TableAppearance Look)
        {
            var TableColDefs = Detail.Definition.FieldDefinitions
                               .Select(def => Capsule.Create(def.TechName, def.NameCaption.ToHtmlEncoded(),
                                                             def.GetEstimatedColumnPixelsWidth(5)));

            var TotalWidth = TableColDefs.Sum(def => def.Value2);

            TableColDefs.ForEach(def => def.Value2 = ((def.Value2 * 100) / TotalWidth));

            var TableRowVals = Detail
                               .Select(rec => Detail.Definition.FieldDefinitions
                                       .Select(fd => (fd.FieldType.IsEqual(DataType.DataTypePicture)
                                                   ? GetStoredPictureAsHtmlImageRef(rec.GetStoredValue(fd) as ImageAssignment, Detail.OwnerIdea, rec)
                                                   : rec.GetStoredValueForDisplay(fd).ToHtmlEncoded())));

            this.PageWriteTable("tbl_dettbl_records", TableRowVals, TableColDefs.ToArray());
        }
        // -----------------------------------------------------------------------------------------
        public void CreateDetailContentTableTransposed(Table Detail, TableAppearance Look)
        {
            this.PageWrite("<table class='tbl_dettbl_records'>");
            this.IncreaseIndent();

            for (int RecIndex = 0; RecIndex <= Detail.Count; RecIndex++)
            {
                this.PageWrite("<col style='width: 150px;' />");
            }

            this.PageWrite("<tbody>");
            this.IncreaseIndent();

            foreach (var ColDef in Detail.Definition.FieldDefinitions)
            {
                this.PageWrite("<tr>");
                this.IncreaseIndent();

                this.PageWrite("<td>" + ColDef.NameCaption.ToHtmlEncoded() + "</td>");

                for (int ColIndex = 0; ColIndex < Detail.Count; ColIndex++)
                {
                    var Record = Detail[ColIndex];
                    var Value  = (ColDef.FieldType.IsEqual(DataType.DataTypePicture)
                                             ? GetStoredPictureAsHtmlImageRef(Record.GetStoredValue(ColDef) as ImageAssignment, Detail.OwnerIdea, Record)
                                             : Record.GetStoredValueForDisplay(ColDef).ToHtmlEncoded());
                    this.PageWrite("<td>" + Value + "</td>");
                }

                this.DecreaseIndent();
                this.PageWrite("</tr>");
            }

            this.DecreaseIndent();
            this.PageWrite("</tbody>");

            this.DecreaseIndent();
            this.PageWrite("</table>");
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
0
        // -----------------------------------------------------------------------------------------
        public void CreateDetailContentTableTransposed(ReportStandardPagesMaker PagesMaker, double LocalNestingMargin, string GroupKey,
                                                       Table Detail, TableAppearance Look)
        {
            var MaxColumns    = Math.Min(Detail.Count + 1, MAX_TRANSPOSED_COLUMNS);
            var SegmentsCount = (int)Math.Ceiling((double)Detail.Count / (double)(MaxColumns - 1));
            var SegmentKey    = GroupKey;
            var FieldIndex    = 0;
            var SegmentIndex  = 0;
            var ColumnIndex   = 0;
            var RecordIndex   = 0;
            var RecordStart   = 0;
            var ColumnWidth   = ((this.WorkingPageContentWidth - LocalNestingMargin) / (double)MaxColumns);

            while (SegmentIndex < SegmentsCount)
            {
                if (SegmentIndex > 0)
                {
                    var Filler = new Border();
                    Filler.Height = INTER_SEGMENTS_FILLING;
                    PagesMaker.AppendContent(Filler);
                }

                while (FieldIndex < Detail.Definition.FieldDefinitions.Count)
                {
                    var RowPanel = new StackPanel();
                    RowPanel.Orientation = Orientation.Horizontal;

                    var FieldDef  = Detail.Definition.FieldDefinitions[FieldIndex];
                    var LabelCell = CreateListCell(FieldDef.NameCaption, ColumnWidth,
                                                   HorizontalAlignment.Left, VerticalAlignment.Stretch,
                                                   this.Configuration.FmtFieldLabelBackground, this.Configuration.FmtListRowLinesForeground,
                                                   this.Configuration.FmtDetailFieldLabel, LINES_LISTROW_THICKNESS);
                    RowPanel.Children.Add(LabelCell);

                    RecordIndex = RecordStart;

                    var ColumnsLimit = Math.Min(Detail.Count, MaxColumns - 1);
                    while (ColumnIndex < ColumnsLimit && RecordIndex < Detail.Count)
                    {
                        var Value = (FieldDef.FieldType.IsEqual(DataType.DataTypePicture)
                                     ? (object)(Detail[RecordIndex].GetStoredValue(FieldDef) as ImageAssignment).Get(ias => ias.Image)
                                     : Detail[RecordIndex].GetStoredValueForDisplay(FieldDef));

                        // NOTE: As when drawing transposed records on symbols, it is better to let the values as left-aligned.
                        var ValueCell = CreateListCell(Value, ColumnWidth,
                                                       HorizontalAlignment.Left, VerticalAlignment.Stretch,
                                                       this.Configuration.FmtFieldValueBackground, this.Configuration.FmtListRowLinesForeground,
                                                       this.Configuration.FmtDetailFieldLabel, LINES_LISTROW_THICKNESS);
                        RowPanel.Children.Add(ValueCell);

                        RecordIndex++;
                        ColumnIndex++;
                    }

                    PagesMaker.AppendContent(RowPanel, false, SegmentKey);
                    SegmentKey = GroupKey + "_" + SegmentIndex.ToString();

                    ColumnIndex = 0;
                    FieldIndex++;
                }

                RecordStart += (MaxColumns - 1);
                FieldIndex   = 0;
                SegmentIndex++;
            }
        }
Exemplo n.º 8
0
        public DetailTableEditor(Table SourceTable, TableDetailDesignator SourceDesignator, TableAppearance SourceCustomLook, bool ForceSingleRecord = false)
            : this()
        {
            this.SourceTable      = SourceTable;
            this.SourceDesignator = SourceDesignator;
            this.SourceCustomLook = SourceCustomLook;

            // Operations: Append-Record and Reset-Records...
            Tuple <Action <TableRecord>, Action> RecordOperations = null;

            if (this.SourceCustomLook.IsMultiRecord && !ForceSingleRecord)
            {
                RecordOperations = SetMultiRecordEditor();
            }
            else
            {
                RecordOperations = SetSingleRecordEditor();
            }

            var ImportWidget = DomainServices.CreateTransferWidget(SourceDesignator, SourceTable.OwnerIdea, false, false,
                                                                   (compatdef, datarecords, append) =>
            {
                if (compatdef == null)
                {
                    Display.DialogMessage("Attention", "Cannot load data with incomptaible table-structure.",
                                          EMessageType.Warning);
                    return;
                }

                if (!append)
                {
                    RecordOperations.Item2();           // Reset-Records
                }
                foreach (var datarecord in datarecords)
                {
                    RecordOperations.Item1(new TableRecord(SourceTable, datarecord));           // Append-Record
                }
            },
                                                                   this.SourceTable);

            ImportWidget.MaxWidth            = 300;
            ImportWidget.HorizontalAlignment = HorizontalAlignment.Left;
            DockPanel.SetDock(ImportWidget, Dock.Left);
            this.BottomPanel.Children.Add(ImportWidget);
        }