Ejemplo n.º 1
0
        private void updateViewBounds()
        {
            try
            {
                this.updateGraphBounds();

                if (fViewBounds == null)
                {
                    fViewBounds = fGraphBounds;
                    return;
                }

                ArborPoint vLT = fGraphBounds.LeftTop.sub(fViewBounds.LeftTop).mul(Mag);
                ArborPoint vRB = fGraphBounds.RightBottom.sub(fViewBounds.RightBottom).mul(Mag);

                double aX = vLT.magnitude() * this.fScreenWidth;
                double aY = vRB.magnitude() * this.fScreenHeight;

                if (aX > 1 || aY > 1)
                {
                    ArborPoint nbLT = fViewBounds.LeftTop.add(vLT);
                    ArborPoint nbRB = fViewBounds.RightBottom.add(vRB);

                    fViewBounds = new PSBounds(nbLT, nbRB);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine("ArborSystem.updateViewBounds(): " + ex.Message);
            }
        }
Ejemplo n.º 2
0
        private void updateGraphBounds()
        {
            ArborPoint lt = new ArborPoint(-1, -1);
            ArborPoint rb = new ArborPoint(1, 1);

            foreach (ArborNode node in this.fNodes)
            {
                ArborPoint pt = node.Pt;
                if (pt.exploded())
                {
                    continue;
                }

                if (pt.X < lt.X)
                {
                    lt.X = pt.X;
                }
                if (pt.Y < lt.Y)
                {
                    lt.Y = pt.Y;
                }
                if (pt.X > rb.X)
                {
                    rb.X = pt.X;
                }
                if (pt.Y > rb.Y)
                {
                    rb.Y = pt.Y;
                }
            }

            lt.X -= 1.2;
            lt.Y -= 1.2;
            rb.X += 1.2;
            rb.Y += 1.2;

            ArborPoint sz   = rb.sub(lt);
            ArborPoint cent = lt.add(sz.div(2));
            ArborPoint d    = new ArborPoint(Math.Max(sz.X, 4.0), Math.Max(sz.Y, 4.0)).div(2);

            this.fGraphBounds = new PSBounds(cent.sub(d), cent.add(d));
        }