Skip to content

Commit bcfbe74

Browse files
committed
Fix for Item Selection in PhotoView navigation
1 parent 1e20f86 commit bcfbe74

File tree

1 file changed

+135
-8
lines changed

1 file changed

+135
-8
lines changed

Files UWP/Navigation/PhotoAlbumNavActions.cs

Lines changed: 135 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -129,15 +129,23 @@ public static void Back_Click(object sender, RoutedEventArgs e)
129129
else
130130
{
131131
App.PathText.Text = (History.HistoryList[History.HistoryList.Count - 1]);
132-
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
132+
if((History.HistoryList[History.HistoryList.Count - 1]).Split('\\')[0].Contains("C:\\"))
133133
{
134-
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "LocD_IC")
134+
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
135135
{
136-
MainPage.Select.itemSelected = NavItemChoice;
137-
break;
136+
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Content.ToString() == ("Removable Drive (" + History.ForwardList[History.ForwardList.Count() - 1].Split('\\')[0] + "\\)"))
137+
{
138+
139+
MainPage.Select.itemSelected = NavItemChoice;
140+
break;
141+
}
138142
}
139143
}
140-
App.ViewModel.AddItemsToCollectionAsync(History.HistoryList[History.HistoryList.Count - 1], GenericFileBrowser.GFBPageName); // To take into account the correct index without interference from the folder being navigated to
144+
else
145+
{
146+
147+
}
148+
App.ViewModel.AddItemsToCollectionAsync(History.HistoryList[History.HistoryList.Count - 1], PhotoAlbum.PAPageName); // To take into account the correct index without interference from the folder being navigated to
141149
}
142150

143151
if (History.ForwardList.Count == 0)
@@ -163,10 +171,129 @@ public static void Forward_Click(object sender, RoutedEventArgs e)
163171
{
164172
App.ViewModel.TextState.isVisible = Visibility.Collapsed;
165173
App.ViewModel.FilesAndFolders.Clear();
166-
App.ViewModel.AddItemsToCollectionAsync(History.ForwardList[History.ForwardList.Count() - 1], PhotoAlbum.PAPageName); // To take into account the correct index without interference from the folder being navigated to
167-
App.PathText.Text = History.ForwardList[History.ForwardList.Count() - 1];
174+
175+
176+
if ((History.ForwardList[History.ForwardList.Count() - 1]) == Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory))
177+
{
178+
App.PathText.Text = "Desktop";
179+
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
180+
{
181+
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "DesktopIC")
182+
{
183+
MainPage.Select.itemSelected = NavItemChoice;
184+
break;
185+
}
186+
}
187+
MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), YourHome.DesktopPath, new SuppressNavigationTransitionInfo());
188+
MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Desktop";
189+
}
190+
else if ((History.ForwardList[History.ForwardList.Count() - 1]) == Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments))
191+
{
192+
App.PathText.Text = "Documents";
193+
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
194+
{
195+
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "DocumentsIC")
196+
{
197+
MainPage.Select.itemSelected = NavItemChoice;
198+
break;
199+
}
200+
}
201+
MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), YourHome.DocumentsPath, new SuppressNavigationTransitionInfo());
202+
MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Documents";
203+
}
204+
else if ((History.ForwardList[History.ForwardList.Count() - 1]) == (Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\Downloads"))
205+
{
206+
App.PathText.Text = "Downloads";
207+
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
208+
{
209+
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "DownloadsIC")
210+
{
211+
MainPage.Select.itemSelected = NavItemChoice;
212+
break;
213+
}
214+
}
215+
MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), YourHome.DownloadsPath, new SuppressNavigationTransitionInfo());
216+
MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Downloads";
217+
}
218+
else if ((History.ForwardList[History.ForwardList.Count() - 1]) == Environment.GetFolderPath(Environment.SpecialFolder.MyPictures))
219+
{
220+
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
221+
{
222+
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "PicturesIC")
223+
{
224+
MainPage.Select.itemSelected = NavItemChoice;
225+
break;
226+
}
227+
}
228+
MainPage.accessibleContentFrame.Navigate(typeof(PhotoAlbum), YourHome.PicturesPath, new SuppressNavigationTransitionInfo());
229+
MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Pictures";
230+
App.PathText.Text = "Pictures";
231+
}
232+
else if ((History.ForwardList[History.ForwardList.Count() - 1]) == Environment.GetFolderPath(Environment.SpecialFolder.MyMusic))
233+
{
234+
App.PathText.Text = "Music";
235+
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
236+
{
237+
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "MusicIC")
238+
{
239+
MainPage.Select.itemSelected = NavItemChoice;
240+
break;
241+
}
242+
}
243+
MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), YourHome.MusicPath, new SuppressNavigationTransitionInfo());
244+
MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Music";
245+
}
246+
else if ((History.ForwardList[History.ForwardList.Count() - 1]) == (Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) + @"\OneDrive"))
247+
{
248+
App.PathText.Text = "OneDrive";
249+
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
250+
{
251+
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "OneD_IC")
252+
{
253+
MainPage.Select.itemSelected = NavItemChoice;
254+
break;
255+
}
256+
}
257+
MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), YourHome.OneDrivePath, new SuppressNavigationTransitionInfo());
258+
MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search OneDrive";
259+
}
260+
else if ((History.ForwardList[History.ForwardList.Count() - 1]) == Environment.GetFolderPath(Environment.SpecialFolder.MyVideos))
261+
{
262+
App.PathText.Text = "Videos";
263+
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
264+
{
265+
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Name.ToString() == "VideosIC")
266+
{
267+
MainPage.Select.itemSelected = NavItemChoice;
268+
break;
269+
}
270+
}
271+
MainPage.accessibleContentFrame.Navigate(typeof(GenericFileBrowser), YourHome.VideosPath, new SuppressNavigationTransitionInfo());
272+
MainPage.accessibleAutoSuggestBox.PlaceholderText = "Search Videos";
273+
}
274+
else
275+
{
276+
Debug.WriteLine("Debug: " + ("Removable Drive (" + History.ForwardList[History.ForwardList.Count() - 1].Split('\\')[0] + "\\)"));
277+
if (!History.ForwardList[History.ForwardList.Count() - 1].Split('\\')[0].Contains("C:\\"))
278+
{
279+
foreach (Microsoft.UI.Xaml.Controls.NavigationViewItemBase NavItemChoice in MainPage.nv.MenuItems)
280+
{
281+
if (NavItemChoice is Microsoft.UI.Xaml.Controls.NavigationViewItem && NavItemChoice.Content.ToString() == ("Removable Drive (" + History.ForwardList[History.ForwardList.Count() - 1].Split('\\')[0] + "\\)"))
282+
{
283+
284+
MainPage.Select.itemSelected = NavItemChoice;
285+
break;
286+
}
287+
}
288+
}
289+
App.PathText.Text = (History.ForwardList[History.ForwardList.Count() - 1]);
290+
App.ViewModel.AddItemsToCollectionAsync(History.ForwardList[History.ForwardList.Count() - 1], PhotoAlbum.PAPageName); // To take into account the correct index without interference from the folder being navigated to
291+
292+
}
293+
294+
295+
168296
History.ForwardList.RemoveAt(History.ForwardList.Count() - 1);
169-
ArrayDiag.DumpForwardArray();
170297

171298
if (History.ForwardList.Count == 0)
172299
{

0 commit comments

Comments
 (0)