Beispiel #1
0
        void NodeHostControl_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Middle)
            {
                Cursor.Current = Cursors.Arrow;
            }

            //mLastPosition = Point(e.X, e.Y);
            if (e.Button == MouseButtons.Right)
            {
                if (mOwner != null)
                {
                    mOwner.ShowContextMenu(this, e.X, e.Y);
                }
            }
            if (e.Button == MouseButtons.Left)
            {
                int       top    = Math.Min(mLastPosition.Y, e.Y);
                int       bottom = Math.Max(mLastPosition.Y, e.Y);
                int       left   = Math.Min(mLastPosition.X, e.X);
                int       right  = Math.Max(mLastPosition.X, e.X);
                Rectangle r      = Rectangle.FromLTRB(left, top, right, bottom);

                List <Control> selected = new List <Control>();
                foreach (Control c in this.Controls)
                {
                    ISelectable selectable = c as ISelectable;
                    if (selectable != null)
                    {
                        Rectangle bounds    = selectable.GetBounds();
                        Rectangle intersect = Rectangle.Intersect(bounds, r);
                        if (intersect != Rectangle.Empty)
                        {
                            Rectangle union = Rectangle.Union(bounds, r);
                            if (union != null)
                            {
                                selected.Add(c);
                                selectable.SelectControl();
                            }
                            else
                            {
                                selectable.DeSelectControl();
                            }
                        }
                        else
                        {
                            //Keyboard.
                            //Keys.
                            if (Control.ModifierKeys != Keys.Shift)
                            {
                                selectable.DeSelectControl();
                            }
                        }
                    }
                }

                {
                    r.Offset(this.PointToScreen(new Point(0, 0)));

                    ControlPaint.DrawReversibleFrame(r, Color.White, FrameStyle.Thick);
                }
            }
        }