AdvancedPageDragAndDrop.PageDragTreeView.OnMouseDown C# (CSharp) Method

OnMouseDown() protected method

Raises the MouseDown event.
protected OnMouseDown ( MouseEventArgs e ) : void
e MouseEventArgs A MouseEventArgs that contains the event data.
return void
        protected override void OnMouseDown(MouseEventArgs e)
        {
            // Grab the node under the mouse
            Point pt = new Point(e.X, e.Y);
            TreeNode nodeDown = GetNodeAt(pt);

            // Try and ensure the node is selected on the mouse down
            if ((nodeDown != null) && (SelectedNode != nodeDown))
                SelectedNode = nodeDown;

            // Mouse down could be a prelude to a drag operation
            if (e.Button == MouseButtons.Left)
            {
                // Remember the node as a potential drag node
                _dragNode = nodeDown;

                // Create the rectangle that moving outside causes a drag operation
                _dragRect = new Rectangle(pt, Size.Empty);
                _dragRect.Inflate(SystemInformation.DragSize);
            }

            base.OnMouseDown(e);
        }