Beispiel #1
0
        private void mergeList_DragOver(object sender, DragEventArgs e)
        {
            // Drag and drop denied by default.
            e.Effect = DragDropEffects.None;

            // Is it a valid format?
            DragDropItem ud = e.Data.GetData(typeof(DragDropItem)) as DragDropItem;

            if (ud != null)
            {
                //we only ever want an entry in 1x in the list.  Remove any duplicates, so you can reorder from the filesystem treeview
                TreeNode[] nodes = mergeList.Nodes.Find(ud.Name, false);
                if (ud.Source == DragDropItem.SourceType.Drive)
                {
                    if (nodes.Length < 1)
                    {
                        e.Effect = DragDropEffects.Copy;
                    }
                }
                else
                {
                    e.Effect = DragDropEffects.Copy;
                }
            }
        }
Beispiel #2
0
        private void mergeList_DragDrop(object sender, DragEventArgs e)
        {
            // Is it a valid format?
            DragDropItem ud = e.Data.GetData(typeof(DragDropItem)) as DragDropItem;

            if (ud != null)
            {
                Point    newPoint = mergeList.PointToClient(new Point(e.X, e.Y));
                TreeNode selected = mergeList.GetNodeAt(newPoint.X, newPoint.Y);
                CheckDrop(mergeList, ud, selected);
            }
        }
Beispiel #3
0
        //enable dragging for mergelist
        private void mergeList_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                // Get the node underneath the mouse.
                TreeNode selected = mergeList.GetNodeAt(e.X, e.Y);
                mergeList.SelectedNode = selected;

                // Start the drag-and-drop operation with a cloned copy of the node.
                if (selected != null)
                {
                    DragDropItem ud = new DragDropItem(selected.Text, DragDropItem.SourceType.Merge);
                    mergeList.DoDragDrop(ud, DragDropEffects.All);
                }
            }
        }
Beispiel #4
0
        private void driveAndDirTreeView_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                // Get the node underneath the mouse.
                TreeNode selected = driveAndDirTreeView.GetNodeAt(e.X, e.Y);
                driveAndDirTreeView.SelectedNode = selected;

                // Start the drag-and-drop operation with a cloned copy of the node.
                if (selected != null)
                {
                    DragDropItem ud = new DragDropItem(GetSelectedNodesPath(selected), DragDropItem.SourceType.Drive);
                    if (!String.IsNullOrEmpty(ud.Name))
                    {
                        driveAndDirTreeView.DoDragDrop(ud, DragDropEffects.All);
                    }
                }
            }
        }
Beispiel #5
0
        private void CheckDrop(TreeView targetTree, DragDropItem newPath, TreeNode selected)
        {
            // TODO: On Add check to make sure that the root (Or this) node have not already been covered.
            if (!String.IsNullOrEmpty(newPath.Name))
            {
                TreeNode tn = new TreeNode
                {
                    Text             = newPath.Name,
                    ImageKey         = newPath.Name,
                    SelectedImageKey = newPath.Name,
                    Name             = newPath.Name
                };

                //no node below?  stick this at the bottom of the list, else put in before the one your over.
                int index = (selected == null) ? targetTree.Nodes.Count - 1 : selected.Index;
                //we only ever want an entry in 1x in the list.  Remove any duplicates, so you can reorder from the filesystem treeview
                TreeNode[] nodes = targetTree.Nodes.Find(newPath.Name, false);
                if (nodes.Length > 0)
                {
                    if (nodes[0].Index < index)
                    {
                        targetTree.Nodes.Insert(index + 1, tn);
                        nodes[0].Remove();
                    }
                    else if (nodes[0].Index > index)
                    {
                        targetTree.Nodes.Insert(index, tn);
                        nodes[0].Remove();
                    }
                }
                else if (newPath.Source == DragDropItem.SourceType.Drive)
                {
                    targetTree.Nodes.Insert(index, tn);
                }
                targetTree.SelectedNode = tn;
                RestartExpectedOutput();
            }
        }