コード例 #1
0
ファイル: Grid.cs プロジェクト: MotorViper/FormGenerator
        /// <summary>
        /// Adds any child properties that are linked to the field.
        /// </summary>
        /// <param name="child">The child whose properties are being added.</param>
        public override void AddChildProperties(IField child)
        {
            base.AddChildProperties(child);

            // Position the child within the grid.
            if (_positions.Columns != null)
            {
                Tuple<int, int> rowAndColumn = _positions.GetNextRowAndColumn();
                int column = rowAndColumn.Item2;
                int row = rowAndColumn.Item1;
                child.AddTypedProperty("Grid.Column", column);
                child.AddTypedProperty("Grid.Row", row);
                IList<IProperty> properties = child.Element.Properties.Find("Across");
                _positions.MakeItemUsed(row, column);
                if (properties != null && properties.Count > 0)
                {
                    IProperty across = properties[0];
                    if (across != null)
                    {
                        int columns = across.IntValue;
                        for (int i = 1; i < columns; ++i)
                            _positions.MakeItemUsed(row, column + i);
                        child.AddTypedProperty("Grid.ColumnSpan", columns);
                        if (properties.Count > 1)
                        {
                            int rows = properties[1].IntValue;
                            child.AddTypedProperty("Grid.RowSpan", rows);
                            for (int col = 0; col < columns; ++col)
                                for (int i = 0; i < rows; ++i)
                                    _positions.MakeItemUsed(row + i, column + col);
                        }
                    }
                }
            }
        }