Beispiel #1
0
        private void btn_group_Click(object sender, EventArgs e)
        {
            if (cont.Count() > 0)
            {
                ShapeGroup       shapeGroup = new ShapeGroup();
                Iterator <Shape> it         = cont.iterator();
                for (it.begin(); !it.EOL(); it.next())
                {
                    if (it.getVal().brush.isSelect())
                    {
                        break;
                    }
                }
                if (((Button)sender).Text == "Group")
                {
                    // GROUP

                    for (; !it.EOL(); it.next())
                    {
                        if (it.getVal().brush.isSelect())
                        {
                            shapeGroup.addShape((VShape)it.remove()); // transfer obj from main container to group
                        }
                    }
                    unselectAll(shapeGroup.children);   // shapes in group is unselect
                    cont.Add(shapeGroup);
                }
                else
                {
                    // UNGROUP
                    if (it.getVal().className() == "ShapeGroup ")
                    {
                        shapeGroup = ((ShapeGroup)it.getVal()); // save shapeGroup in var
                        Iterator <Shape> itChild = shapeGroup.children.iterator();
                        shapeGroup.hide(gr);                    //
                        it.remove();                            // remove shapeGroup


                        for (itChild.begin(); !itChild.EOL(); itChild.next())
                        {
                            it.addNext(itChild.remove());   // transfer obj from group to main container

                            it.getVal().brush.select();     // when ungroup, obj stand select for u can group undo
                            it.getVal().show(gr);
                        }
                    }
                }
                paintAction();
                toolStripMenuItemCounter.Text = cont.Count() + "";
            }
        }
Beispiel #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);
        }