// -----------------------------------------------------------------------------------------
        // Rows=[Value], ColumnDefinitions=[Tech-Name, Name, Width-Percentage, Row-Field-Extractor]
        public void PageWriteTable <TRow>(string ClassName, IRecognizableComposite SourceOwner, IEnumerable <TRow> Rows,
                                          params Capsule <string, string, double, Func <TRow, IMModelClass> >[] ColumnDefinitions)
            where TRow : IMModelClass
        {
            var Records = Rows.Select(
                row =>
            {
                var Values = new List <string>();

                // Travel Colum-Defs...
                foreach (var ColValueDef in ColumnDefinitions)
                {
                    var Entity = (ColValueDef.Value3 == null
                                              ? row : ColValueDef.Value3(row));

                    var Spec = "";
                    if (Entity != null)
                    {
                        var ColDef = Entity.ClassDefinition.GetPropertyDef(ColValueDef.Value0, false);

                        var Value = (ColDef == null ? null : ColDef.Read(Entity));
                        Spec      = GetRecordValueAsHtmlString(Value, SourceOwner, row);
                    }

                    Values.Add(Spec);
                }

                return((IEnumerable <string>)Values);
            });

            var ColDefs = ColumnDefinitions.Select(
                def => Capsule.Create(def.Value0, def.Value1, def.Value2)).ToArray();

            this.PageWriteTable(ClassName, Records, ColDefs);
        }
Beispiel #2
0
        public void CreateContentList(IEnumerable <IMModelClass> Source, IRecognizableComposite SourceOwner, DisplayList DispList,
                                      string DefinitorTechName, string DefinitorName, string TechPrefixInternalOwner = null, string TechPrefixSource = null,
                                      params Tuple <string, string, double, Func <IMModelClass, object> >[] ExtraColDefs)
        {
            var TableColDefs = new List <Capsule <string, string, double, Func <IMModelClass, object> > >();
            var TableRowVals = new List <List <string> >();

            // Define columns
            if (DispList.PropName)
            {
                TableColDefs.Add(Capsule.Create(FormalPresentationElement.__Name.TechName.RemoveNewLines().ToHtmlEncoded(),
                                                FormalPresentationElement.__Name.Name.RemoveNewLines().ToHtmlEncoded(), 25.0,
                                                (Func <IMModelClass, object>)null));
            }

            if (DispList.PropTechName)
            {
                TableColDefs.Add(Capsule.Create(FormalPresentationElement.__TechName.TechName.RemoveNewLines().ToHtmlEncoded(),
                                                FormalPresentationElement.__TechName.Name.RemoveNewLines().ToHtmlEncoded(), 20.0,
                                                (Func <IMModelClass, object>)null));
            }

            if (DispList.PropSummary)
            {
                TableColDefs.Add(Capsule.Create(FormalPresentationElement.__Summary.TechName.RemoveNewLines().ToHtmlEncoded(),
                                                FormalPresentationElement.__Summary.Name.RemoveNewLines().ToHtmlEncoded(),
                                                (!DispList.PropTechName ? 50.0 : 30.0),
                                                (Func <IMModelClass, object>)null));
            }

            if (DispList.PropPictogram)
            {
                TableColDefs.Add(Capsule.Create(FormalPresentationElement.__Pictogram.TechName.RemoveNewLines().ToHtmlEncoded(),
                                                "Pict.", 5.0,               // FormalPresentationElement.__Pictogram.Name.RemoveNewLines().ToHtmlEncoded()
                                                (Func <IMModelClass, object>)null));
            }

            if (DispList.Definitor && !(DefinitorTechName.IsAbsent() || DefinitorName.IsAbsent()))
            {
                TableColDefs.Add(Capsule.Create(DefinitorTechName.ToHtmlEncoded(), DefinitorName.ToHtmlEncoded(),
                                                (!DispList.PropPictogram ? 28.0 : 20.0),
                                                (Func <IMModelClass, object>)null));
            }

            if (ExtraColDefs != null)
            {
                foreach (var ExtraColDef in ExtraColDefs)
                {
                    TableColDefs.Add(Capsule.Create(ExtraColDef.Item1.ToHtmlEncoded(), ExtraColDef.Item2.ToHtmlEncoded(), ExtraColDef.Item3, ExtraColDef.Item4));
                }
            }

            // Generate record values
            foreach (var Record in Source)
            {
                var Values = new List <string>();

                string Anchor = null;

                if (this.RegisteredLocations.ContainsKey(Record))
                {
                    var RefLink = this.GetRelativeLocationOf(Record);

                    if (!RefLink.IsAbsent())
                    {
                        Anchor = "<a href=" + RefLink + ">@VALUE</a>";
                    }
                }

                // Travel Colum-Defs...
                foreach (var ColValueDef in TableColDefs)
                {
                    var    ColDef = Record.ClassDefinition.GetPropertyDef(ColValueDef.Value0, false);
                    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();
                            }

                            return(Picture);
                        });
                    }
                    else
                    {
                        Value = (ColValueDef.Value3 != null
                                 ? ColValueDef.Value3(Record)
                                 : (ColDef == null ? null : ColDef.Read(Record)));
                    }

                    var NamePrefix = (TechPrefixInternalOwner.IsAbsent() ? "" : TechPrefixInternalOwner + ".") +
                                     (TechPrefixSource.IsAbsent() ? "" : TechPrefixSource + "_" + Source.IndexOfMatch(item => item == Record).ToString() + ".");
                    var Spec = GetRecordValueAsHtmlString(Value, SourceOwner, Record, null, NamePrefix);

                    if (Values.Count < 1 && Anchor != null)
                    {
                        Spec = Anchor.Replace("@VALUE", Spec);
                    }

                    Values.Add(Spec);
                }

                TableRowVals.Add(Values);
            }
            ;

            this.PageWriteTable("tbl_list_objects", TableRowVals, TableColDefs.Select(def => Capsule.Create(def.Value0, def.Value1, def.Value2)).ToArray());
        }