Skip to content

Commit e4f24bc

Browse files
committed
Expand folder pinning support to PhotoAlbum layout
1 parent 1b49cca commit e4f24bc

File tree

3 files changed

+43
-8
lines changed

3 files changed

+43
-8
lines changed

Files UWP/Interacts/Interaction.cs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,23 @@ public async void PinItem_Click(object sender, RoutedEventArgs e)
270270
}
271271
else if(typeof(PageType) == typeof(PhotoAlbum))
272272
{
273+
var selectedDataItem = (type as PhotoAlbum).instanceViewModel.FilesAndFolders[(type as PhotoAlbum).gv.SelectedIndex];
274+
StorageFolder cacheFolder = Windows.Storage.ApplicationData.Current.LocalCacheFolder;
273275

276+
try
277+
{
278+
List<string> items = new List<string>();
279+
items.Add(selectedDataItem.FilePath);
280+
var ListFile = await cacheFolder.GetFileAsync("PinnedItems.txt");
281+
await FileIO.AppendLinesAsync(ListFile, items);
282+
}
283+
catch (FileNotFoundException)
284+
{
285+
List<string> items = new List<string>();
286+
items.Add(selectedDataItem.FilePath);
287+
var createdListFile = await cacheFolder.CreateFileAsync("PinnedItems.txt");
288+
await FileIO.WriteLinesAsync(createdListFile, items);
289+
}
274290
}
275291
var CurrentInstance = ItemViewModel<PhotoAlbum>.GetCurrentSelectedTabInstance<ProHome>();
276292
CurrentInstance.PopulatePinnedSidebarItems();

Files UWP/PhotoAlbum.xaml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@
410410
<Style TargetType="GridViewItem">
411411
<Setter Property="ContextFlyout">
412412
<Setter.Value>
413-
<MenuFlyout x:Name="RightClickContextMenu" MenuFlyoutPresenterStyle="{StaticResource MenuFlyoutFluentThemeResources}">
413+
<MenuFlyout Opened="RightClickContextMenu_Opened" x:Name="RightClickContextMenu" MenuFlyoutPresenterStyle="{StaticResource MenuFlyoutFluentThemeResources}">
414414
<MenuFlyout.Items>
415415
<MenuFlyoutItem Click="OpenItem_Click" Text="Open With..." Name="OpenItem">
416416
<MenuFlyoutItem.Icon>
@@ -439,14 +439,19 @@
439439
<FontIcon Glyph="&#xE8C6;"/>
440440
</MenuFlyoutItem.Icon>
441441
</MenuFlyoutItem>
442-
<MenuFlyoutItem Click="CopyItem_Click" Text="Copy" Name="CopyItem" >
443-
<MenuFlyoutItem.Icon>
444-
<FontIcon Glyph="&#xE8C8;"/>
445-
</MenuFlyoutItem.Icon>
446-
</MenuFlyoutItem>
442+
<MenuFlyoutItem Click="CopyItem_Click" Text="Copy" Name="CopyItem" >
443+
<MenuFlyoutItem.Icon>
444+
<FontIcon Glyph="&#xE8C8;"/>
445+
</MenuFlyoutItem.Icon>
446+
</MenuFlyoutItem>
447+
<MenuFlyoutSeparator/>
448+
<MenuFlyoutItem Text="Pin to sidebar" Name="SidebarPinItem">
449+
<MenuFlyoutItem.Icon>
450+
<SymbolIcon Symbol="Pin"/>
451+
</MenuFlyoutItem.Icon>
447452

448-
<MenuFlyoutSeparator/>
449-
<MenuFlyoutItem Click="PropertiesItem_Click" Text="Properties" Name="PropertiesItem">
453+
</MenuFlyoutItem>
454+
<MenuFlyoutItem Click="PropertiesItem_Click" Text="Properties" Name="PropertiesItem">
450455
<MenuFlyoutItem.Icon>
451456
<FontIcon Glyph="&#xE946;"/>
452457
</MenuFlyoutItem.Icon>

Files UWP/PhotoAlbum.xaml.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
6565
CurrentInstance.ForwardButton.IsEnabled = CurrentInstance.accessibleContentFrame.CanGoForward;
6666
CurrentInstance.RefreshButton.IsEnabled = true;
6767
ItemViewModel<PhotoAlbum>.GetCurrentSelectedTabInstance<ProHome>().AlwaysPresentCommands.isEnabled = true;
68+
SidebarPinItem.Click += instanceInteraction.PinItem_Click;
6869
var parameters = eventArgs.Parameter.ToString();
6970

7071
TextState.isVisible = Visibility.Collapsed;
@@ -261,5 +262,18 @@ private void FileList_SelectionChanged(object sender, SelectionChangedEventArgs
261262
ItemViewModel<GenericFileBrowser>.GetCurrentSelectedTabInstance<ProHome>().ShareItems.isEnabled = false;
262263
}
263264
}
265+
266+
private void RightClickContextMenu_Opened(object sender, object e)
267+
{
268+
var selectedDataItem = instanceViewModel.FilesAndFolders[gv.SelectedIndex];
269+
if (selectedDataItem.FileType != "Folder" || gv.SelectedItems.Count > 1)
270+
{
271+
SidebarPinItem.IsEnabled = false;
272+
}
273+
else if (selectedDataItem.FileType == "Folder")
274+
{
275+
SidebarPinItem.IsEnabled = true;
276+
}
277+
}
264278
}
265279
}

0 commit comments

Comments
 (0)