Exemplo n.º 1
0
        public bool TryBrowseToPhysicalLocation(string path)
        {
            Pidl pidl;

            if (Pidl.TryParse(path, out pidl))
            {
                this.BrowseTo(pidl);
                pidl.Dispose();
                return(true);
            }
            return(false);
        }
Exemplo n.º 2
0
            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);
            }
Exemplo n.º 3
0
            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);
            }