Skip to content

Commit 69a015b

Browse files
committed
Allowed PhotoAlbum Experience to Respond to User Click Events
1 parent 704a90e commit 69a015b

File tree

5 files changed

+157
-31
lines changed

5 files changed

+157
-31
lines changed

GenericFileBrowser.xaml.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public GenericFileBrowser()
6767
Forward.Click += Navigation.NavigationActions.Forward_Click;
6868
Refresh.Click += Navigation.NavigationActions.Refresh_Click;
6969
AllView.SelectionChanged += Interact.Interaction.List_ItemClick;
70+
7071
}
7172

7273
public static UniversalPath p = new UniversalPath();

ItemInteractions.cs

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,12 @@ public static async void List_ItemClick(object sender, SelectionChangedEventArgs
8181

8282
}
8383

84-
public static void PhotoAlbumItemList_Click(object sender, ItemClickEventArgs e)
84+
public static async void PhotoAlbumItemList_ClickAsync(object sender, ItemClickEventArgs e)
8585
{
86-
var index = PhotoAlbum.gv.SelectedIndex;
86+
GridView grid = sender as GridView;
87+
var index = grid.Items.IndexOf(e.ClickedItem);
8788
var clickedOnItem = ItemViewModel.FilesAndFolders[index];
89+
8890
Debug.WriteLine("Reached PhotoAlbumViewer event");
8991

9092
if (clickedOnItem.FileExtension == "Folder")
@@ -101,15 +103,15 @@ public static void PhotoAlbumItemList_Click(object sender, ItemClickEventArgs e)
101103
}
102104
else
103105
{
104-
/* StorageFile file = await StorageFile.GetFileFromPathAsync(clickedOnItem.FilePath);
106+
StorageFile file = await StorageFile.GetFileFromPathAsync(clickedOnItem.FilePath);
105107
var options = new LauncherOptions();
106108
options.DisplayApplicationPicker = true;
107-
await Launcher.LaunchFileAsync(file, options); */
108-
var uri = new Uri(clickedOnItem.FilePath);
109-
BitmapImage bitmap = new BitmapImage();
110-
bitmap.UriSource = uri;
111-
LIS.image = bitmap;
112-
PhotoAlbum.largeImg.Source = bitmap;
109+
await Launcher.LaunchFileAsync(file, options);
110+
//var uri = new Uri(clickedOnItem.FilePath);
111+
//BitmapImage bitmap = new BitmapImage();
112+
//bitmap.UriSource = uri;
113+
//LIS.image = bitmap;
114+
//PhotoAlbum.largeImg.Source = bitmap;
113115
}
114116
}
115117

@@ -121,6 +123,12 @@ public static void AllView_RightTapped(object sender, RightTappedRoutedEventArgs
121123

122124
}
123125

126+
public static void FileList_RightTapped(object sender, RightTappedRoutedEventArgs e)
127+
{
128+
GridView gridView = sender as GridView;
129+
PhotoAlbum.context.ShowAt(gridView, e.GetPosition(gridView));
130+
}
131+
124132
public static async void OpenItem_Click(object sender, RoutedEventArgs e)
125133
{
126134
var ItemInvoked = sender as DataGridRow;

NavigationSystem.cs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,82 @@ public static void Refresh_Click(object sender, RoutedEventArgs e)
232232
}
233233
}
234234

