// ----------------------------------------------------------------------------------------- public void CreateDetailSubsection(ReportStandardPagesMaker PagesMaker, double LocalNestingMargin, ContainedDetail Detail) { var Result = new StackPanel(); var TitleBorder = new Border(); TitleBorder.Margin = new Thickness(0, 0, 0, 0); TitleBorder.BorderBrush = this.Configuration.FmtCardLinesForeground; TitleBorder.BorderThickness = new Thickness(LINES_CARD_THICKNESS); TitleBorder.VerticalAlignment = VerticalAlignment.Stretch; var Title = (Detail is Link ? Link.__ClassDefinitor.Name : Detail.Kind.Name) + ": " + Detail.Designation.NameCaption + (Detail is Table ? " [Structure: " + Detail.Designation.Definitor.Name.RemoveNewLines() + "]" : ""); TitleBorder.Child = CreateText(Title, this.Configuration.FmtCardFieldLabel, HorizontalAlignment.Stretch, VerticalAlignment.Top, this.Configuration.FmtFieldLabelBackground); var GroupKey = "Detail_" + (new Random()).Next().ToString(); PagesMaker.AppendContent(TitleBorder, false, GroupKey); FrameworkElement Content = null; var Representator = Detail.OwnerIdea.VisualRepresentators.FirstOrDefault(); var Look = (Representator != null ? Detail.OwnerIdea.GetDetailLook(Detail.Designation, Representator.MainSymbol) : null); if (Detail is Link && this.Configuration.CompositeIdea_DetailsIncludeLinksTarget && !((Link)Detail).Target.ToStringAlways().IsAbsent()) { Content = CreateDetailContent((Link)Detail); } else if (Detail is Attachment && this.Configuration.CompositeIdea_DetailsIncludeAttachmentsContent && ((Attachment)Detail).Content.NullDefault(new byte[0]).Length > 0) { Content = CreateDetailContent((Attachment)Detail); } else if (Detail is Table && ((Table)Detail).Count > 0 && this.Configuration.CompositeIdea_DetailsIncludeTablesData) { // Notice that no Content is returned (records appended to pages-maker inside) CreateDetailContent(PagesMaker, LocalNestingMargin, GroupKey, (Table)Detail, (TableAppearance)Look); } if (Content != null) { var Container = new Border(); Container.BorderThickness = new Thickness(LINES_CARD_THICKNESS); Container.BorderBrush = this.Configuration.FmtCardLinesForeground; Container.Child = Content; PagesMaker.AppendContent(Container, false, GroupKey); } }
// ----------------------------------------------------------------------------------------- public void CreateCollectionOfComplements(ReportStandardPagesMaker PagesMaker, string GroupKey, IEnumerable <VisualComplement> Source) { // Create initial Header var ColumnHeaderDefs = new Dictionary <string, Capsule <string, double, Func <IMModelClass, object> > >(); ColumnHeaderDefs.Add(VisualComplement.__Kind.TechName, Capsule.Create(VisualComplement.__Kind.Name, 0.2, (Func <IMModelClass, object>)null)); ColumnHeaderDefs.Add(VisualComplement.__Content.TechName, Capsule.Create(VisualComplement.__Content.Name, 0.8, (Func <IMModelClass, object>)null)); var Header = CreateListHeader(PagesMaker, ColumnHeaderDefs, this.Configuration.FmtListFieldLabel, this.Configuration.FmtFieldLabelBackground); PagesMaker.PageBreakStartCreator = (() => CreateListHeader(PagesMaker, ColumnHeaderDefs, this.Configuration.FmtListFieldLabel, this.Configuration.FmtFieldLabelBackground, this.Configuration.FmtListLinesForeground).Item1); PagesMaker.AppendContent(Header.Item1, false, GroupKey); var ColumnValueDefs = Header.Item2; var VerticalAlign = VerticalAlignment.Stretch; var HorizontalAlign = HorizontalAlignment.Stretch; // Travel Records... Source.ForEachIndexing((record, index) => { int ColIndex = 0; FrameworkElement Cell = null; var RecordFrame = new StackPanel(); // Grid is too expensive for each record RecordFrame.Orientation = Orientation.Horizontal; Cell = CreateListCell(record.Kind.Name, ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); ColIndex++; Cell = CreateListCell(record.ContentAsText, ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); PagesMaker.AppendContent(RecordFrame, false, (index > 0 ? null : GroupKey)); }); PagesMaker.PageBreakStartCreator = null; }
// ----------------------------------------------------------------------------------------- public IEnumerable <FixedPage> CreateDomainContent(ReportStandardPagesMaker PagesMaker, Domain Source) { var Result = new List <FixedPage>(); PagesMaker.AppendPageBreak(); PagesMaker.NestingMargin = 0; PagesMaker.AppendContent(CreateText("Domain: " + Source.NameCaption, this.Configuration.FmtSubjectTitle), true, "Domain"); if (this.Configuration.Domain_Concept_Defs_List.Show) { PagesMaker.AppendContent(CreateText("Concept Definitions", this.Configuration.FmtSectionTitle), true, "ConceptDefs"); this.CreateContentList(PagesMaker, "ConceptDefs", Source.ConceptDefinitions, this.Configuration.Domain_Concept_Defs_List, null, null, new Tuple <string, string, double, Func <IMModelClass, object> >("Cluster", "Cluster", 0.15, ins => Source.ConceptDefClusters.FirstOrDefault(clu => clu == ((IdeaDefinition)ins).Cluster) .Get(clu => clu.NameCaption, ""))); } if (this.Configuration.Domain_Relationship_Defs_List.Show) { PagesMaker.AppendContent(CreateText("Relationship Definitions", this.Configuration.FmtSectionTitle), true, "RelationshipDefs"); this.CreateContentList(PagesMaker, "RelationshipDefs", Source.RelationshipDefinitions, this.Configuration.Domain_Relationship_Defs_List, null, null, new Tuple <string, string, double, Func <IMModelClass, object> >("Cluster", "Cluster", 0.15, ins => Source.RelationshipDefClusters.FirstOrDefault(clu => clu == ((IdeaDefinition)ins).Cluster) .Get(clu => clu.NameCaption, ""))); } if (this.Configuration.Domain_Marker_Defs_List.Show) { PagesMaker.AppendContent(CreateText("Marker Definitions", this.Configuration.FmtSectionTitle), true, "MarkerDefs"); this.CreateContentList(PagesMaker, "MarkerDefs", Source.MarkerDefinitions, this.Configuration.Domain_Marker_Defs_List, null, null); } return(Result); }
// ----------------------------------------------------------------------------------------- public void CreateCompositeContent(ReportStandardPagesMaker PagesMaker, Idea Source, double LocalNestingMargin, double ProgressPercentageStart, double ProgressPercentageEnd) { this.CurrentWorker.ReportProgress((int)ProgressPercentageStart, "Generating " + Source.ToStringAlways()); PagesMaker.NestingMargin = LocalNestingMargin; var IdeaGroupKeySuffix = Source.GlobalId.ToString(); var Text = CreateText(Source.Definitor.NameCaption /* Source.SelfKind.Name */ + ": " + Source.NameCaption, this.Configuration.FmtSubjectTitle); PagesMaker.AppendContent(Text, true, "Idea" + IdeaGroupKeySuffix); // Main Info var Card = (Source is Composition ? this.Configuration.Composition_Card : (Source is Concept ? this.Configuration.CompositeIdea_Concepts_Card : this.Configuration.CompositeIdea_Relationships_Card)); if (Card.Show) { var CompositionCardSections = this.CreateContentCard(Source, Card); CompositionCardSections.ForEachIndexing( (section, index) => PagesMaker.AppendContent( section, false, (index > 0 ? null : "Idea" + IdeaGroupKeySuffix))); } // View if (this.Configuration.CompositeIdea_View_Diagram && Source.CompositeActiveView != null) { var ViewSnapshot = this.CurrentWorker.AtOriginalThreadInvoke( () => { var Snapshot = Source.CompositeActiveView.ToSnapshot(); if (Snapshot == null || Snapshot.Item1 == null) { return(null); } Snapshot.Item1.Freeze(); return(Snapshot.Item1); }); if (ViewSnapshot != null) { Text = CreateText(View.__ClassDefinitor.Name + ": " + Source.CompositeActiveView, this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true, "View" + IdeaGroupKeySuffix); var ViewImage = ViewSnapshot.ToDrawingImage(); var ViewContent = this.CreateContentView(ViewImage, this.WorkingPageContentWidth, this.WorkingPageContentHeight * 0.95); PagesMaker.AppendContent(ViewContent, false, "View" + IdeaGroupKeySuffix, true); } } // Details... var Details = Source.Details.Where(det => !(det is InternalLink)).OrderBy(det => det.Designation.Name); if (this.Configuration.CompositeIdea_Details && Details.Any()) { Text = CreateText("Details", this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true, "Details" + IdeaGroupKeySuffix); this.CreateIdeaDetails(PagesMaker, LocalNestingMargin, Details); } // Markers... if (this.Configuration.CompositeIdea_Markers_List.Show && Source.Markings.Count > 0) { Text = CreateText("Markers", this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true, "Markers" + IdeaGroupKeySuffix); this.CreateListOfMarkers(PagesMaker, "Markers" + IdeaGroupKeySuffix, Source.Markings.OrderBy(reg => (reg.Descriptor == null ? "~" : reg.Descriptor.Name))); } // Related from... if (this.Configuration.CompositeIdea_RelatedFrom_Collection) { var OriginCounterpartLinks = Source.AssociatingLinks.Where(lnk => lnk.RoleDefinitor.RoleType == ERoleType.Target) .SelectMany(lnk => lnk.OwnerRelationship.Links.Where(rlk => rlk.RoleDefinitor.RoleType == ERoleType.Origin) .Select(rlk => Tuple.Create(lnk, rlk))); var TargetCompanionLinks = Source.AssociatingLinks.Where(lnk => lnk.RoleDefinitor.RoleType == ERoleType.Target) .SelectMany(lnk => lnk.OwnerRelationship.Links.Where(rlk => rlk.RoleDefinitor.RoleType == ERoleType.Target && !rlk.AssociatedIdea.IsEqual(Source))); if (OriginCounterpartLinks.Any() || TargetCompanionLinks.Any()) { Text = CreateText("Related From...", this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true, "RelatedFrom" + IdeaGroupKeySuffix); } if (OriginCounterpartLinks.Any()) { this.CreateCollectionOfIdeaCounterpartLinks(PagesMaker, ERoleType.Origin.GetFieldName(), ERoleType.Target.GetFieldName(), OriginCounterpartLinks, "RelatedFrom" + IdeaGroupKeySuffix); } if (this.Configuration.CompositeIdea_IncludeTargetCompanions && TargetCompanionLinks.Any()) { this.CreateCollectionOfIdeaCompanionLinks(PagesMaker, TargetCompanionLinks, "TargetCompanions" + IdeaGroupKeySuffix); } } // Related to... if (this.Configuration.CompositeIdea_RelatedTo_Collection) { var TargetCounterpartLinks = Source.AssociatingLinks.Where(lnk => lnk.RoleDefinitor.RoleType == ERoleType.Origin) .SelectMany(lnk => lnk.OwnerRelationship.Links.Where(rlk => rlk.RoleDefinitor.RoleType == ERoleType.Target) .Select(rlk => Tuple.Create(lnk, rlk))); var OriginCompanionLinks = Source.AssociatingLinks.Where(lnk => lnk.RoleDefinitor.RoleType == ERoleType.Origin) .SelectMany(lnk => lnk.OwnerRelationship.Links.Where(rlk => rlk.RoleDefinitor.RoleType == ERoleType.Origin && !rlk.AssociatedIdea.IsEqual(Source))); if (TargetCounterpartLinks.Any() || OriginCompanionLinks.Any()) { Text = CreateText("Related To...", this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true, "RelatedTo" + IdeaGroupKeySuffix); } if (TargetCounterpartLinks.Any()) { this.CreateCollectionOfIdeaCounterpartLinks(PagesMaker, ERoleType.Target.GetFieldName(), ERoleType.Origin.GetFieldName(), TargetCounterpartLinks, "RelatedTo" + IdeaGroupKeySuffix); } if (this.Configuration.CompositeIdea_IncludeOriginCompanions && OriginCompanionLinks.Any()) { this.CreateCollectionOfIdeaCompanionLinks(PagesMaker, OriginCompanionLinks, "OriginCompanions" + IdeaGroupKeySuffix); } } // Grouped Ideas... if (this.Configuration.CompositeIdea_GroupedIdeas_List.Show) { var GroupedIdeas = Source.VisualRepresentators .SelectMany(vrep => vrep.MainSymbol.GetGroupedSymbols() .Select(rep => rep.OwnerRepresentation.RepresentedIdea)) .Distinct().OrderBy(idea => idea.Name); if (GroupedIdeas.Any()) { Text = CreateText("Grouped Ideas", this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true, "GroupedIdeas" + IdeaGroupKeySuffix); this.CreateContentList(PagesMaker, "GroupedIdeas" + IdeaGroupKeySuffix, GroupedIdeas, this.Configuration.CompositeIdea_GroupedIdeas_List, "Definition", "Definition"); } } // Complements collection... if (this.Configuration.CompositeIdea_Complements) { // Consider symbol's appended floaters: call-outs and quotes var Complements = Source.VisualRepresentators .SelectMany(vrep => vrep.MainSymbol.AttachedComplements.Where(atc => atc.IsAttachedFloater)); // Consider composite view's free complements (notes, texts, stamps) if (Source.CompositeViews.Count > 0) { Complements = Complements.Concat(Source.CompositeViews .SelectMany(cvw => cvw.GetFreeComplements().Where(frc => frc.IsComplementNote || frc.IsComplementStamp || frc.IsComplementText))); } if (Complements.Any()) { Text = CreateText("Complements", this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true, "IdeaComplements" + IdeaGroupKeySuffix); this.CreateCollectionOfComplements(PagesMaker, "IdeaComplements" + IdeaGroupKeySuffix, Complements); } } // Relationship Links (only when this Idea is a Relationship) var SourceRelationship = Source as Relationship; if (SourceRelationship != null && SourceRelationship.Links.Count > 0 && this.Configuration.CompositeRelationship_Links_Collection) { Text = CreateText("Links", this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true, "RelLinks" + IdeaGroupKeySuffix); this.CreateCollectionOfRelationshipLinks(PagesMaker, SourceRelationship.Links, "RelLinks" + IdeaGroupKeySuffix); } // Composing Concepts List var Concepts = Source.CompositeConcepts.OrderBy(idea => idea.Name).ToList(); if (this.Configuration.CompositeIdea_Concepts_List.Show && Concepts.Any()) { Text = CreateText("List of composing Concepts", this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true, "Concepts" + IdeaGroupKeySuffix); this.CreateContentList(PagesMaker, "Concepts" + IdeaGroupKeySuffix, Concepts, this.Configuration.CompositeIdea_Concepts_List, Concept.__ConceptDefinitor.TechName, Concept.__ConceptDefinitor.Name); } // Composing Relationships List var Relationships = Source.CompositeRelationships.OrderBy(idea => idea.Name).ToList(); if (this.Configuration.CompositeIdea_Relationships_List.Show && Relationships.Any()) { Text = CreateText("List of composing Relationships", this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true, "Relationships" + IdeaGroupKeySuffix); this.CreateContentList(PagesMaker, "Relationships" + IdeaGroupKeySuffix, Relationships, this.Configuration.CompositeIdea_Relationships_List, Relationship.__RelationshipDefinitor.TechName, Relationship.__RelationshipDefinitor.Name); } // Determine progress var ProgressStep = ((ProgressPercentageEnd - ProgressPercentageStart) / (double)(Concepts.Count + Relationships.Count)); var ProgressPercentage = ProgressPercentageStart; // Composing Concepts Contents if (this.Configuration.CompositeIdea_Concepts_ReportCompositeContent && Concepts.Any()) { Text = CreateText("Content of the composing Concepts", this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true); foreach (var Composite in Concepts) { ProgressPercentage += ProgressStep; CreateCompositeContent(PagesMaker, Composite, (LocalNestingMargin + COMPOSITE_NESTING_MARGIN).EnforceMaximum(COMPOSITE_NESTING_MARGIN * MAX_NESTED_LEVELS), ProgressPercentage, (ProgressPercentage + ProgressStep)); } } PagesMaker.NestingMargin = LocalNestingMargin; // Reset to current-level nesting // Composing Relationships Contents if (this.Configuration.CompositeIdea_Relationships_ReportCompositeContent && Relationships.Any()) { Text = CreateText("Content of the composing Relationships", this.Configuration.FmtSectionTitle); PagesMaker.AppendContent(Text, true); { ProgressPercentage += ProgressStep; foreach (var Composite in Relationships) { CreateCompositeContent(PagesMaker, Composite, (LocalNestingMargin + COMPOSITE_NESTING_MARGIN).EnforceMaximum(COMPOSITE_NESTING_MARGIN * MAX_NESTED_LEVELS), ProgressPercentage, (ProgressPercentage + ProgressStep)); } } } PagesMaker.NestingMargin = LocalNestingMargin; // Reset to current-level nesting }
public void CreateListOfModelObjects(ReportStandardPagesMaker PagesMaker, string GroupKey, IEnumerable <IMModelClass> Source, Dictionary <string, Capsule <string, double, Func <IMModelClass, object> > > ColumnHeaderDefs) { // Create initial Header var Header = CreateListHeader(PagesMaker, ColumnHeaderDefs, this.Configuration.FmtListFieldLabel, this.Configuration.FmtFieldLabelBackground, this.Configuration.FmtListLinesForeground); PagesMaker.PageBreakStartCreator = (() => CreateListHeader(PagesMaker, ColumnHeaderDefs, this.Configuration.FmtListFieldLabel, this.Configuration.FmtFieldLabelBackground, this.Configuration.FmtListLinesForeground).Item1); PagesMaker.AppendContent(Header.Item1, false, GroupKey); var ColumnValueDefs = Header.Item2; var VerticalAlign = VerticalAlignment.Stretch; var HorizontalAlign = HorizontalAlignment.Stretch; // Travel Records... Source.ForEachIndexing((record, index) => { var RecordFrame = new StackPanel(); // Grid is too expensive for each record RecordFrame.Orientation = Orientation.Horizontal; // Travel Colum-Defs... foreach (var ColValueDef in ColumnValueDefs) { var ColDef = record.ClassDefinition.GetPropertyDef(ColValueDef.Key, false); var MaxValueWidth = double.PositiveInfinity; var MaxValueHeight = double.PositiveInfinity; object Value = null; if (ColDef != null && record is IRecognizableElement && ColDef.TechName == FormalPresentationElement.__Pictogram.TechName) // Used as "Formal..." but could be a "Simple..." { Value = this.CurrentWorker.AtOriginalThreadInvoke( () => { var Picture = ((IRecognizableElement)record).Pictogram; if (Picture == null) { if (record is IdeaDefinition) { Picture = ((IdeaDefinition)record).Pictogram; } else if (record is Idea && ((Idea)record).IdeaDefinitor.DefaultSymbolFormat.UseDefinitorPictogramAsNullDefault) { Picture = ((Idea)record).IdeaDefinitor.Pictogram; } } if (Picture != null && !Picture.IsFrozen) { Picture.Freeze(); } MaxValueWidth = ReportConfiguration.PICTOGRAM_MAX_WIDTH; MaxValueHeight = ReportConfiguration.PICTOGRAM_MAX_HEIGHT; return(Picture); }); } else { Value = (ColValueDef.Value.Value1 != null ? ColValueDef.Value.Value1(record) : (ColDef == null ? null : ColDef.Read(record))); } var Cell = CreateListCell(Value, ColValueDef.Value.Value0, HorizontalAlign, VerticalAlign, null, null, null, LINES_LIST_THICKNESS, MaxValueWidth, MaxValueHeight); RecordFrame.Children.Add(Cell); } PagesMaker.AppendContent(RecordFrame, false, (index > 0 ? null : GroupKey)); }); PagesMaker.PageBreakStartCreator = null; }
public const int MAX_TRANSPOSED_COLUMNS = 7; // The first is for the field-name. // ----------------------------------------------------------------------------------------- public void CreateIdeaDetails(ReportStandardPagesMaker PagesMaker, double LocalNestingMargin, IEnumerable <ContainedDetail> Details) { var DetailIndex = 0; foreach (var Detail in Details) { /* var DetailPanel = new StackPanel(); * * var DetailHeader = new Grid(); * DetailHeader.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.1, GridUnitType.Star) }); * DetailHeader.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.15, GridUnitType.Star) }); * DetailHeader.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.15, GridUnitType.Star) }); * DetailHeader.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.4, GridUnitType.Star) }); * DetailHeader.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(0.2, GridUnitType.Star) }); * * var Expositor = CreateContentCardPropertyExpositor("Type", Detail.KindName, * this.Configuration.FmtCardFieldLabel, this.Configuration.FmtFieldLabelBackground, * this.Configuration.FmtCardFieldValue, this.Configuration.FmtFieldValueBackground); * DetailHeader.Children.Add(Expositor); * * Expositor = CreateContentCardPropertyExpositor(FormalPresentationElement.__Name.Name, Detail.Designation.Name, * this.Configuration.FmtCardFieldLabel, this.Configuration.FmtFieldLabelBackground, * this.Configuration.FmtCardFieldValue, this.Configuration.FmtFieldValueBackground); * Grid.SetColumn(Expositor, 1); * DetailHeader.Children.Add(Expositor); * * Expositor = CreateContentCardPropertyExpositor(FormalPresentationElement.__TechName.Name, Detail.Designation.TechName, * this.Configuration.FmtCardFieldLabel, this.Configuration.FmtFieldLabelBackground, * this.Configuration.FmtCardFieldValue, this.Configuration.FmtFieldValueBackground); * Grid.SetColumn(Expositor, 2); * DetailHeader.Children.Add(Expositor); * * Expositor = CreateContentCardPropertyExpositor(FormalPresentationElement.__Summary.Name, Detail.Designation.Summary, * this.Configuration.FmtCardFieldLabel, this.Configuration.FmtFieldLabelBackground, * this.Configuration.FmtCardFieldValue, this.Configuration.FmtFieldValueBackground); * Grid.SetColumn(Expositor, 3); * DetailHeader.Children.Add(Expositor); * * Expositor = CreateContentCardPropertyExpositor("Definition", Detail.Designation.Definitor.Name, * this.Configuration.FmtCardFieldLabel, this.Configuration.FmtFieldLabelBackground, * this.Configuration.FmtCardFieldValue, this.Configuration.FmtFieldValueBackground); * Grid.SetColumn(Expositor, 4); * DetailHeader.Children.Add(Expositor); * * DetailPanel.Children.Add(DetailHeader); * DetailPanel.Children.Add(CreateDetailBody(Detail)); * * PagesMaker.AppendContent(DetailPanel, true); */ if (DetailIndex > 0) { var Filler = new Border(); Filler.Height = INTER_DETAILS_FILLING; PagesMaker.AppendContent(Filler); } CreateDetailSubsection(PagesMaker, LocalNestingMargin, Detail); // Detail is directly generated into pages-maker. DetailIndex++; } }
// ----------------------------------------------------------------------------------------- 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; }
// ----------------------------------------------------------------------------------------- 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++; } }
// ----------------------------------------------------------------------------------------- public void CreateListOfMarkers(ReportStandardPagesMaker PagesMaker, string GroupKey, IEnumerable <MarkerAssignment> Source) { // Create initial Header var ColumnHeaderDefs = new Dictionary <string, Capsule <string, double, Func <IMModelClass, object> > >(); if (this.Configuration.CompositeIdea_Markers_List.Definitor) { ColumnHeaderDefs.Add(MarkerAssignment.__Definitor.TechName, Capsule.Create(MarkerAssignment.__Definitor.Name, 0.25, (Func <IMModelClass, object>)null)); } if (this.Configuration.CompositeIdea_Markers_List.PropPictogram) { ColumnHeaderDefs.Add(SimplePresentationElement.__Pictogram.TechName, Capsule.Create("Pict.", 0.05, (Func <IMModelClass, object>)null)); } if (this.Configuration.CompositeIdea_Markers_List.PropName) { ColumnHeaderDefs.Add(SimplePresentationElement.__Name.TechName, Capsule.Create(SimplePresentationElement.__Name.Name, 0.2, (Func <IMModelClass, object>)null)); } if (this.Configuration.CompositeIdea_Markers_List.PropTechName) { ColumnHeaderDefs.Add(SimplePresentationElement.__TechName.TechName, Capsule.Create(SimplePresentationElement.__TechName.Name, 0.2, (Func <IMModelClass, object>)null)); } if (this.Configuration.CompositeIdea_Markers_List.PropSummary) { ColumnHeaderDefs.Add(SimplePresentationElement.__Summary.TechName, Capsule.Create(SimplePresentationElement.__Summary.Name, 0.3, (Func <IMModelClass, object>)null)); } var Header = CreateListHeader(PagesMaker, ColumnHeaderDefs, this.Configuration.FmtListFieldLabel, this.Configuration.FmtFieldLabelBackground); PagesMaker.PageBreakStartCreator = (() => CreateListHeader(PagesMaker, ColumnHeaderDefs, this.Configuration.FmtListFieldLabel, this.Configuration.FmtFieldLabelBackground, this.Configuration.FmtListLinesForeground).Item1); PagesMaker.AppendContent(Header.Item1, false, GroupKey); var ColumnValueDefs = Header.Item2; var VerticalAlign = VerticalAlignment.Stretch; var HorizontalAlign = HorizontalAlignment.Stretch; // Travel Records... Source.ForEachIndexing((record, index) => { int ColIndex = 0; FrameworkElement Cell = null; var RecordFrame = new StackPanel(); // Grid is too expensive for each record RecordFrame.Orientation = Orientation.Horizontal; if (this.Configuration.CompositeIdea_Markers_List.Definitor) { Cell = CreateListCell(record.Definitor.Name, ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); } if (this.Configuration.CompositeIdea_Markers_List.PropPictogram) { ColIndex++; Cell = CreateListCell(record.Descriptor != null && record.Descriptor.Pictogram != null ? record.Descriptor.Pictogram : record.Definitor.Pictogram, ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); } if (this.Configuration.CompositeIdea_Markers_List.PropName) { ColIndex++; Cell = CreateListCell(record.Descriptor == null ? "" : record.Descriptor.Name.RemoveNewLines(), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); } if (this.Configuration.CompositeIdea_Markers_List.PropTechName) { ColIndex++; Cell = CreateListCell(record.Descriptor == null ? "" : record.Descriptor.TechName, ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); } if (this.Configuration.CompositeIdea_Markers_List.PropSummary) { ColIndex++; Cell = CreateListCell(record.Descriptor == null ? "" : record.Descriptor.Summary, ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); } PagesMaker.AppendContent(RecordFrame, false, (index > 0 ? null : GroupKey)); }); PagesMaker.PageBreakStartCreator = null; }
// ----------------------------------------------------------------------------------------- public void CreateCollectionOfRelationshipLinks(ReportStandardPagesMaker PagesMaker, IEnumerable <RoleBasedLink> Source, string GroupKey) { // Notice the order by self-info, later related-info Source = Source.OrderBy(lnk => lnk.RoleDefinitor.RoleType.ToString() + lnk.RoleDefinitor.Name + lnk.AssociatedIdea.Name); // Create initial Header var ColumnHeaderDefs = new Dictionary <string, Capsule <string, double, Func <IMModelClass, object> > >(); // Related Idea labels... ColumnHeaderDefs.Add("Idea", Capsule.Create("Idea", 0.3, (Func <IMModelClass, object>)null)); ColumnHeaderDefs.Add("RoleType", Capsule.Create("Type", 0.1, (Func <IMModelClass, object>)null)); ColumnHeaderDefs.Add("RoleDef", Capsule.Create("Role", 0.2, (Func <IMModelClass, object>)null)); ColumnHeaderDefs.Add("RoleVar", Capsule.Create("Variant", 0.1, (Func <IMModelClass, object>)null)); ColumnHeaderDefs.Add("RoleDesc", Capsule.Create("Descriptor", 0.3, (Func <IMModelClass, object>)null)); var Header = CreateListHeader(PagesMaker, ColumnHeaderDefs, this.Configuration.FmtListFieldLabel, this.Configuration.FmtFieldLabelBackground); PagesMaker.PageBreakStartCreator = (() => CreateListHeader(PagesMaker, ColumnHeaderDefs, this.Configuration.FmtListFieldLabel, this.Configuration.FmtFieldLabelBackground, this.Configuration.FmtListLinesForeground).Item1); PagesMaker.AppendContent(Header.Item1, false, GroupKey); var ColumnValueDefs = Header.Item2; var VerticalAlign = VerticalAlignment.Stretch; var HorizontalAlign = HorizontalAlignment.Stretch; // Travel Records... Source.ForEachIndexing((record, index) => { int ColIndex = 0; FrameworkElement Cell = null; var RecordFrame = new StackPanel(); // Grid is too expensive for each record RecordFrame.Orientation = Orientation.Horizontal; Cell = CreateListCell(record.AssociatedIdea.ToString(), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); ColIndex++; Cell = CreateListCell(record.RoleDefinitor.RoleType.GetFieldName(), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); ColIndex++; Cell = CreateListCell(record.RoleDefinitor.ToString(), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); ColIndex++; Cell = CreateListCell(record.RoleVariant.ToString(), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); ColIndex++; Cell = CreateListCell((record.Descriptor == null ? "" : record.Descriptor.ToString()), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, (record.Descriptor == null ? HorizontalAlignment.Center : HorizontalAlign), VerticalAlign); RecordFrame.Children.Add(Cell); PagesMaker.AppendContent(RecordFrame, false, (index > 0 ? null : GroupKey)); }); PagesMaker.PageBreakStartCreator = null; }
// ----------------------------------------------------------------------------------------- public void CreateCollectionOfIdeaCounterpartLinks(ReportStandardPagesMaker PagesMaker, string RelatedPrefix, string SelfPrefix, IEnumerable <Tuple <RoleBasedLink, RoleBasedLink> > Source, string GroupKey) { RelatedPrefix = RelatedPrefix + Environment.NewLine; SelfPrefix = SelfPrefix + Environment.NewLine; // Notice the order by self-info, later related-info Source = Source.OrderBy(tlk => tlk.Item1.OwnerRelationship.Name + "~" + tlk.Item2.AssociatedIdea.Name); // Create initial Header var ColumnHeaderDefs = new Dictionary <string, Capsule <string, double, Func <IMModelClass, object> > >(); // Related Idea labels... ColumnHeaderDefs.Add("Idea", Capsule.Create(RelatedPrefix + " Idea", 0.25, (Func <IMModelClass, object>)null)); ColumnHeaderDefs.Add("RemRoleDesc", Capsule.Create(RelatedPrefix + "Link Desc.", 0.1, (Func <IMModelClass, object>)null)); ColumnHeaderDefs.Add("RemRoleDef", Capsule.Create(RelatedPrefix + "Link Role", 0.075, (Func <IMModelClass, object>)null)); ColumnHeaderDefs.Add("RemRoleVar", Capsule.Create(RelatedPrefix + "Link Var.", 0.075, (Func <IMModelClass, object>)null)); // Relationship Idea label... ColumnHeaderDefs.Add("Relationship", Capsule.Create("By" + Environment.NewLine + "Relationship", 0.25, (Func <IMModelClass, object>)null)); // Self Idea labels... ColumnHeaderDefs.Add("LocRoleDesc", Capsule.Create(SelfPrefix + "Link Desc.", 0.1, (Func <IMModelClass, object>)null)); ColumnHeaderDefs.Add("LocRoleDef", Capsule.Create(SelfPrefix + "Link Role", 0.075, (Func <IMModelClass, object>)null)); ColumnHeaderDefs.Add("LocRoleVar", Capsule.Create(SelfPrefix + "Link Var.", 0.075, (Func <IMModelClass, object>)null)); var Header = CreateListHeader(PagesMaker, ColumnHeaderDefs, this.Configuration.FmtListFieldLabel, this.Configuration.FmtFieldLabelBackground); PagesMaker.PageBreakStartCreator = (() => CreateListHeader(PagesMaker, ColumnHeaderDefs, this.Configuration.FmtListFieldLabel, this.Configuration.FmtFieldLabelBackground, this.Configuration.FmtListLinesForeground).Item1); PagesMaker.AppendContent(Header.Item1, false, GroupKey); var ColumnValueDefs = Header.Item2; var VerticalAlign = VerticalAlignment.Stretch; var HorizontalAlign = HorizontalAlignment.Stretch; // Travel Records... Source.ForEachIndexing((record, index) => { int ColIndex = 0; FrameworkElement Cell = null; var RecordFrame = new StackPanel(); // Grid is too expensive for each record RecordFrame.Orientation = Orientation.Horizontal; // Related Idea info... Cell = CreateListCell(record.Item2.AssociatedIdea.ToString(), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); ColIndex++; Cell = CreateListCell((record.Item2.Descriptor == null ? "" : record.Item2.Descriptor.ToString()), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, (record.Item2.Descriptor == null ? HorizontalAlignment.Center : HorizontalAlign), VerticalAlign); RecordFrame.Children.Add(Cell); ColIndex++; Cell = CreateListCell(record.Item2.RoleDefinitor.ToString(), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); ColIndex++; Cell = CreateListCell(record.Item2.RoleVariant.ToString(), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); // Relationship info... ColIndex++; Cell = CreateListCell(record.Item2.OwnerRelationship.ToString(), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); // Self Idea info... ColIndex++; Cell = CreateListCell((record.Item1.Descriptor == null ? "" : record.Item1.Descriptor.ToString()), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); ColIndex++; Cell = CreateListCell(record.Item1.RoleDefinitor.ToString(), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); ColIndex++; Cell = CreateListCell(record.Item1.RoleVariant.ToString(), ColumnValueDefs.ElementAt(ColIndex).Value.Value0, HorizontalAlign, VerticalAlign); RecordFrame.Children.Add(Cell); PagesMaker.AppendContent(RecordFrame, false, (index > 0 ? null : GroupKey)); }); PagesMaker.PageBreakStartCreator = null; }