Skip to content

Commit feeb3e1

Browse files
authored
Merge pull request #288 from jeffsieu/folder-properties
Add folder properties to ribbon, right-click menu
2 parents d01f774 + af07b29 commit feeb3e1

File tree

6 files changed

+43
-18
lines changed

6 files changed

+43
-18
lines changed

Files/Controls/RibbonArea.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,12 @@
981981
</AppBarButton.Icon>
982982
</AppBarButton>
983983
<AppBarButton MinWidth="40" LabelPosition="{x:Bind RibbonViewModel.ItemLabelPosition, Mode=OneWay}" Style="{StaticResource AppBarButtonRevealStyle}" CornerRadius="2" Click="{x:Bind parentPage.instanceInteraction.OpenItem_Click}" x:Name="OpenWithButton" IsEnabled="{x:Bind parentPage.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Open With" Icon="OpenWith"/>
984+
<AppBarSeparator/>
985+
<AppBarButton MinWidth="40" LabelPosition="{x:Bind RibbonViewModel.ItemLabelPosition, Mode=OneWay}" Style="{StaticResource AppBarButtonRevealStyle}" CornerRadius="2" Click="{x:Bind parentPage.instanceInteraction.ShowFolderPropertiesButton_Click}" x:Name="ShowFolderPropertiesButton" IsEnabled="{x:Bind parentPage.AlwaysPresentCommands.isEnabled, Mode=OneWay}" Label="Folder Properties">
986+
<AppBarButton.Icon>
987+
<FontIcon Glyph="&#xE946;"/>
988+
</AppBarButton.Icon>
989+
</AppBarButton>
984990
</controls:RibbonPage.PageContent>
985991
</controls:RibbonPage>
986992
</Custom:TabViewItem>

Files/Filesystem/ItemViewModel.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,15 @@ public class ItemViewModel : INotifyPropertyChanged
3535
public EmptyFolderTextState EmptyTextState { get; set; } = new EmptyFolderTextState();
3636
public LoadingIndicator LoadIndicator { get; set; } = new LoadingIndicator();
3737
public ReadOnlyObservableCollection<ListedItem> FilesAndFolders { get; }
38+
public ListedItem currentFolder { get => _rootFolderItem; }
3839
public CollectionViewSource viewSource;
3940
public UniversalPath Universal { get; } = new UniversalPath();
4041
private ObservableCollection<ListedItem> _filesAndFolders;
4142
private StorageFolderQueryResult _folderQueryResult;
4243
public StorageFileQueryResult _fileQueryResult;
4344
private CancellationTokenSource _cancellationTokenSource;
4445
private StorageFolder _rootFolder;
46+
private ListedItem _rootFolderItem;
4547
private QueryOptions _options;
4648
private volatile bool _filesRefreshing;
4749
private const int _step = 250;
@@ -519,6 +521,21 @@ public async void AddItemsToCollectionAsync(string path)
519521
try
520522
{
521523
_rootFolder = await StorageFolder.GetFolderFromPathAsync(Universal.path);
524+
var rootFolderProperties = await _rootFolder.GetBasicPropertiesAsync();
525+
526+
_rootFolderItem = new ListedItem(_rootFolder.FolderRelativeId)
527+
{
528+
FileName = _rootFolder.Name,
529+
FileDateReal = rootFolderProperties.DateModified,
530+
FileType = "Folder", //TODO: Take a look at folder.DisplayType
531+
FolderImg = Visibility.Visible,
532+
FileImg = null,
533+
FileIconVis = Visibility.Collapsed,
534+
FilePath = _rootFolder.Path,
535+
EmptyImgVis = Visibility.Collapsed,
536+
FileSize = null,
537+
FileSizeBytes = 0
538+
};
522539

523540
App.OccupiedInstance.RibbonArea.Back.IsEnabled = App.OccupiedInstance.ItemDisplayFrame.CanGoBack;
524541
App.OccupiedInstance.RibbonArea.Forward.IsEnabled = App.OccupiedInstance.ItemDisplayFrame.CanGoForward;

Files/GenericFileBrowser.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@
6464
<FontIcon Glyph="&#xE8A5;"/>
6565
</MenuFlyoutItem.Icon>
6666
</MenuFlyoutItem>
67+
<MenuFlyoutSeparator/>
68+
<MenuFlyoutItem Text="Properties" Click="{x:Bind AssociatedInteractions.ShowFolderPropertiesButton_Click}" x:Name="PropertiesFolder">
69+
<MenuFlyoutItem.Icon>
70+
<FontIcon Glyph="&#xE946;"/>
71+
</MenuFlyoutItem.Icon>
72+
</MenuFlyoutItem>
6773
</MenuFlyoutSubItem>
6874
</MenuFlyout>
6975

Files/Interacts/Interaction.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,13 @@ public async void ShowPropertiesButton_Click(object sender, RoutedEventArgs e)
480480
await App.propertiesDialog.ShowAsync(ContentDialogPlacement.Popup);
481481
}
482482

483+
public async void ShowFolderPropertiesButton_Click(object sender, RoutedEventArgs e)
484+
{
485+
App.propertiesDialog.accessiblePropertiesFrame.Tag = App.propertiesDialog;
486+
App.propertiesDialog.accessiblePropertiesFrame.Navigate(typeof(Properties), App.OccupiedInstance.instanceViewModel.currentFolder, new SuppressNavigationTransitionInfo());
487+
await App.propertiesDialog.ShowAsync(ContentDialogPlacement.Popup);
488+
}
489+
483490
private async void Manager_DataRequested(DataTransferManager sender, DataRequestedEventArgs args)
484491
{
485492
DataRequestDeferral dataRequestDeferral = args.Request.GetDeferral();

Files/PhotoAlbum.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,12 @@
6767
</MenuFlyoutItem.Icon>
6868
</MenuFlyoutItem>
6969
</MenuFlyoutSubItem>
70+
<MenuFlyoutSeparator/>
71+
<MenuFlyoutItem Text="Properties" Click="{x:Bind AssociatedInteractions.ShowFolderPropertiesButton_Click}" x:Name="PropertiesFolder">
72+
<MenuFlyoutItem.Icon>
73+
<FontIcon Glyph="&#xE946;"/>
74+
</MenuFlyoutItem.Icon>
75+
</MenuFlyoutItem>
7076
</MenuFlyout>
7177

7278
<MenuFlyout Opening="RightClickContextMenu_Opening" x:Key="BaseLayoutItemContextFlyout">

Files/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)