Skip to content

Commit 186dd9f

Browse files
lukeblukeb
authored andcommitted
Hook up some ribbon commands
1 parent 3b7d3b1 commit 186dd9f

File tree

7 files changed

+141
-23
lines changed

7 files changed

+141
-23
lines changed

Files UWP/GenericFileBrowser.xaml.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using Files.Navigation;
1111
using Files.Interacts;
1212
using System.Diagnostics;
13+
using Windows.UI.Core;
1314

1415
namespace Files
1516
{
@@ -60,6 +61,10 @@ public GenericFileBrowser()
6061
//PathBarTip.IsOpen = true;
6162
}
6263

64+
private void SelectAllAcceleratorDG_Invoked(Windows.UI.Xaml.Input.KeyboardAccelerator sender, Windows.UI.Xaml.Input.KeyboardAcceleratorInvokedEventArgs args)
65+
{
66+
}
67+
6368
private void AddItem_Click(object sender, RoutedEventArgs e)
6469
{
6570
//await AddDialog.ShowAsync();
@@ -259,6 +264,7 @@ private void AllView_DragLeave(object sender, DragEventArgs e)
259264
{
260265

261266
}
267+
262268
}
263269

264270
public class EmptyFolderTextState : INotifyPropertyChanged

Files UWP/Interacts/Interaction.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ private async static void Manager_DataRequested(DataTransferManager sender, Data
447447
List<IStorageItem> items = new List<IStorageItem>();
448448
if(page.Name == "GenericItemView")
449449
{
450-
foreach (ListedItem li in dataGrid.SelectedItems)
450+
foreach (ListedItem li in GenericFileBrowser.data.SelectedItems)
451451
{
452452
if (li.FileType == "Folder")
453453
{
@@ -863,5 +863,23 @@ public static async void CloneDirectoryAsync(string SourcePath, string Destinati
863863
}
864864
}
865865
}
866+
867+
public static void SelectAllItems()
868+
{
869+
if(page.Name == "GenericItemView")
870+
{
871+
foreach(ListedItem li in GenericFileBrowser.data.ItemsSource)
872+
{
873+
if (!GenericFileBrowser.data.SelectedItems.Contains(li))
874+
{
875+
GenericFileBrowser.data.SelectedItems.Add(li);
876+
}
877+
}
878+
}
879+
else if(page.Name == "PhotoAlbumViewer")
880+
{
881+
PhotoAlbum.gv.SelectAll();
882+
}
883+
}
866884
}
867885
}

Files UWP/PhotoAlbum.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@
397397
</Grid.ContextFlyout>
398398
<TextBlock Name="EmptyText" Visibility="{x:Bind local:App.ViewModel.TextState.isVisible, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" HorizontalAlignment="Center" Text="This folder is empty." TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,125,0,0" Grid.Row="3" Canvas.ZIndex="0"/>
399399

400-
<controls:AdaptiveGridView animations:ReorderGridAnimation.Duration="300" ShowsScrollingPlaceholders="True" Margin="24,24,24,0" Grid.Row="3" SelectionMode="Single" IsDoubleTapEnabled="True" IsRightTapEnabled="True" ItemsSource="{x:Bind local:App.ViewModel.FilesAndFolders}" Name="FileList" Padding="0, 0, 0, 0" >
400+
<controls:AdaptiveGridView animations:ReorderGridAnimation.Duration="300" ShowsScrollingPlaceholders="True" Margin="24,24,24,0" Grid.Row="3" SelectionMode="Extended" IsDoubleTapEnabled="True" IsRightTapEnabled="True" ItemsSource="{x:Bind local:App.ViewModel.FilesAndFolders}" Name="FileList" Padding="0, 0, 0, 0" >
401401
<controls:AdaptiveGridView.Resources>
402402
<MenuFlyout x:Name="RightClickContextMenu" x:Key="RightClickFlyout">
403403
<MenuFlyout.Items>

