コード例 #1
0
ファイル: Table.cs プロジェクト: MotorViper/FormGenerator
        /// <summary>
        /// Adds the fields children.
        /// </summary>
        protected override void AddChildren()
        {
            BeginAddChildren();
            IEnumerable<IElement> fields = Element.Children.ToList();

            // Add the headers.
            foreach (IElement child in fields)
            {
                IElement header = child.Properties.FindChild("Header");
                if (header != null)
                {
                    if (header.Properties.Count == 0)
                    {
                        SimpleElement label = new SimpleElement("Label");
                        label.Properties.Add(new SimpleProperty("Content", new SimpleValue(header.ElementName)));
                        header = label;
                    }
                    if (string.IsNullOrWhiteSpace(header.ElementType))
                        header.ElementType = "Label";
                    AddElement(header, Level + 1, this);
                }
            }

            // Add a set of children for every item in the content list.
            IList<IProperty> over = Element.Properties.Find("Content");
            if (over == null || over.Count == 0)
                throw new Exception("Tried to create table with no Content.");
            if (over.Count == 1)
            {
                IPropertyList items = Element.Parameters.GetList(over[0].StringValue);
                foreach (IProperty item in items)
                    AddElements(fields, item);
            }
            else
            {
                foreach (IProperty item in over)
                    AddElements(fields, item);
            }
            EndAddChildren();
        }
コード例 #2
0
ファイル: Table.cs プロジェクト: MotorViper/FormGenerator
 /// <summary>
 /// Outputs the fields children.
 /// </summary>
 protected override void AddChildren()
 {
     GridData positions = new GridData(Element.Properties, "10");
     List<string> columns = positions.Columns;
     List<IElement> fields = Element.Children.ToList();
     Builder.Append("<tr>").AppendLine();
     int i = 0;
     foreach (IElement child in fields)
     {
         string columnData = columns[i];
         IElement header = child.Properties.FindChild("Header");
         if (columnData != "Auto")
             Builder.Append("<th style=\"width: ").Append(columnData).Append("px\">").AppendLine();
         else
             Builder.Append("<th>").AppendLine();
         if (header != null)
         {
             if (header.Properties.Count == 0)
             {
                 SimpleElement label = new SimpleElement("Label");
                 label.Properties.Add(new SimpleProperty("Content", new SimpleValue(header.ElementName)));
                 header = label;
             }
             if (string.IsNullOrWhiteSpace(header.ElementType))
                 header.ElementType = "Label";
             AddElement(header, Level + 1, this);
         }
         Builder.Append("</th>").AppendLine();
         ++i;
     }
     Builder.Append("</tr>").AppendLine();
     IList<IProperty> over = Element.Properties.Find("Content");
     if (over == null || over.Count == 0)
         throw new Exception("Tried to create table with no Content.");
     AddRows(fields, over.Count == 1 ? Element.Parameters.GetList(over[0].StringValue) : (IEnumerable<IProperty>)over);
 }