protected override void OnKeyDown(KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { if (this.SelectedItems != null && this.SelectedItems.Count > 0) { try { FolderListViewItem item = (FolderListViewItem)this.FocusedItem; if (item != null) { var pidl = item.Pidl.Clone(); try { if (DereferenceLinks && pidl.IsLink) { // attempt to resolve links first if necessary string resolvedPath; Pidl resolvedPidl; if (ShellItem.TryResolveLink(Handle, pidl.Path, out resolvedPath) && Pidl.TryParse(resolvedPath, out resolvedPidl)) { pidl.Dispose(); pidl = resolvedPidl; } } var handled = false; var control = Parent as FolderView; if (control != null) { var args = new FolderViewItemEventArgs(new FolderViewItem(pidl)); control.OnItemKeyEnterPressed(args); handled = args.Handled; } if (AutoDrillDown && pidl.IsFolder && !handled) { // if the user pressed ENTER on a folder item, perform a drill down Browse(new ShellItem(pidl, _rootShellItem, false)); } } finally { pidl.Dispose(); } } } catch (Exception ex) { HandleBrowseException(ex); } } e.Handled = true; e.SuppressKeyPress = true; } base.OnKeyDown(e); }
protected override void OnDoubleClick(EventArgs e) { if (this.SelectedItems != null && this.SelectedItems.Count > 0) { try { Point point = this.PointToClient(Cursor.Position); FolderListViewItem item = (FolderListViewItem)this.GetItemAt(point.X, point.Y); if (item != null) { var pidl = item.Pidl.Clone(); try { if (DereferenceLinks && pidl.IsLink) { // attempt to resolve links first if necessary string resolvedPath; Pidl resolvedPidl; if (ShellItem.TryResolveLink(Handle, pidl.Path, out resolvedPath) && Pidl.TryParse(resolvedPath, out resolvedPidl)) { pidl.Dispose(); pidl = resolvedPidl; } } var handled = false; var control = Parent as FolderView; if (control != null) { var args = new FolderViewItemEventArgs(new FolderViewItem(pidl)); control.OnItemDoubleClick(args); handled = args.Handled; } if (AutoDrillDown && pidl.IsFolder && !handled) { // if the user double clicked on a folder item, perform a drill down Browse(new ShellItem(pidl, _rootShellItem, false)); } } finally { pidl.Dispose(); } } } catch (Exception ex) { HandleBrowseException(ex); } } base.OnDoubleClick(e); }
public string GetPath(IntPtr hWnd, bool resolveLinks) { if (resolveLinks && IsLink) { string resolvedPath; if (ShellItem.TryResolveLink(hWnd, Path, out resolvedPath)) { return(resolvedPath); } } return(Path); }