CodeTV.PanelChannel.treeViewChannel_MouseDown C# (CSharp) Method

treeViewChannel_MouseDown() private method

private treeViewChannel_MouseDown ( object sender, MouseEventArgs e ) : void
sender object
e MouseEventArgs
return void
        private void treeViewChannel_MouseDown(object sender, MouseEventArgs e)
        {
            bool startDrag = false;
            foreach (TreeNode tn in this.treeViewChannel.SelectedNodes)
            {
                if (tn.Bounds.Contains(e.X, e.Y))
                    startDrag = true;
            }
            this.treeNodeUnderMouseToDrag = this.treeViewChannel.HitTest(e.X, e.Y).Node;
            if (this.treeNodeUnderMouseToDrag != null && startDrag)
            {
                // Remember the point where the mouse down occurred. The DragSize indicates
                // the size that the mouse can move before a drag event should be started.
                Size dragSize = SystemInformation.DragSize;
                dragSize.Height *= this.treeViewChannel.SelectedNodes.Count;

                // Create a rectangle using the DragSize, with the mouse position being
                // at the center of the rectangle.
                this.dragBoxFromMouseDown = new Rectangle(new Point(e.X - (dragSize.Width / 2),
                                                               e.Y - (dragSize.Height / 2)), dragSize);
            }
            else
                // Reset the rectangle if the mouse is not over an item in the ListBox.
                this.dragBoxFromMouseDown = Rectangle.Empty;
        }