Files UWP/ProHome.xaml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
44
xmlns:local="using:Files"
55
xmlns:local1="using:Files.Interacts.Home"
6+
xmlns:local2="using:Files.Interacts"
67
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
78
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
89
xmlns:Custom="using:Microsoft.Toolkit.Uwp.UI.Controls"
@@ -884,7 +885,7 @@
884885
<CommandBar.Content>
885886
<CommandBar Background="Transparent" OverflowButtonVisibility="Collapsed" DefaultLabelPosition="Right">
886887
<AppBarButton Label="Open new window" Icon="NewWindow"/>
887-
<AppBarButton Label="Settings" Icon="Setting"/>
888+
<AppBarButton Name="SettingsButton" Click="SettingsButton_Click" Label="Settings" Icon="Setting"/>
888889
</CommandBar>
889890
</CommandBar.Content>
890891
</CommandBar>
@@ -893,25 +894,25 @@
893894
<CommandBar Background="Transparent" OverflowButtonVisibility="Collapsed" DefaultLabelPosition="Right">
894895
<CommandBar.Content>
895896
<CommandBar Background="Transparent" OverflowButtonVisibility="Collapsed" DefaultLabelPosition="Right">
896-
<AppBarButton IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Cut" Icon="Cut"/>
897-
<AppBarButton IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Copy" Icon="Copy"/>
898-
<AppBarButton IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Paste" Icon="Paste"/>
899-
<AppBarButton IsEnabled="{x:Bind local:App.AlwaysPresentCommands.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Copy Path">
897+
<AppBarButton Click="CutButton_Click" Name="CutButton" IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Cut" Icon="Cut"/>
898+
<AppBarButton Click="CopyButton_Click" Name="CopyButton" IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Copy" Icon="Copy"/>
899+
<AppBarButton Click="PasteButton_Click" Name="PasteButton" IsEnabled="{x:Bind local2:Interaction.PS.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Paste" Icon="Paste"/>
900+
<AppBarButton Click="CopyPathButton_Click" Name="CopyPathButton" IsEnabled="{x:Bind local:App.AlwaysPresentCommands.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Copy Path">
900901
<AppBarButton.Icon>
901902
<FontIcon Glyph="&#xF271;" FontFamily="Segoe MDL2 Assets"/>
902903
</AppBarButton.Icon>
903904
</AppBarButton>
904905
<AppBarSeparator/>
905-
<AppBarButton IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Delete" Icon="Delete"/>
906-
<AppBarButton IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Rename" Icon="Rename"/>
907-
<AppBarButton Name="AddItem" IsEnabled="{x:Bind local:App.AlwaysPresentCommands.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Add Item" Icon="Add"/>
906+
<AppBarButton Click="DeleteButton_Click" Name="DeleteButton" IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Delete" Icon="Delete"/>
907+
<AppBarButton Click="RenameButton_Click" Name="RenameButton" IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Rename" Icon="Rename"/>
908+
<AppBarButton Click="AddItem_Click" Name="AddItem" IsEnabled="{x:Bind local:App.AlwaysPresentCommands.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Add Item" Icon="Add"/>
908909
<AppBarSeparator/>
909910
<AppBarButton IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Properties">
910911
<AppBarButton.Icon>
911912
<FontIcon Glyph="&#xE946;"/>
912913
</AppBarButton.Icon>
913914
</AppBarButton>
914-
<AppBarButton IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Open With" Icon="OpenWith"/>
915+
<AppBarButton Click="OpenWithButton_Click" Name="OpenWithButton" IsEnabled="{x:Bind local:App.HomeItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Open With" Icon="OpenWith"/>
915916
</CommandBar>
916917
</CommandBar.Content>
917918
</CommandBar>
@@ -920,7 +921,7 @@
920921
<CommandBar Background="Transparent" OverflowButtonVisibility="Collapsed" DefaultLabelPosition="Right">
921922
<CommandBar.Content>
922923
<CommandBar Background="Transparent" OverflowButtonVisibility="Collapsed" DefaultLabelPosition="Right">
923-
<AppBarButton IsEnabled="{x:Bind local:App.ShareItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Share" Icon="Share"/>
924+
<AppBarButton Click="ShareButton_Click" Name="ShareButton" IsEnabled="{x:Bind local:App.ShareItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Share" Icon="Share"/>
924925
</CommandBar>
925926
</CommandBar.Content>
926927
</CommandBar>
@@ -929,13 +930,18 @@
929930
<CommandBar Background="Transparent" OverflowButtonVisibility="Collapsed" DefaultLabelPosition="Right">
930931
<CommandBar.Content>
931932
<CommandBar Background="Transparent" OverflowButtonVisibility="Collapsed" DefaultLabelPosition="Right">
932-
<AppBarButton IsEnabled="{x:Bind local:App.LayoutItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Layout Mode">
933+
<AppBarButton Click="LayoutButton_Click" Name="LayoutButton" IsEnabled="{x:Bind local:App.LayoutItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Label="Layout Mode">
933934
<AppBarButton.Icon>
934935
<FontIcon Glyph="&#xF246;" FontFamily="Segoe MDL2 Assets"/>
935936
</AppBarButton.Icon>
936937
</AppBarButton>
937-
<AppBarButton IsEnabled="{x:Bind local:App.LayoutItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Icon="SelectAll" Label="Select All"/>
938-
<AppBarButton IsEnabled="{x:Bind local:App.LayoutItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Icon="ClearSelection" Label="Clear All"/>
938+
<AppBarButton Click="SelectAllButton_Click" Name="SelectAllButton" IsEnabled="{x:Bind local:App.LayoutItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Icon="SelectAll" Label="Select All">
939+
<AppBarButton.KeyboardAccelerators>
940+
<KeyboardAccelerator Modifiers="Control" Key="A"/>
941+
</AppBarButton.KeyboardAccelerators>
942+
</AppBarButton>
943+
<AppBarButton Click="ClearAllButton_Click" Name="ClearAllButton" IsEnabled="{x:Bind local:App.LayoutItems.isEnabled, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" Icon="ClearSelection" Label="Clear All"/>
944+
939945
</CommandBar>
940946
</CommandBar.Content>
941947
</CommandBar>

