Skip to content

Commit 51701eb

Browse files
committed
Add folder properties to ribbon, right-click menu
1 parent 0d90f42 commit 51701eb

File tree

8 files changed

+48
-22
lines changed

8 files changed

+48
-22
lines changed

Files UWP/Filesystem/ItemViewModel.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ namespace Files.Filesystem
3636
public class ItemViewModel : INotifyPropertyChanged
3737
{
3838
public ReadOnlyObservableCollection<ListedItem> FilesAndFolders { get; }
39+
public ListedItem currentFolder { get => _rootFolderItem; }
3940
public CollectionViewSource viewSource;
4041
public UniversalPath Universal { get; } = new UniversalPath();
4142
private ObservableCollection<ListedItem> _filesAndFolders;
4243
private StorageFolderQueryResult _folderQueryResult;
4344
public StorageFileQueryResult _fileQueryResult;
4445
private CancellationTokenSource _cancellationTokenSource;
4546
private StorageFolder _rootFolder;
47+
private ListedItem _rootFolderItem;
4648
private QueryOptions _options;
4749
private volatile bool _filesRefreshing;
4850
private const int _step = 250;
@@ -508,6 +510,21 @@ public async void AddItemsToCollectionAsync(string path)
508510
try
509511
{
510512
_rootFolder = await StorageFolder.GetFolderFromPathAsync(Universal.path);
513+
var rootFolderProperties = await _rootFolder.GetBasicPropertiesAsync();
514+
515+
_rootFolderItem = new ListedItem(_rootFolder.FolderRelativeId)
516+
{
517+
FileName = _rootFolder.Name,
518+
FileDateReal = rootFolderProperties.DateModified,
519+
FileType = "Folder", //TODO: Take a look at folder.DisplayType
520+
FolderImg = Visibility.Visible,
521+
FileImg = null,
522+
FileIconVis = Visibility.Collapsed,
523+
FilePath = _rootFolder.Path,
524+
EmptyImgVis = Visibility.Collapsed,
525+
FileSize = null,
526+
FileSizeBytes = 0
527+
};
511528

512529
App.selectedTabInstance.BackButton.IsEnabled = App.selectedTabInstance.accessibleContentFrame.CanGoBack;
513530
App.selectedTabInstance.ForwardButton.IsEnabled = App.selectedTabInstance.accessibleContentFrame.CanGoForward;

Files UWP/GenericFileBrowser.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@
208208
</MenuFlyoutItem.Icon>
209209
</MenuFlyoutItem>
210210
</MenuFlyoutSubItem>
211+
<MenuFlyoutSeparator/>
212+
<MenuFlyoutItem Text="Properties" x:Name="PropertiesFolder">
213+
<MenuFlyoutItem.Icon>
214+
<FontIcon Glyph="&#xE946;"/>
215+
</MenuFlyoutItem.Icon>
216+
</MenuFlyoutItem>
211217
</MenuFlyout>
212218
</Grid.ContextFlyout>
213219
<ProgressBar x:Name="progBar" Height="10" VerticalAlignment="Top" IsIndeterminate="True"/>

Files UWP/GenericFileBrowser.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public GenericFileBrowser()
113113
NewTextDocument.Click += tabInstance.instanceInteraction.NewTextDocument_Click;
114114
UnzipItem.Click += tabInstance.instanceInteraction.ExtractItems_Click;
115115
PropertiesItem.Click += tabInstance.ShowPropertiesButton_Click;
116+
PropertiesFolder.Click += tabInstance.ShowFolderPropertiesButton_Click;
116117
OpenInNewWindowItem.Click += tabInstance.instanceInteraction.OpenInNewWindowItem_Click;
117118

118119
switch (viewModelInstance.DirectorySortOption)

Files UWP/PhotoAlbum.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,12 @@
438438
</MenuFlyoutItem.Icon>
439439
</MenuFlyoutItem>
440440
</MenuFlyoutSubItem>
441+
<MenuFlyoutSeparator/>
442+
<MenuFlyoutItem Text="Properties" x:Name="PropertiesFolder">
443+
<MenuFlyoutItem.Icon>
444+
<FontIcon Glyph="&#xE946;"/>
445+
</MenuFlyoutItem.Icon>
446+
</MenuFlyoutItem>
441447
</MenuFlyout.Items>
442448
</MenuFlyout>
443449
</Grid.ContextFlyout>

Files UWP/PhotoAlbum.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public PhotoAlbum()
7777
NewBitmapImage.Click += tabInstance.instanceInteraction.NewBitmapImage_Click;
7878
NewTextDocument.Click += tabInstance.instanceInteraction.NewTextDocument_Click;
7979
UnzipItem.Click += tabInstance.instanceInteraction.ExtractItems_Click;
80-
80+
PropertiesFolder.Click += tabInstance.ShowFolderPropertiesButton_Click;
8181
}
8282

8383
protected override void OnNavigatedTo(NavigationEventArgs eventArgs)

Files UWP/ProHome.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,12 @@
663663
</AppBarButton.Icon>
664664
</AppBarButton>
665665
<AppBarButton Click="OpenWithButton_Click" Name="OpenWithButton" IsEnabled="{x:Bind HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Open With" Icon="OpenWith"/>
666+
<AppBarSeparator/>
667+
<AppBarButton Click="ShowFolderPropertiesButton_Click" Name="ShowFolderPropertiesButton" IsEnabled="{x:Bind AlwaysPresentCommands.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Folder Properties">
668+
<AppBarButton.Icon>
669+
<FontIcon Glyph="&#xE946;"/>
670+
</AppBarButton.Icon>
671+
</AppBarButton>
666672
</CommandBar>
667673
</CommandBar.Content>
668674
</CommandBar>

Files UWP/ProHome.xaml.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -642,22 +642,29 @@ private void ClearAllButton_Click(object sender, RoutedEventArgs e)
642642
}
643643
}
644644

