/// <summary>
        /// Registers the neccesairy events
        /// </summary>
        /// <param name="br">The browser for which to support the ContextMenu</param>
        //public BrowserTVContextMenuWrapper(Browser_old2 br)
        public BrowserTVContextMenuWrapper(BrowserTreeView br)
        {
            this.br = br;

            br.FolderView.MouseUp += new System.Windows.Forms.MouseEventHandler(FolderView_MouseUp);
            br.FolderView.AfterLabelEdit += new NodeLabelEditEventHandler(FolderView_AfterLabelEdit);
            br.FolderView.BeforeLabelEdit += new NodeLabelEditEventHandler(FolderView_BeforeLabelEdit);
            br.FolderView.KeyDown += new KeyEventHandler(FolderView_KeyDown);

            this.CreateHandle(new CreateParams());
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Registers the TreeView for drag/drop operations and uses this class as the IDropTarget
        /// </summary>
        /// <param name="br">The browser for which to support the drop</param>
        public BrowserTVDropWrapper(BrowserTreeView br)
        {
            this.br = br;

            treeViewHandle = br.FolderView.Handle;
            ShellAPI.RegisterDragDrop(treeViewHandle, this);

            br.FolderView.HandleCreated += new EventHandler(FolderView_HandleCreated);
            br.FolderView.HandleDestroyed += new EventHandler(FolderView_HandleDestroyed);

            ShellHelper.GetIDropTargetHelper(out dropHelperPtr, out dropHelper);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Registers the TreeView.ItemDrag to receive the event when an item is being dragged
 /// </summary>
 /// <param name="br">The browser for which to support the drag</param>
 //public BrowserTVDragWrapper(Browser_old2 br)
 public BrowserTVDragWrapper(BrowserTreeView br)
 {
     this.br = br;
     br.FolderView.ItemDrag += new ItemDragEventHandler(ItemDrag);
 }
        /// <summary>
        /// When keys are pressed, this method will check for known key combinations. For example copy and past with
        /// Ctrl + C and Ctrl + V.
        /// </summary>
        /// 
        //public static void ProcessKeyCommands(Browser_old2 br, object sender, KeyEventArgs e)
        public static void ProcessKeyCommands(BrowserTreeView br, object sender, KeyEventArgs e)
        {
            if (e.Control && !e.Shift && !e.Alt)
            {
                switch (e.KeyCode)
                {
                    case Keys.C:
                    case Keys.Insert:
                    case Keys.V:
                    case Keys.X:
                        #region Copy/Paste/Cut
                        {
                            Cursor.Current = Cursors.WaitCursor;
                            IntPtr[] pidls;
                            ShellItem parent;

                            pidls = new IntPtr[1];
                            pidls[0] = br.SelectedItem.PIDLRel.Ptr;
                            parent = (br.SelectedItem.ParentItem != null ? br.SelectedItem.ParentItem : br.SelectedItem);

                            if (pidls.Length > 0)
                            {
                                string cmd;
                                if (e.KeyCode == Keys.C || e.KeyCode == Keys.Insert)
                                    cmd = "copy";
                                else if (e.KeyCode == Keys.V)
                                    cmd = "paste";
                                else
                                    cmd = "cut";

                                ContextMenuHelper.InvokeCommand(parent, pidls, cmd, new Point(0, 0));
                                Cursor.Current = Cursors.Default;
                            }
                            e.Handled = true;
                            e.SuppressKeyPress = true;
                        }
                        #endregion
                        break;

                    case Keys.N:
                        #region Create New Folder
                        if (!br.CreateNewFolder())
                            System.Media.SystemSounds.Beep.Play();

                        e.Handled = true;
                        e.SuppressKeyPress = true;
                        #endregion
                        break;

                    case Keys.Z:
                        break;

                    case Keys.Y:
                        break;
                }
            }
            else
            {
                switch (e.KeyCode)
                {
                    case Keys.Insert:
                        #region Paste
                        if (e.Shift && !e.Control && !e.Alt)
                        {
                            IntPtr[] pidls = new IntPtr[1];
                            pidls[0] = br.SelectedItem.PIDLRel.Ptr;
                            ShellItem parent = (br.SelectedItem.ParentItem != null ? br.SelectedItem.ParentItem : br.SelectedItem);
                            ContextMenuHelper.InvokeCommand(parent, pidls, "paste", new Point(0, 0));
                        }
                        e.Handled = true;
                        e.SuppressKeyPress = true;
                        #endregion
                        break;

                    case Keys.Delete:
                        #region Delete
                        if (!e.Control && !e.Alt)
                        {
                            IntPtr[] pidls;
                            ShellItem parent;
                            pidls = new IntPtr[1];
                            pidls[0] = br.SelectedItem.PIDLRel.Ptr;
                            parent = (br.SelectedItem.ParentItem != null ? br.SelectedItem.ParentItem : br.SelectedItem);

                            if (pidls.Length > 0)
                                ContextMenuHelper.InvokeCommand(parent, pidls, "delete", new Point(0, 0));
                        }
                        e.Handled = true;
                        e.SuppressKeyPress = true;
                        #endregion
                        break;

                    case Keys.F2:
                        #region Rename
                        if (sender.Equals(br.FolderView))
                        {
                            if (br.FolderView.SelectedNode != null)
                            {
                                br.FolderView.LabelEdit = true;
                                br.FolderView.SelectedNode.BeginEdit();
                            }
                        }
                        #endregion
                        break;

                    case Keys.Back:
                        #region Up
                        {
                            if (br.FolderView.SelectedNode != null && br.FolderView.SelectedNode.Parent != null)
                                br.FolderView.SelectedNode = br.FolderView.SelectedNode.Parent;
                        }
                        e.Handled = true;
                        e.SuppressKeyPress = true;
                        #endregion
                        break;
                }
            }
        }