Skip to content

Commit 3e800f0

Browse files
author
Yair Aichenbaum
committed
Refactored ModernSidebar code
1 parent 199be7a commit 3e800f0

File tree

1 file changed

+13
-27
lines changed

1 file changed

+13
-27
lines changed

Files/UserControls/ModernSidebar.xaml.cs

Lines changed: 13 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ private void Sidebar_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
5656
{
5757
//(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.HomeItems.isEnabled = false;
5858
//(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.ShareItems.isEnabled = false;
59+
string NaviagtionPath = ""; // path to navigate
5960

6061
if (args.InvokedItem == null)
6162
{
@@ -78,45 +79,21 @@ private void Sidebar_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
7879
}
7980
else // Any other item
8081
{
81-
if (App.AppSettings.LayoutMode == 0) // List View
82-
{
83-
App.CurrentInstance.ContentFrame.Navigate(typeof(GenericFileBrowser), args.InvokedItemContainer.Tag.ToString(), new SuppressNavigationTransitionInfo());
84-
}
85-
else
86-
{
87-
App.CurrentInstance.ContentFrame.Navigate(typeof(PhotoAlbum), args.InvokedItemContainer.Tag.ToString(), new SuppressNavigationTransitionInfo());
88-
}
89-
//(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.HomeItems.isEnabled = false;
90-
//(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.ShareItems.isEnabled = false;
91-
//(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.LayoutItems.isEnabled = true;
82+
NaviagtionPath = args.InvokedItemContainer.Tag.ToString();
9283
}
9384

9485
break;
9586
}
9687
case NavigationControlItemType.OneDrive:
9788
{
98-
if (App.AppSettings.LayoutMode == 0) // List View
99-
{
100-
App.CurrentInstance.ContentFrame.Navigate(typeof(GenericFileBrowser), App.AppSettings.OneDrivePath, new SuppressNavigationTransitionInfo());
101-
}
102-
else
103-
{
104-
App.CurrentInstance.ContentFrame.Navigate(typeof(PhotoAlbum), App.AppSettings.OneDrivePath, new SuppressNavigationTransitionInfo());
105-
}
89+
NaviagtionPath = App.AppSettings.OneDrivePath;
10690
break;
10791
}
10892
default:
10993
{
11094
var clickedItem = args.InvokedItemContainer;
11195

112-
if (App.AppSettings.LayoutMode == 0) // List View
113-
{
114-
App.CurrentInstance.ContentFrame.Navigate(typeof(GenericFileBrowser), clickedItem.Tag.ToString(), new SuppressNavigationTransitionInfo());
115-
}
116-
else
117-
{
118-
App.CurrentInstance.ContentFrame.Navigate(typeof(PhotoAlbum), clickedItem.Tag.ToString(), new SuppressNavigationTransitionInfo());
119-
}
96+
NaviagtionPath = clickedItem.Tag.ToString();
12097

12198
App.CurrentInstance.NavigationToolbar.PathControlDisplayText = clickedItem.Tag.ToString();
12299
//(App.CurrentInstance.OperationsControl as RibbonArea).RibbonViewModel.LayoutItems.isEnabled = true;
@@ -125,6 +102,15 @@ private void Sidebar_ItemInvoked(Microsoft.UI.Xaml.Controls.NavigationView sende
125102
}
126103
}
127104

105+
if (App.AppSettings.LayoutMode == 0) // List View
106+
{
107+
App.CurrentInstance.ContentFrame.Navigate(typeof(GenericFileBrowser), NaviagtionPath, new SuppressNavigationTransitionInfo());
108+
}
109+
else
110+
{
111+
App.CurrentInstance.ContentFrame.Navigate(typeof(PhotoAlbum), NaviagtionPath, new SuppressNavigationTransitionInfo());
112+
}
113+
128114
App.CurrentInstance.NavigationToolbar.PathControlDisplayText = App.CurrentInstance.ViewModel.Universal.WorkingDirectory;
129115
}
130116

0 commit comments

Comments
 (0)