235+
public class PhotoAlbumNavActions
236+
{
237+
public static void Back_Click(object sender, RoutedEventArgs e)
238+
{
239+
if (ItemViewModel.IsTerminated == false)
240+
{
241+
ItemViewModel.IsStopRequested = true;
242+
}
243+
244+
if (History.HistoryList.Count() > 1)
245+
{
246+
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
247+
Debug.WriteLine("\nBefore Removals");
248+
ArrayDiag.DumpArray();
249+
History.AddToForwardList(History.HistoryList[History.HistoryList.Count() - 1]);
250+
History.HistoryList.RemoveAt(History.HistoryList.Count() - 1);
251+
Debug.WriteLine("\nAfter Removals");
252+
ArrayDiag.DumpArray();
253+
ItemViewModel.ViewModel = new ItemViewModel(History.HistoryList[History.HistoryList.Count() - 1], true); // To take into account the correct index without interference from the folder being navigated to
254+
ItemViewModel.FilesAndFolders.Clear();
255+
GenericFileBrowser.P.path = History.HistoryList[History.HistoryList.Count() - 1];
256+
GenericFileBrowser.UpdateAllBindings();
257+
258+
if (History.ForwardList.Count == 0)
259+
{
260+
ItemViewModel.FS.isEnabled = false;
261+
}
262+
else if (History.ForwardList.Count > 0)
263+
{
264+
ItemViewModel.FS.isEnabled = true;
265+
}
266+
267+
268+
}
269+
270+
}
271+
272+
public static void Forward_Click(object sender, RoutedEventArgs e)
273+
{
274+
if (ItemViewModel.IsTerminated == false)
275+
{
276+
ItemViewModel.IsStopRequested = true;
277+
}
278+
279+
if (History.ForwardList.Count() > 0)
280+
{
281+
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
282+
ItemViewModel.ViewModel = new ItemViewModel(History.ForwardList[History.ForwardList.Count() - 1], true); // To take into account the correct index without interference from the folder being navigated to
283+
ItemViewModel.FilesAndFolders.Clear();
284+
GenericFileBrowser.P.path = History.ForwardList[History.ForwardList.Count() - 1];
285+
History.ForwardList.RemoveAt(History.ForwardList.Count() - 1);
286+
GenericFileBrowser.UpdateAllBindings();
287+
ArrayDiag.DumpForwardArray();
288+
289+
if (History.ForwardList.Count == 0)
290+
{
291+
ItemViewModel.FS.isEnabled = false;
292+
}
293+
else if (History.ForwardList.Count > 0)
294+
{
295+
ItemViewModel.FS.isEnabled = true;
296+
}
297+
298+
}
299+
}
300+
301+
public static void Refresh_Click(object sender, RoutedEventArgs e)
302+
{
303+
ItemViewModel.TextState.isVisible = Visibility.Collapsed;
304+
ItemViewModel.FilesAndFolders.Clear();
305+
ItemViewModel.ViewModel = new ItemViewModel(ItemViewModel.PUIP.Path, true);
306+
GenericFileBrowser.P.path = ItemViewModel.PUIP.Path;
307+
GenericFileBrowser.UpdateAllBindings();
308+
}
309+
}
310+
235311
public class UniversalPath : INotifyPropertyChanged
236312
{
237313

PhotoAlbum.xaml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
xmlns:local="using:Files"
1818
xmlns:local1="using:Navigation"
1919
xmlns:local2="using:ItemListPresenter"
20+
xmlns:local3="using:Interact"
2021
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
2122
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
2223
xmlns:controls="using:Microsoft.Toolkit.Uwp.UI.Controls"
@@ -119,8 +120,59 @@
119120
</ScrollViewer>
120121

121122
</Grid>
122-
<GridView Background="White" ItemsSource="{x:Bind local2:ItemViewModel.FilesAndFolders}" Name="FileList" Padding="15, 0, 0, 0" Margin="0,200,0,0" Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
123-
123+
<GridView IsRightTapEnabled="True" IsItemClickEnabled="True" Background="White" ItemsSource="{x:Bind local2:ItemViewModel.FilesAndFolders}" Name="FileList" Padding="0, 0, 0, 0" Margin="40,200,40,0" Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" >
124+
<GridView.Resources>
125+
<MenuFlyout x:Name="RightClickContextMenu" x:Key="RightClickFlyout">
126+
<MenuFlyout.Items>
127+
<MenuFlyoutItem Text="Open" Name="OpenItem">
128+
<MenuFlyoutItem.Icon>
129+
<FontIcon Glyph="&#xE7AC;"/>
130+
</MenuFlyoutItem.Icon>
131+
</MenuFlyoutItem>
132+
133+
<MenuFlyoutItem Text="Share" Name="ShareItem">
134+
<MenuFlyoutItem.Icon>
135+
<FontIcon Glyph="&#xE72D;"/>
136+
</MenuFlyoutItem.Icon>
137+
</MenuFlyoutItem>
138+
<MenuFlyoutItem Text="Scan with Windows Defender..." Name="ScanItem" >
139+
<MenuFlyoutItem.Icon>
140+
<FontIcon Glyph="&#xE83D;"/>
141+
</MenuFlyoutItem.Icon>
142+
</MenuFlyoutItem>
143+
<MenuFlyoutSeparator/>
144+
<MenuFlyoutItem Text="Delete" Name="DeleteItem" >
145+
<MenuFlyoutItem.Icon>
146+
<FontIcon Glyph="&#xE74D;"/>
147+
</MenuFlyoutItem.Icon>
148+
</MenuFlyoutItem>
149+
<MenuFlyoutItem Text="Rename" Name="RenameItem" >
150+
<MenuFlyoutItem.Icon>
151+
<FontIcon Glyph="&#xE8AC;"/>
152+
</MenuFlyoutItem.Icon>
153+
</MenuFlyoutItem>
154+
<MenuFlyoutSeparator/>
155+
<MenuFlyoutItem Text="Cut" Name="CutItem" >
156+
<MenuFlyoutItem.Icon>
157+
<FontIcon Glyph="&#xE8C6;"/>
158+
</MenuFlyoutItem.Icon>
159+
</MenuFlyoutItem>
160+
<MenuFlyoutItem Text="Copy" Name="CopyItem" >
161+
<MenuFlyoutItem.Icon>
162+
<FontIcon Glyph="&#xE8C8;"/>
163+
</MenuFlyoutItem.Icon>
164+
</MenuFlyoutItem>
165+
166+
<MenuFlyoutSeparator/>
167+
<MenuFlyoutItem Text="Properties" Name="PropertiesItem">
168+
<MenuFlyoutItem.Icon>
169+
<FontIcon Glyph="&#xE946;"/>
170+
</MenuFlyoutItem.Icon>
171+
</MenuFlyoutItem>
172+
</MenuFlyout.Items>
173+
174+
</MenuFlyout>
175+
</GridView.Resources>
124176
<GridView.ItemTemplate>
125177
<DataTemplate>
126178
<Grid Margin="0, 0, 0, 0" Padding="15, 15, 15, 15" Width="150" Height="150" HorizontalAlignment="Center" VerticalAlignment="Center">

PhotoAlbum.xaml.cs

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,41 +12,26 @@
1212
//
1313

1414
using ItemListPresenter;
15-
using Microsoft.Toolkit.Uwp.UI.Controls;
16-
using System;
17-
using System.Collections.Generic;
18-
using System.Collections.ObjectModel;
19-
using System.Diagnostics;
20-
using System.IO;
21-
using System.Linq;
22-
using System.Runtime.InteropServices.WindowsRuntime;
23-
using Windows.Foundation;
24-
using Windows.Foundation.Collections;
25-
using Windows.Storage;
26-
using Windows.Storage.FileProperties;
27-
using Windows.UI.Xaml;
2815
using Windows.UI.Xaml.Controls;
29-
using Windows.UI.Xaml.Controls.Primitives;
30-
using Windows.UI.Xaml.Data;
31-
using Windows.UI.Xaml.Input;
32-
using Windows.UI.Xaml.Media;
33-
using Windows.UI.Xaml.Media.Imaging;
3416
using Windows.UI.Xaml.Navigation;
3517

3618

3719

3820
namespace Files
3921
{
40-
22+
4123
public sealed partial class PhotoAlbum : Page
4224
{
4325
public static GridView gv;
4426
public static Image largeImg;
27+
public static MenuFlyout context;
28+
4529
public PhotoAlbum()
4630
{
4731
this.InitializeComponent();
4832

4933
gv = FileList;
34+
context = RightClickContextMenu;
5035
}
5136

5237
protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
@@ -55,7 +40,11 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
5540
var parameters = eventArgs.Parameter.ToString();
5641
ItemViewModel.ViewModel = new ItemViewModel(parameters, true);
5742
Interact.Interaction.page = this;
58-
FileList.ItemClick += Interact.Interaction.PhotoAlbumItemList_Click;
43+
FileList.ItemClick += Interact.Interaction.PhotoAlbumItemList_ClickAsync;
44+
Back.Click += Navigation.PhotoAlbumNavActions.Back_Click;
45+
Forward.Click += Navigation.PhotoAlbumNavActions.Forward_Click;
46+
Refresh.Click += Navigation.PhotoAlbumNavActions.Refresh_Click;
47+
FileList.RightTapped += Interact.Interaction.FileList_RightTapped;
5948
}
6049

6150

0 commit comments

Comments
 (0)