Exemplo n.º 1
0
Arquivo: Node.cs Projeto: dzamkov/DUIP
        public Node(Context WorldInputContext, Disposable<Content> Content, Block Block, Point Position, Point Velocity)
        {
            this._Content = Content;
            this._Block = Block;
            this._Position = Position;
            this._Velocity = Velocity;
            this._Layout = this._Block.Object.CreateLayout(null, SizeRange, out this._Size);

            this._InputContext = new _NodeInputContext(this, WorldInputContext);
            this._Layout.Link(this._InputContext);
        }
Exemplo n.º 2
0
Arquivo: Node.cs Projeto: dzamkov/DUIP
        public Node(Context WorldInputContext, Disposable<Content> Content, Block Block, Layout Layout, Point Size, Point Position, Point Velocity)
        {
            this._Content = Content;
            this._Block = Block;
            this._Position = Position;
            this._Velocity = Velocity;
            this._Layout = Layout;
            this._Size = Size;

            this._InputContext = new _NodeInputContext(this, WorldInputContext);
            this._Layout.Link(this._InputContext);
        }
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
            };
        }