internal TableControlRow(TableRowDefinition rowdefinition) : this()
        {
            Wrap = rowdefinition.multiLine;
            if (rowdefinition.appliesTo != null)
            {
                SelectedBy = EntrySelectedBy.Get(rowdefinition.appliesTo.referenceList);
            }
            foreach (TableRowItemDefinition itemdef in rowdefinition.rowItemDefinitionList)
            {
                FieldPropertyToken fpt = itemdef.formatTokenList[0] as FieldPropertyToken;
                TableControlColumn column;

                if (fpt != null)
                {
                    column = new TableControlColumn(fpt.expression.expressionValue, itemdef.alignment,
                                                    fpt.expression.isScriptBlock, fpt.fieldFormattingDirective.formatString);
                }
                else
                {
                    column = new TableControlColumn();
                }

                Columns.Add(column);
            }
        }
        private static void AddRowDefinitions(HtmlNode htmlNode, GridDefinition grid)
        {
            var table = new TableRowDefinition(htmlNode);

            foreach (var node in htmlNode.Nodes("tr"))
            {
                var tr = new TdRowDefinition(table, node);
                grid.RowDefinitions.Add(tr);
            }
        }
Beispiel #3
0
 internal TableControlRow(TableRowDefinition rowdefinition)
 {
     this._columns = new List <TableControlColumn>();
     foreach (TableRowItemDefinition definition in rowdefinition.rowItemDefinitionList)
     {
         TableControlColumn column;
         FieldPropertyToken token = definition.formatTokenList[0] as FieldPropertyToken;
         if (token != null)
         {
             column = new TableControlColumn(token.expression.expressionValue, definition.alignment, token.expression.isScriptBlock);
         }
         else
         {
             column = new TableControlColumn();
         }
         this._columns.Add(column);
     }
 }
Beispiel #4
0
        private List <TableRowItemDefinition> GetActiveTableRowDefinition(TableControlBody tableBody, PSObject so)
        {
            if (tableBody.optionalDefinitionList.Count == 0)
            {
                // we do not have any override, use default
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }

            // see if we have an override that matches
            TableRowDefinition matchingRowDefinition = null;

            var       typeNames = so.InternalTypeNames;
            TypeMatch match     = new TypeMatch(_expressionFactory, _typeInfoDatabase, typeNames);

            foreach (TableRowDefinition x in tableBody.optionalDefinitionList)
            {
                if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                {
                    matchingRowDefinition = x;
                    break;
                }
            }

            if (matchingRowDefinition == null)
            {
                matchingRowDefinition = match.BestMatch as TableRowDefinition;
            }

            if (matchingRowDefinition == null)
            {
                Collection <string> typesWithoutPrefix = Deserializer.MaskDeserializationPrefix(typeNames);
                if (typesWithoutPrefix != null)
                {
                    match = new TypeMatch(_expressionFactory, _typeInfoDatabase, typesWithoutPrefix);

                    foreach (TableRowDefinition x in tableBody.optionalDefinitionList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(x, x.appliesTo)))
                        {
                            matchingRowDefinition = x;
                            break;
                        }
                    }

                    if (matchingRowDefinition == null)
                    {
                        matchingRowDefinition = match.BestMatch as TableRowDefinition;
                    }
                }
            }

            if (matchingRowDefinition == null)
            {
                // no matching override, use default
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }

            // we have an override, we need to compute the merge of the active cells
            List <TableRowItemDefinition> activeRowItemDefinitionList = new List <TableRowItemDefinition>();
            int col = 0;

            foreach (TableRowItemDefinition rowItem in matchingRowDefinition.rowItemDefinitionList)
            {
                // Check if the row is an override or not
                if (rowItem.formatTokenList.Count == 0)
                {
                    // It's a place holder, use the default
                    activeRowItemDefinitionList.Add(tableBody.defaultDefinition.rowItemDefinitionList[col]);
                }
                else
                {
                    // Use the override
                    activeRowItemDefinitionList.Add(rowItem);
                }

                col++;
            }

            return(activeRowItemDefinitionList);
        }
Beispiel #5
0
        private List <TableRowItemDefinition> GetActiveTableRowDefinition(TableControlBody tableBody, PSObject so)
        {
            if (tableBody.optionalDefinitionList.Count == 0)
            {
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }
            TableRowDefinition bestMatch         = null;
            ConsolidatedString internalTypeNames = so.InternalTypeNames;
            TypeMatch          match             = new TypeMatch(this.expressionFactory, this.typeInfoDatabase, internalTypeNames);

            foreach (TableRowDefinition definition2 in tableBody.optionalDefinitionList)
            {
                if (match.PerfectMatch(new TypeMatchItem(definition2, definition2.appliesTo)))
                {
                    bestMatch = definition2;
                    break;
                }
            }
            if (bestMatch == null)
            {
                bestMatch = match.BestMatch as TableRowDefinition;
            }
            if (bestMatch == null)
            {
                Collection <string> typeNames = Deserializer.MaskDeserializationPrefix(internalTypeNames);
                if (typeNames != null)
                {
                    match = new TypeMatch(this.expressionFactory, this.typeInfoDatabase, typeNames);
                    foreach (TableRowDefinition definition3 in tableBody.optionalDefinitionList)
                    {
                        if (match.PerfectMatch(new TypeMatchItem(definition3, definition3.appliesTo)))
                        {
                            bestMatch = definition3;
                            break;
                        }
                    }
                    if (bestMatch == null)
                    {
                        bestMatch = match.BestMatch as TableRowDefinition;
                    }
                }
            }
            if (bestMatch == null)
            {
                return(tableBody.defaultDefinition.rowItemDefinitionList);
            }
            List <TableRowItemDefinition> list = new List <TableRowItemDefinition>();
            int num = 0;

            foreach (TableRowItemDefinition definition4 in bestMatch.rowItemDefinitionList)
            {
                if (definition4.formatTokenList.Count == 0)
                {
                    list.Add(tableBody.defaultDefinition.rowItemDefinitionList[num]);
                }
                else
                {
                    list.Add(definition4);
                }
                num++;
            }
            return(list);
        }