Пример #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnDragLeave(EventArgs e)
        {
            if (this._selectedNode != null)
            {
                this.SelectedNode = this._selectedNode;
            }

            if (this._previousNode != null)
            {
                this._previousNode.BackColor = this._dragOverNodeBackColor;
                this._previousNode.ForeColor = this._dragOverNodeForeColor;
            }

            this._formDrag.Visible = false;
            this.Cursor            = Cursors.Default;

            // Call cancel event
            if (this.DragCancel != null)
            {
                DragItemEventArgs ea = new DragItemEventArgs();
                ea.Node = this._selectedNode;

                this.DragCancel(this, ea);
            }
        }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnKeyUp(KeyEventArgs e)
        {
            if (e.KeyCode == Keys.Escape)
            {
                if (this._selectedNode != null)
                {
                    this.SelectedNode = this._selectedNode;
                }

                if (this._previousNode != null)
                {
                    this._previousNode.BackColor = SystemColors.HighlightText;
                    this._previousNode.ForeColor = SystemColors.ControlText;
                }

                this.Cursor            = Cursors.Default;
                this._formDrag.Visible = false;

                // Call cancel event
                if (this.DragCancel != null)
                {
                    DragItemEventArgs ea = new DragItemEventArgs();
                    ea.Node = this._selectedNode;

                    this.DragCancel(this, ea);
                }
            }
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        protected override void OnItemDrag(System.Windows.Forms.ItemDragEventArgs e)
        {
            this._selectedNode = (TreeNode)e.Item;

            // Call dragstart event
            if (this.DragStart != null)
            {
                DragItemEventArgs ea = new DragItemEventArgs();
                ea.Node = this._selectedNode;

                this.DragStart(this, ea);
            }
            // Change any previous node back
            if (this._previousNode != null)
            {
                this._previousNode.BackColor = SystemColors.HighlightText;
                this._previousNode.ForeColor = SystemColors.ControlText;
            }

            // Move the form with the icon/label on it
            // A better width measurement algo for the form is needed here
            int width = (int)(this._selectedNode.Text.Length * (int)this._formDrag.labelText.Font.Size * 1.5f);

            if (this._selectedNode.Text.Length < 5)
            {
                width += 20;
            }

            this._formDrag.Size = new Size(width, this._formDrag.Height);

            this._formDrag.labelText.Size = new Size(width, this._formDrag.labelText.Size.Height);
            this._formDrag.labelText.Text = this._selectedNode.Text;

            // Start drag drop
            this.DoDragDrop(e.Item, this._dragMode);
        }