CodeTV.PanelChannel.treeViewChannel_DragOver C# (CSharp) Method

treeViewChannel_DragOver() private method

private treeViewChannel_DragOver ( object sender, DragEventArgs e ) : void
sender object
e System.Windows.Forms.DragEventArgs
return void
        private void treeViewChannel_DragOver(object sender, DragEventArgs e)
        {
            // Determine whether string data exists in the drop data. If not, then
            // the drop effect reflects that the drop cannot occur.
            if (!e.Data.GetDataPresent(typeof(ArrayList)))
            {
                e.Effect = DragDropEffects.None;
                return;
            }

            // Set the effect based upon the KeyState.
            if ((e.KeyState & 4) == 4 &&
              (e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move)
            {
                // SHIFT KeyState for move.
                e.Effect = DragDropEffects.Move;
            }
            else if ((e.KeyState & 8) == 8 &&
              (e.AllowedEffect & DragDropEffects.Copy) == DragDropEffects.Copy)
            {
                // CTL KeyState for copy.
                e.Effect = DragDropEffects.Copy;
            }
            else if ((e.AllowedEffect & DragDropEffects.Move) == DragDropEffects.Move)
            {
                // By default, the drop action should be move, if allowed.
                e.Effect = DragDropEffects.Move;
            }
            else
                e.Effect = DragDropEffects.None;

            // Get the item the mouse is below.

            // The mouse locations are relative to the screen, so they must be
            // converted to client coordinates.
            this.treeNodeUnderMouseToDrop = this.treeViewChannel.HitTest(this.treeViewChannel.PointToClient(new Point(e.X, e.Y))).Node;

            if (this.treeViewChannel.IsHierarchySelected(this.treeNodeUnderMouseToDrop))
                e.Effect = DragDropEffects.None;
        }