645-
646645
public async void ShowPropertiesButton_Click(object sender, RoutedEventArgs e)
647646
{
648647
if (this.accessibleContentFrame.SourcePageType == typeof(GenericFileBrowser))
649648
{
650649
propertiesDialog.accessiblePropertiesFrame.Tag = propertiesDialog;
651-
propertiesDialog.accessiblePropertiesFrame.Navigate(typeof(Properties), (App.selectedTabInstance.accessibleContentFrame.Content as GenericFileBrowser).data.SelectedItems, new SuppressNavigationTransitionInfo());
650+
propertiesDialog.accessiblePropertiesFrame.Navigate(typeof(Properties), (App.selectedTabInstance.accessibleContentFrame.Content as GenericFileBrowser).data.SelectedItem, new SuppressNavigationTransitionInfo());
652651
}
653652
else if (this.accessibleContentFrame.SourcePageType == typeof(PhotoAlbum))
654653
{
655654
propertiesDialog.accessiblePropertiesFrame.Tag = propertiesDialog;
656-
propertiesDialog.accessiblePropertiesFrame.Navigate(typeof(Properties), (App.selectedTabInstance.accessibleContentFrame.Content as PhotoAlbum).gv.SelectedItems, new SuppressNavigationTransitionInfo());
655+
propertiesDialog.accessiblePropertiesFrame.Navigate(typeof(Properties), (App.selectedTabInstance.accessibleContentFrame.Content as PhotoAlbum).gv.SelectedItem, new SuppressNavigationTransitionInfo());
657656
}
658657
await propertiesDialog.ShowAsync(ContentDialogPlacement.Popup);
659658
}
660659

660+
public async void ShowFolderPropertiesButton_Click(object sender, RoutedEventArgs e)
661+
{
662+
propertiesDialog.accessiblePropertiesFrame.Tag = propertiesDialog;
663+
propertiesDialog.accessiblePropertiesFrame.Navigate(typeof(Properties), App.selectedTabInstance.instanceViewModel.currentFolder, new SuppressNavigationTransitionInfo());
664+
665+
await propertiesDialog.ShowAsync(ContentDialogPlacement.Popup);
666+
}
667+
661668
private void RibbonTip_Loaded(object sender, RoutedEventArgs e)
662669
{
663670
if (ApplicationData.Current.LocalSettings.Values["HasBeenWelcomed"] == null)

Files UWP/Properties.xaml.cs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,5 @@
11
using Files.Filesystem;
2-
using Files.Interacts;
3-
using System;
4-
using System.Collections;
5-
using System.Collections.Generic;
6-
using System.Collections.ObjectModel;
7-
using System.IO;
8-
using System.Linq;
9-
using System.Runtime.InteropServices.WindowsRuntime;
10-
using Windows.Foundation;
11-
using Windows.Foundation.Collections;
12-
using Windows.UI.Xaml;
132
using Windows.UI.Xaml.Controls;
14-
using Windows.UI.Xaml.Controls.Primitives;
15-
using Windows.UI.Xaml.Data;
16-
using Windows.UI.Xaml.Input;
17-
using Windows.UI.Xaml.Media;
183
using Windows.UI.Xaml.Navigation;
194

205
namespace Files
@@ -31,9 +16,7 @@ public Properties()
3116

3217
protected override void OnNavigatedTo(NavigationEventArgs e)
3318
{
34-
var result = e.Parameter as IEnumerable;
35-
IList<ListedItem> listedItems = result.OfType<ListedItem>().ToList();
36-
Item = listedItems[0];
19+
Item = e.Parameter as ListedItem;
3720
PropertiesDialog = Frame.Tag as ContentDialog;
3821
base.OnNavigatedTo(e);
3922
}

0 commit comments

Comments
 (0)