Files UWP/ProHome.xaml.cs

Lines changed: 93 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,28 @@ private async void VisiblePath_TextChanged(object sender, KeyRoutedEventArgs e)
271271
}
272272
else if (StorageFolder.GetFolderFromPathAsync(CurrentInput) != null)
273273
{
274-
await StorageFolder.GetFolderFromPathAsync(CurrentInput);
275-
App.ViewModel.TextState.isVisible = Visibility.Collapsed;
276-
ProHome.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), CurrentInput);
274+
try
275+
{
276+
await StorageFolder.GetFolderFromPathAsync(CurrentInput);
277+
App.ViewModel.TextState.isVisible = Visibility.Collapsed;
278+
ProHome.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), CurrentInput);
279+
}
280+
catch (ArgumentException)
281+
{
282+
MessageDialog dialog = new MessageDialog("The path typed was not correct. Please try again.", "Invalid Path");
283+
await dialog.ShowAsync();
284+
}
285+
catch (FileNotFoundException)
286+
{
287+
MessageDialog dialog = new MessageDialog("The path typed was not correct. Please try again.", "Invalid Path");
288+
await dialog.ShowAsync();
289+
}
290+
catch (System.Exception)
291+
{
292+
MessageDialog dialog = new MessageDialog("The path typed was not correct. Please try again.", "Invalid Path");
293+
await dialog.ShowAsync();
294+
}
295+
277296
}
278297
else
279298
{
@@ -299,6 +318,11 @@ private async void VisiblePath_TextChanged(object sender, KeyRoutedEventArgs e)
299318
MessageDialog dialog = new MessageDialog("The path typed was not correct. Please try again.", "Invalid Path");
300319
await dialog.ShowAsync();
301320
}
321+
catch (System.Exception)
322+
{
323+
MessageDialog dialog = new MessageDialog("The path typed was not correct. Please try again.", "Invalid Path");
324+
await dialog.ShowAsync();
325+
}
302326
}
303327
}
304328
else
@@ -592,5 +616,71 @@ private void DrivesList_SelectionChanged(object sender, SelectionChangedEventArg
592616
locationsList.SelectedItem = null;
593617
}
594618
}
619+
620+
private void SettingsButton_Click(object sender, RoutedEventArgs e)
621+
{
622+
Frame rootFrame = Window.Current.Content as Frame;
623+
rootFrame.Navigate(typeof(Settings));
624+
}
625+
626+
private void CutButton_Click(object sender, RoutedEventArgs e)
627+
{
628+
Interaction.CutItem_Click(null, null);
629+
}
630+
631+
private void CopyButton_Click(object sender, RoutedEventArgs e)
632+
{
633+
Interaction.CopyItem_ClickAsync(null, null);
634+
}
635+
636+
private void PasteButton_Click(object sender, RoutedEventArgs e)
637+
{
638+
Interaction.PasteItem_ClickAsync(null, null);
639+
}
640+
641+
private void CopyPathButton_Click(object sender, RoutedEventArgs e)
642+
{
643+
Interaction.GetPath_Click(null, null);
644+
}
645+
646+
private void DeleteButton_Click(object sender, RoutedEventArgs e)
647+
{
648+
Interaction.DeleteItem_Click(null, null);
649+
}
650+
651+
private void RenameButton_Click(object sender, RoutedEventArgs e)
652+
{
653+
Interaction.RenameItem_Click(null, null);
654+
}
655+
656+
private async void AddItem_Click(object sender, RoutedEventArgs e)
657+
{
658+
await ProHome.AddItemBox.ShowAsync();
659+
}
660+
661+
private void OpenWithButton_Click(object sender, RoutedEventArgs e)
662+
{
663+
Interaction.OpenItem_Click(null, null);
664+
}
665+
666+
private void ShareButton_Click(object sender, RoutedEventArgs e)
667+
{
668+
Interaction.ShareItem_Click(null, null);
669+
}
670+
671+
private void LayoutButton_Click(object sender, RoutedEventArgs e)
672+
{
673+
674+
}
675+
676+
private void SelectAllButton_Click(object sender, RoutedEventArgs e)
677+
{
678+
Interaction.SelectAllItems();
679+
}
680+
681+
private void ClearAllButton_Click(object sender, RoutedEventArgs e)
682+
{
683+
684+
}
595685
}
596686
}

