Пример #1
0
 private void OnRightKeyDown(DirectoryListingPane pane)
 {
     if (pane.SelectedItem is FileViewModel)
     {
         // If a file is selected in this pane, try to move down (which should change the deeper panes)
         // and focus on the newly selected item
         if (pane.SelectedIndex < pane.Items.Count - 1)
         {
             pane.SelectItemAndFocus(pane.SelectedIndex + 1);
         }
     }
     else if (pane.SelectedItem is DirectoryViewModel)
     {
         // Go into the next pane, which is guaranteed to be open
         // bc the selected file system item in this pane is itself a directory
         var nextPane = (DirectoryListingPane)_panes[_panes.IndexOf(pane) + 1];
         if (nextPane.Items.Count > 0)
         {
             nextPane.SelectItemAndFocus(0);
         }
     }
     else if (pane.SelectedItem == null)
     {
         // If nothing is selected, then select the first item
         pane.SelectItemAndFocus(0);
     }
 }
Пример #2
0
        private bool OnDownKeyDown(DirectoryListingPane pane)
        {
            if (pane.SelectedItem == null)
            {
                // If nothing is selected, then select the first item
                pane.SelectItemAndFocus(0);
                return(true);
            }

            return(false);
        }
Пример #3
0
 private void OnLeftKeyDown(DirectoryListingPane pane)
 {
     if (_panes.IndexOf(pane) == 0)
     {
         // In the root directory pane, try to move up (which should close deeper panes if open)
         // and focus on the newly selected item
         // (Note: this is commented out because Finder doesn't do this)
         // if (pane.SelectedIndex > 0)
         //	pane.SelectItemAndFocus(pane.SelectedIndex - 1);
     }
     else
     {
         // If it's not the root pane, deselect everything in this pane (which should close deeper panes)
         // and focus on the selected item in the previous pane
         pane.SelectItem(-1);
         var previousPane = (DirectoryListingPane)_panes[_panes.IndexOf(pane) - 1];
         previousPane.FocusSelectedItem();
     }
 }
Пример #4
0
 private Tuple <int, IReadOnlyList <FileSystemItemViewModel> > GetLatestSelectedFiles(DirectoryListingPane directory)
 {
     return(Tuple.Create(_panes.IndexOf(directory), directory.SelectedItems.Cast <FileSystemItemViewModel>().ToReadOnlyList()));
 }
Пример #5
0
        private void PushPane(FileSystemItemViewModel item)
        {
            IFileSystemPane pane;

            switch (item)
            {
            case DirectoryViewModel directory:
                // Open directory listing pane
                var directoryPane = new DirectoryListingPane(directory);

                // Subscribe to events
                directoryPane.MouseDoubleClick += DirectoryListingPane_MouseDoubleClick;
                directoryPane.PreviewKeyDown   += DirectoryListingPane_PreviewKeyDown;
                directoryPane.KeyDown          += DirectoryListingPane_KeyDown;
                directoryPane.SelectionChanged += DirectoryListingPane_SelectionChanged;

                pane = directoryPane;

                // Add a breadcrumb
                if (_panes.Count > 0)
                {
                    StackPanelBreadcrumbs.Children.Add(new TextBlock {
                        Text              = ">",
                        Height            = 18,
                        VerticalAlignment = VerticalAlignment.Center,
                        Margin            = new Thickness(4, 0, 4, 0)
                    });
                }
                var breadcrumbIcon = new Image {
                    Source            = directory.Icon,
                    Width             = 18, Height = 18,                 // Smaller than the icons in the title bar and directory listings
                    VerticalAlignment = VerticalAlignment.Center
                };
                StackPanelBreadcrumbs.Children.Add(breadcrumbIcon);
                var breadcrumbTextBlock = new TextBlock {
                    Text              = directory.DisplayName,                // TODO: Use same ellipsis as in directory listing item
                    Height            = 18,
                    Margin            = new Thickness(4, 0, 0, 0),
                    VerticalAlignment = VerticalAlignment.Center
                };
                StackPanelBreadcrumbs.Children.Add(breadcrumbTextBlock);

                break;

            case FileViewModel file:
                // Open file preview pane
                pane = new FileInfoPane(file);
                break;

            default:
                throw new NotSupportedException($"{item.GetType()} doesn't have a corresponding Pane");
            }

            // Add a grid splitter for resizing if this isn't the first pane
            if (_panes.Count > 0)
            {
                AddGridSplitter(width: 5);
            }

            // Add the pane
            GridMain.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(260, GridUnitType.Pixel)                    // Panes' widths are in pixels, but resizable
            });
            Grid.SetColumn((UIElement)pane, GridMain.ColumnDefinitions.Count - 1); // Set column position in the main grid
            _panes.Add(pane);                                                      // Add to stack
            GridMain.Children.Add((UIElement)pane);                                // Add to main grid

            // Scroll to the end horizontally
            ScrollViewerMain.ScrollToRightEnd();
        }