コード例 #1
0
ファイル: Grid.cs プロジェクト: MotorViper/FormGenerator
        /// <summary>
        /// Outputs the fields children.
        /// </summary>
        protected override void AddChildren()
        {
            GridData positions = new GridData(Element.Properties, "10");
            IEnumerable<IElement> fields = Element.Children;
            int row = 0;

            AppendStartOfLine("<tr>").AppendLine();
            foreach (IElement child in fields)
            {
                int columns = 1;
                int rows = 1;
                Tuple<int, int> rowAndColumn = positions.GetNextRowAndColumn();
                if (rowAndColumn.Item1 != row)
                {
                    AppendStartOfLine("</tr>").AppendLine();
                    AppendStartOfLine("<tr>").AppendLine();
                }
                row = rowAndColumn.Item1;
                int column = rowAndColumn.Item2;
                positions.MakeItemUsed(row, column);
                IList<IProperty> across = child.Properties.Find("Across");
                if (across != null && across.Count > 0)
                {
                    columns = across[0].IntValue;
                    for (int i = 1; i < columns; ++i)
                        positions.MakeItemUsed(row, column + i);
                    if (across.Count > 1)
                    {
                        rows = across[1].IntValue;
                        for (int col = 0; col < columns; ++col)
                            for (int i = 0; i < rows; ++i)
                                positions.MakeItemUsed(row + i, column + col);
                    }
                }
                Builder.Append("<td ");
                if (columns > 1)
                    Builder.Append($" colspan=\"{columns}\"");
                if (rows > 1)
                    Builder.Append($" rowspan=\"{rows}\"");
                Builder.Append(">").AppendLine();
                AddElement(child, Level + 1, this, Keys);
                Builder.Append("</td>").AppendLine();
            }
            Builder.Append("</tr>").AppendLine();
        }
コード例 #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);
 }
コード例 #3
0
ファイル: Grid.cs プロジェクト: MotorViper/FormGenerator
 /// <summary>
 /// Start adding the grids children.
 /// </summary>
 protected void BeginAddChildren()
 {
     _positions = new GridData(Element.Properties, _columnWidth);
 }