Files UWP/Settings.xaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@
1515
</Page.Resources>
1616

1717
<Grid>
18-
<Grid Tag="{x:Bind Tag, Mode=OneWay}" Background="Transparent" Name="DragArea" HorizontalAlignment="Stretch" Height="34" VerticalAlignment="Top" Margin="0,0,200,0" Canvas.ZIndex="5"/>
19-
2018
<UILib:NavigationView IsSettingsVisible="False" BackRequested="SettingsPane_BackRequested" Name="SettingsPane" IsBackEnabled="True" ItemInvoked="NavigationView_ItemInvoked" PaneTitle="Settings" PaneDisplayMode="Top">
2119
<UILib:NavigationView.MenuItems>
22-
<UILib:NavigationViewItem Content="Personalization"/>
20+
<UILib:NavigationViewItem IsSelected="True" Content="Personalization"/>
2321
<UILib:NavigationViewItem Content="Preferences"/>
2422
<UILib:NavigationViewItem Content="About"/>
2523
</UILib:NavigationView.MenuItems>

Files UWP/Settings.xaml.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public Settings()
1414
{
1515
this.InitializeComponent();
1616
var CoreTitleBar = CoreApplication.GetCurrentView().TitleBar;
17-
CoreTitleBar.ExtendViewIntoTitleBar = true;
18-
Window.Current.SetTitleBar(DragArea);
17+
CoreTitleBar.ExtendViewIntoTitleBar = false;
18+
//Window.Current.SetTitleBar(DragArea);
1919
SettingsContentFrame.Navigate(typeof(Personalization));
2020
}
2121

0 commit comments

Comments
 (0)