Example #1
0
        private bool SetElement(int X, int Y, GridPadding Element)
        {
            if (X < 0 || X >= this.nrColumns)
            {
                return(false);
            }

            if (Y < 0)
            {
                return(false);
            }

            int i = Y * this.nrColumns + X;
            int c = this.elements.Count;

            while (i > c)
            {
                this.elements.Add(null);
                c++;
            }

            if (i == c)
            {
                this.elements.Add(Element);
                return(true);
            }
            else
            {
                if (this.elements[i] is null)
                {
                    this.elements[i] = Element;
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
Example #2
0
        private void SetElement(int X, int Y, int ColSpan, int RowSpan, ILayoutElement Element)
        {
            GridPadding P = new GridPadding(Element, 0, 0, X, Y, ColSpan, RowSpan);

            if (ColSpan > 1 || RowSpan > 1)
            {
                int  i;
                bool First = true;

                for (; RowSpan > 0; RowSpan--)
                {
                    for (i = 0; i < ColSpan; i++)
                    {
                        if (!this.SetElement(X + i, Y, P))
                        {
                            throw new InvalidOperationException("Cell does not fit in grid.");
                        }

                        if (First)
                        {
                            First = false;
                            P     = new GridPadding(null, 0, 0, 0, 0, 0, 0);
                        }
                    }

                    Y++;
                }
            }
            else
            {
                if (!this.SetElement(X, Y, P))
                {
                    throw new InvalidOperationException("Cell does not fit in grid.");
                }
            }
        }