Exemple #1
0
        void Feeder_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            if (_isDragging)
            {
                this.Capture  = true;
                this.Location = new Point(this.Location.X + e.X - _mouseLocationOnButton.X, this.Location.Y + e.Y - _mouseLocationOnButton.Y);

                if (PanelArranged.Contains(this))
                {
                    Point location = PanelUnArranged.PointToClient(Cursor.Position);
                    if (PanelUnArranged.ClientRectangle.Contains(location))
                    {
                        location = MoveOnPanelUnArranged(location);
                    }
                }
                else
                {
                    Point location = PanelArranged.PointToClient(Cursor.Position);
                    if (PanelArranged.ClientRectangle.Contains(location))
                    {
                        location = MoveOnPanelArranged(location);
                    }
                }
            }
        }
Exemple #2
0
 private Point MoveOnPanelArranged(Point location)
 {
     location = PanelArranged.PointToClient(Cursor.Position);
     location = new Point(location.X - _mouseLocationOnButton.X, location.Y - _mouseLocationOnButton.Y + PanelArranged.Height);
     PanelUnArranged.Controls.Remove(this);
     this.Location = location;
     PanelArranged.Controls.Add(this);
     this.Capture = true;
     this.BringToFront();
     this.PanelArranged.Refresh();
     return(location);
 }
Exemple #3
0
        private Control GetTargetControl(Point controlLocation)
        {
            if (PanelArranged.ClientRectangle.Contains(PanelArranged.PointToClient(Cursor.Position)))
            {
                foreach (Control control in PanelArranged.Controls)
                {
                    Rectangle clientRectangle = new Rectangle(control.Location, control.Size);
                    if (control is GroupBox && clientRectangle.Contains(controlLocation))
                    {
                        return(control as GroupBox);
                    }
                }
            }

            return(null);
        }