예제 #1
0
 public void addShape(VShape sh)
 {
     children.Add(sh);
     calcWH(sh);
 }
예제 #2
0
        public void calcWH(VShape sh)
        {
            if (sh.className() == "ShapeGroup ")
            {
                ShapeGroup shape = (ShapeGroup)sh;
                if (x > shape.x)
                {
                    x = shape.x;
                    if (x2 == 0)
                    {
                        x2 = shape.x + shape.w;
                    }
                }
                else if (shape.x + shape.w > x2)
                {
                    x2 = shape.x + shape.w;
                }

                if (y > shape.y)
                {
                    y = shape.y;
                    if (y2 == 0)
                    {
                        y2 = shape.y + shape.h;
                    }
                }
                else if (shape.y + shape.h > y2)
                {
                    y2 = shape.y + shape.h;
                }
            }
            else
            {
                if (sh.x - sh.R <= x)
                {  // start x = maxVal
                    x = (int)(sh.x - sh.R);
                    if (x2 == 0)
                    {
                        x2 = (int)(sh.x + sh.R);
                    }
                }
                else
                {
                    if (sh.x + sh.R > x2)
                    {
                        x2 = (int)(sh.x + sh.R);
                    }
                }
                if (sh.y - sh.R < y)
                {
                    y = (int)(sh.y - sh.R);
                    if (y2 == 0)
                    {
                        y2 = (int)(sh.y + sh.R);
                    }
                }
                else
                {
                    if (sh.y + sh.R > y2)
                    {
                        y2 = (int)(sh.y + sh.R);
                    }
                }
            }
            w = (x2 - x);
            h = (y2 - y);
        }