Exemplo n.º 1
0
 public override Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size)
 {
     Compass<double> margin = this.Margin;
     Point sizepadding = new Point(margin.Left + margin.Right, margin.Up + margin.Down);
     Layout inner = this.Inner.CreateLayout(null, SizeRange.Translate(-sizepadding), out Size);
     Size += sizepadding;
     return new _Layout
     {
         Offset = new Point(margin.Left, margin.Up),
         Inner = inner
     };
 }
Exemplo n.º 2
0
 public override Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size)
 {
     Point sizepadding = this.SizePadding;
     Layout inner = this.Inner.CreateLayout(null, SizeRange.Translate(-sizepadding), out Size);
     Size += sizepadding;
     return new _Layout
     {
         Block = this,
         Inner = inner,
         Size = Size
     };
 }
Exemplo n.º 3
0
Arquivo: Grid.cs Projeto: dzamkov/DUIP
        public override Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size)
        {
            int cols = this.Columns;
            int rows = this.Rows;

            double sep = this.Seperator.Weight;
            Rectangle contentsizerange = SizeRange.Translate(-new Point(sep * (cols - 1), sep * (rows - 1)));

            // Create preliminary cell layouts to estimate sizes needed
            Point maxcellsize = contentsizerange.BottomRight;
            double[] widths = new double[cols];
            double[] heights = new double[rows];
            Layout[,] cells = new Layout[cols, rows];
            for (int c = 0; c < cols; c++)
            {
                for (int r = 0; r < rows; r++)
                {
                    Point size;
                    cells[c, r] = this.Cells[c, r].CreateLayout(null, new Rectangle(new Point(widths[c], heights[r]), maxcellsize), out size);
                    widths[c] = Math.Max(widths[c], size.X);
                    heights[r] = Math.Max(heights[r], size.Y);
                }
            }
            _AdjustSizes(widths, contentsizerange.Left, contentsizerange.Right);
            _AdjustSizes(heights, contentsizerange.Top, contentsizerange.Bottom);

            // Adjust cells to have the new sizes
            for (int c = 0; c < cols; c++)
            {
                double width = widths[c];
                for (int r = 0; r < rows; r++)
                {
                    double height = heights[r];
                    cells[c, r] = this.Cells[c, r].CreateLayout(null, new Point(width, height));
                }
            }

            // Determine offsets
            double totalwidth;
            double totalheight;
            double[] coloffsets = _GetOffsets(widths, sep, out totalwidth);
            double[] rowoffsets = _GetOffsets(heights, sep, out totalheight);

            Size = new Point(totalwidth, totalheight);
            return new _Layout
            {
                Block = this,
                Cells = cells,
                ColumnOffsets = coloffsets,
                RowOffsets = rowoffsets,
                Size = Size
            };
        }