public DrawingItem HitTest(Control owner, int x, int y)
 {
     for (int i = this.Count - 1; i >= 0; i--)
     {
         DrawingItem  objDraw = this[i];
         DrawGroupBox dgb     = objDraw as DrawGroupBox;
         if (dgb != null)
         {
             DrawingItem di = dgb.HitTestChild(owner, x, y);
             if (di != null)
             {
                 return(di);
             }
             else
             {
                 if (objDraw.HitTest(owner, x, y))
                 {
                     return(objDraw);
                 }
             }
         }
         else if (objDraw.HitTest(owner, x, y))
         {
             return(objDraw);
         }
     }
     return(null);
 }
 public virtual DrawingItem HitTestChild(Control owner, int x, int y)
 {
     if (_items != null)
     {
         int x0 = x - this.Left;
         int y0 = y - this.Top;
         if (this.RotateAngle != 0)
         {
             PointF pf = DrawRect.ConvertPoint(this.RectF, this.RotateAngle, new PointF((float)x, (float)y));
             x0 = (int)pf.X;
             y0 = (int)pf.Y;
         }
         for (int i = _items.Count - 1; i >= 0; i--)
         {
             DrawingItem  obj = _items[i];
             DrawGroupBox dgb = obj as DrawGroupBox;
             if (dgb != null)
             {
                 DrawingItem o = dgb.HitTestChild(owner, x0, y0);
                 if (o != null)
                 {
                     return(o);
                 }
             }
             if (obj.HitTest(owner, x0, y0))
             {
                 return(obj);
             }
         }
     }
     return(null);
 }
        public override void OnLoadedFromXmlFile(DrawingItem obj, IDesignPane designPane, IDrawDesignControl designControl)
        {
            Point p0 = this.Location;

            this.Copy(obj);             //contained objects are cloned in _items
            if (this.Page != null && this.Page.InDesignMode)
            {
                DrawGroupBox dgb = obj as DrawGroupBox;
                if (dgb != null)
                {
                    IList <DrawingItem> lst = dgb.Items;                    //cloned in _items
                    if (lst != null && designPane != null && designControl != null)
                    {
                        //for each object, create a designer control and assign it to the control
                        Control ctrl = designControl as Control;                         //control corresponding to this object
                        foreach (DrawingItem di in lst)
                        {
                            Type     t  = di.GetType();
                            object[] vs = t.GetCustomAttributes(typeof(TypeMappingAttribute), true);
                            if (vs != null && vs.Length > 0)
                            {
                                TypeMappingAttribute tm = vs[0] as TypeMappingAttribute;
                                if (tm != null)
                                {
                                    //create designer control
                                    IComponent         ic  = designPane.CreateComponent(tm.MappedType, di.Name);
                                    IDrawDesignControl idc = ic as IDrawDesignControl;
                                    Control            c   = ic as Control;
                                    DrawingItem        d0  = idc.Item;                             //auto-created object, should be deleted
                                    ctrl.Controls.Add(c);
                                    idc.Item   = GetItemByID(di.DrawingId);                        //use cloned object for the new control
                                    c.Location = di.Location;
                                    if (_items != null)
                                    {
                                        //remove auto-created object d0
                                        for (int i = 0; i < _items.Count; i++)
                                        {
                                            if (d0 == _items[i] || d0.DrawingId == _items[i].DrawingId)
                                            {
                                                _items.RemoveAt(i);
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            this.Location = p0;
        }
        protected override void OnControlAdded(ControlEventArgs e)
        {
            base.OnControlAdded(e);
            IDrawDesignControl ddc = e.Control as IDrawDesignControl;

            if (ddc != null)
            {
                DrawGroupBox dgb = this.Item as DrawGroupBox;
                if (dgb != null)
                {
                }
            }
        }
        public override void Copy(DrawingItem obj)
        {
            base.Copy(obj);
            DrawGroupBox dgb = obj as DrawGroupBox;

            if (dgb != null)
            {
                this.bmp = dgb.bmp;
                this._imageStartPoint = dgb._imageStartPoint;
                this.sFilename        = dgb.sFilename;
                _items = new List <DrawingItem>();
                foreach (DrawingItem item0 in dgb.Items)
                {
                    _items.Add(item0.Clone());
                }
            }
        }
 public BackImage(DrawGroupBox owner)
 {
     _owner = owner;
 }