24
24
using Windows . System ;
25
25
using Files . CommandLine ;
26
26
using Files . View_Models ;
27
+ using Files . Controls ;
27
28
28
29
namespace Files
29
30
{
30
31
sealed partial class App : Application
31
32
{
32
33
33
- private static ProHome occupiedInstance ;
34
- public static ProHome OccupiedInstance
34
+ private static IShellPage currentInstance ;
35
+ public static IShellPage CurrentInstance
35
36
{
36
37
get
37
38
{
38
- return occupiedInstance ;
39
+ return currentInstance ;
39
40
}
40
41
set
41
42
{
42
- if ( value != occupiedInstance )
43
+ if ( value != currentInstance )
43
44
{
44
- occupiedInstance = value ;
45
+ currentInstance = value ;
45
46
}
46
47
}
47
48
}
@@ -50,7 +51,8 @@ public static ProHome OccupiedInstance
50
51
public static Dialogs . PropertiesDialog propertiesDialog { get ; set ; }
51
52
public static Dialogs . LayoutDialog layoutDialog { get ; set ; }
52
53
public static Dialogs . AddItemDialog addItemDialog { get ; set ; }
53
- public static ObservableCollection < SidebarItem > sideBarItems = new ObservableCollection < SidebarItem > ( ) ;
54
+ public static ObservableCollection < INavigationControlItem > sideBarItems = new ObservableCollection < INavigationControlItem > ( ) ;
55
+ public static ObservableCollection < LocationItem > locationItems = new ObservableCollection < LocationItem > ( ) ;
54
56
public static ObservableCollection < WSLDistroItem > linuxDistroItems = new ObservableCollection < WSLDistroItem > ( ) ;
55
57
public static SettingsViewModel AppSettings { get ; set ; }
56
58
@@ -91,13 +93,13 @@ private async void CoreWindow_KeyDown(CoreWindow sender, KeyEventArgs args)
91
93
var ctrl = Window . Current . CoreWindow . GetKeyState ( VirtualKey . Control ) ;
92
94
var shift = Window . Current . CoreWindow . GetKeyState ( VirtualKey . Shift ) ;
93
95
var alt = Window . Current . CoreWindow . GetKeyState ( VirtualKey . Menu ) ;
94
- if ( App . OccupiedInstance != null )
96
+ if ( App . CurrentInstance != null )
95
97
{
96
98
if ( ctrl . HasFlag ( CoreVirtualKeyStates . Down ) )
97
99
{
98
100
if ( shift . HasFlag ( CoreVirtualKeyStates . Down ) )
99
101
{
100
- if ( ( App . OccupiedInstance . ItemDisplayFrame . Content as BaseLayout ) != null )
102
+ if ( App . CurrentInstance . ContentPage != null )
101
103
{
102
104
switch ( args . VirtualKey )
103
105
{
@@ -111,21 +113,21 @@ private async void CoreWindow_KeyDown(CoreWindow sender, KeyEventArgs args)
111
113
}
112
114
else
113
115
{
114
- if ( ( App . OccupiedInstance . ItemDisplayFrame . Content as BaseLayout ) != null )
116
+ if ( App . CurrentInstance . ContentPage != null )
115
117
{
116
118
switch ( args . VirtualKey )
117
119
{
118
120
case VirtualKey . C :
119
- App . OccupiedInstance . instanceInteraction . CopyItem_ClickAsync ( null , null ) ;
121
+ App . CurrentInstance . InteractionOperations . CopyItem_ClickAsync ( null , null ) ;
120
122
break ;
121
123
case VirtualKey . X :
122
- App . OccupiedInstance . instanceInteraction . CutItem_Click ( null , null ) ;
124
+ App . CurrentInstance . InteractionOperations . CutItem_Click ( null , null ) ;
123
125
break ;
124
126
case VirtualKey . V :
125
- App . OccupiedInstance . instanceInteraction . PasteItem_ClickAsync ( null , null ) ;
127
+ App . CurrentInstance . InteractionOperations . PasteItem_ClickAsync ( null , null ) ;
126
128
break ;
127
129
case VirtualKey . A :
128
- App . OccupiedInstance . instanceInteraction . SelectAllItems ( ) ;
130
+ App . CurrentInstance . InteractionOperations . SelectAllItems ( ) ;
129
131
break ;
130
132
}
131
133
}
@@ -151,33 +153,33 @@ private async void CoreWindow_KeyDown(CoreWindow sender, KeyEventArgs args)
151
153
}
152
154
else if ( ctrl . HasFlag ( CoreVirtualKeyStates . None ) && alt . HasFlag ( CoreVirtualKeyStates . None ) )
153
155
{
154
- if ( ( App . OccupiedInstance . ItemDisplayFrame . Content as BaseLayout ) != null )
156
+ if ( App . CurrentInstance . ContentPage != null )
155
157
{
156
158
switch ( args . VirtualKey )
157
159
{
158
160
case VirtualKey . Delete :
159
- App . OccupiedInstance . instanceInteraction . DeleteItem_Click ( null , null ) ;
161
+ App . CurrentInstance . InteractionOperations . DeleteItem_Click ( null , null ) ;
160
162
break ;
161
163
case VirtualKey . Enter :
162
- if ( ( App . OccupiedInstance . ItemDisplayFrame . Content as BaseLayout ) . IsQuickLookEnabled )
164
+ if ( ( App . CurrentInstance . ContentPage ) . IsQuickLookEnabled )
163
165
{
164
- App . OccupiedInstance . instanceInteraction . ToggleQuickLook ( ) ;
166
+ App . CurrentInstance . InteractionOperations . ToggleQuickLook ( ) ;
165
167
}
166
168
else
167
169
{
168
- App . OccupiedInstance . instanceInteraction . List_ItemClick ( null , null ) ;
170
+ App . CurrentInstance . InteractionOperations . List_ItemClick ( null , null ) ;
169
171
}
170
172
break ;
171
173
}
172
174
173
- if ( App . OccupiedInstance . ItemDisplayFrame . SourcePageType == typeof ( PhotoAlbum ) )
175
+ if ( App . CurrentInstance . CurrentPageType == typeof ( PhotoAlbum ) )
174
176
{
175
177
switch ( args . VirtualKey )
176
178
{
177
179
case VirtualKey . F2 :
178
- if ( ( App . OccupiedInstance . ItemDisplayFrame . Content as BaseLayout ) . SelectedItems . Count > 0 )
180
+ if ( ( App . CurrentInstance . ContentPage ) . SelectedItems . Count > 0 )
179
181
{
180
- App . OccupiedInstance . instanceInteraction . RenameItem_Click ( null , null ) ;
182
+ App . CurrentInstance . InteractionOperations . RenameItem_Click ( null , null ) ;
181
183
}
182
184
break ;
183
185
}
@@ -259,21 +261,25 @@ public async void PopulatePinnedSidebarItems()
259
261
var icon = "\uE8B7 " ;
260
262
261
263
bool isDuplicate = false ;
262
- foreach ( SidebarItem sbi in sideBarItems )
264
+ foreach ( INavigationControlItem sbi in sideBarItems )
263
265
{
264
- if ( ! string . IsNullOrWhiteSpace ( sbi . Path ) && ! sbi . isDefaultLocation )
266
+ if ( sbi is LocationItem )
265
267
{
266
- if ( sbi . Path . ToString ( ) == locationPath )
268
+ if ( ! string . IsNullOrWhiteSpace ( sbi . Path ) && ! ( sbi as LocationItem ) . IsDefaultLocation )
267
269
{
268
- isDuplicate = true ;
270
+ if ( sbi . Path . ToString ( ) == locationPath )
271
+ {
272
+ isDuplicate = true ;
269
273
274
+ }
270
275
}
271
276
}
277
+
272
278
}
273
279
274
280
if ( ! isDuplicate )
275
281
{
276
- sideBarItems . Add ( new SidebarItem ( ) { isDefaultLocation = false , Text = name , IconGlyph = icon , Path = locationPath } ) ;
282
+ sideBarItems . Add ( new LocationItem ( ) { IsDefaultLocation = false , Text = name , Glyph = icon , Path = locationPath } ) ;
277
283
}
278
284
}
279
285
catch ( UnauthorizedAccessException e )
@@ -298,13 +304,13 @@ public async void PopulatePinnedSidebarItems()
298
304
299
305
private void AddDefaultLocations ( )
300
306
{
301
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Home" , IconGlyph = "\uE737 " , isDefaultLocation = true , Path = "Home" } ) ;
302
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Desktop" , IconGlyph = "\uE8FC " , isDefaultLocation = true , Path = AppSettings . DesktopPath } ) ;
303
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Downloads" , IconGlyph = "\uE896 " , isDefaultLocation = true , Path = AppSettings . DownloadsPath } ) ;
304
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Documents" , IconGlyph = "\uE8A5 " , isDefaultLocation = true , Path = AppSettings . DocumentsPath } ) ;
305
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Pictures" , IconGlyph = "\uEB9F " , isDefaultLocation = true , Path = AppSettings . PicturesPath } ) ;
306
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Music" , IconGlyph = "\uEC4F " , isDefaultLocation = true , Path = AppSettings . MusicPath } ) ;
307
- sideBarItems . Add ( new SidebarItem ( ) { Text = "Videos" , IconGlyph = "\uE8B2 " , isDefaultLocation = true , Path = AppSettings . VideosPath } ) ;
307
+ sideBarItems . Add ( new LocationItem { Text = "Home" , Glyph = "\uE737 " , IsDefaultLocation = true , Path = "Home" } ) ;
308
+ sideBarItems . Add ( new LocationItem { Text = "Desktop" , Glyph = "\uE8FC " , IsDefaultLocation = true , Path = AppSettings . DesktopPath } ) ;
309
+ sideBarItems . Add ( new LocationItem { Text = "Downloads" , Glyph = "\uE896 " , IsDefaultLocation = true , Path = AppSettings . DownloadsPath } ) ;
310
+ sideBarItems . Add ( new LocationItem { Text = "Documents" , Glyph = "\uE8A5 " , IsDefaultLocation = true , Path = AppSettings . DocumentsPath } ) ;
311
+ sideBarItems . Add ( new LocationItem { Text = "Pictures" , Glyph = "\uEB9F " , IsDefaultLocation = true , Path = AppSettings . PicturesPath } ) ;
312
+ sideBarItems . Add ( new LocationItem { Text = "Music" , Glyph = "\uEC4F " , IsDefaultLocation = true , Path = AppSettings . MusicPath } ) ;
313
+ sideBarItems . Add ( new LocationItem { Text = "Videos" , Glyph = "\uE8B2 " , IsDefaultLocation = true , Path = AppSettings . VideosPath } ) ;
308
314
}
309
315
310
316
public static async void RemoveStaleSidebarItems ( )
@@ -326,27 +332,29 @@ public static async void RemoveStaleSidebarItems()
326
332
327
333
// Remove unpinned items from sidebar
328
334
var sideBarItems_Copy = sideBarItems . ToList ( ) ;
329
- foreach ( SidebarItem location in sideBarItems )
335
+ foreach ( INavigationControlItem location in sideBarItems )
330
336
{
331
- if ( ! location . isDefaultLocation )
337
+ if ( location is LocationItem )
332
338
{
333
- if ( ! ListFileLines . Contains ( location . Path . ToString ( ) ) )
339
+ if ( ! ( location as LocationItem ) . IsDefaultLocation )
334
340
{
335
- sideBarItems_Copy . Remove ( location ) ;
341
+ if ( ! ListFileLines . Contains ( location . Path . ToString ( ) ) )
342
+ {
343
+ sideBarItems_Copy . Remove ( location ) ;
344
+ }
336
345
}
337
346
}
338
-
339
347
}
340
348
sideBarItems . Clear ( ) ;
341
- foreach ( SidebarItem correctItem in sideBarItems_Copy )
349
+ foreach ( INavigationControlItem correctItem in sideBarItems_Copy )
342
350
{
343
351
sideBarItems . Add ( correctItem ) ;
344
352
}
345
353
LinesToRemoveFromFile . Clear ( ) ;
346
354
}
347
355
}
348
356
349
- public static SidebarItem rightClickedItem ;
357
+ public static INavigationControlItem rightClickedItem ;
350
358
351
359
public static async void FlyoutItem_Click ( object sender , RoutedEventArgs e )
352
360
{
@@ -369,7 +377,7 @@ public static void Clipboard_ContentChanged(object sender, object e)
369
377
try
370
378
{
371
379
DataPackageView packageView = Clipboard . GetContent ( ) ;
372
- if ( packageView . Contains ( StandardDataFormats . StorageItems ) && App . OccupiedInstance . ItemDisplayFrame . SourcePageType != typeof ( YourHome ) )
380
+ if ( packageView . Contains ( StandardDataFormats . StorageItems ) && App . CurrentInstance . CurrentPageType != typeof ( YourHome ) )
373
381
{
374
382
App . PS . isEnabled = true ;
375
383
}
@@ -488,16 +496,16 @@ private void Dispatcher_AcceleratorKeyActivated(CoreDispatcher sender, Accelerat
488
496
NavigationActions . Forward_Click ( null , null ) ;
489
497
break ;
490
498
case VirtualKey . F :
491
- App . OccupiedInstance . RibbonArea . RibbonTabView . SelectedIndex = 0 ;
499
+ ( App . CurrentInstance . OperationsControl as RibbonArea ) . RibbonTabView . SelectedIndex = 0 ;
492
500
break ;
493
501
case VirtualKey . H :
494
- App . OccupiedInstance . RibbonArea . RibbonTabView . SelectedIndex = 1 ;
502
+ ( App . CurrentInstance . OperationsControl as RibbonArea ) . RibbonTabView . SelectedIndex = 1 ;
495
503
break ;
496
504
case VirtualKey . S :
497
- App . OccupiedInstance . RibbonArea . RibbonTabView . SelectedIndex = 2 ;
505
+ ( App . CurrentInstance . OperationsControl as RibbonArea ) . RibbonTabView . SelectedIndex = 2 ;
498
506
break ;
499
507
case VirtualKey . V :
500
- App . OccupiedInstance . RibbonArea . RibbonTabView . SelectedIndex = 3 ;
508
+ ( App . CurrentInstance . OperationsControl as RibbonArea ) . RibbonTabView . SelectedIndex = 3 ;
501
509
break ;
502
510
}
503
511
}
@@ -613,10 +621,18 @@ private void OnSuspending(object sender, SuspendingEventArgs e)
613
621
}
614
622
}
615
623
616
- public class WSLDistroItem
624
+ public class WSLDistroItem : INavigationControlItem
617
625
{
618
626
public string DistroName { get ; set ; }
619
627
public string Path { get ; set ; }
620
628
public Uri Logo { get ; set ; }
629
+
630
+ string INavigationControlItem . IconGlyph => null ;
631
+
632
+ string INavigationControlItem . Text => DistroName ;
633
+
634
+ string INavigationControlItem . Path => Path ;
635
+
636
+ NavigationControlItemType INavigationControlItem . ItemType => NavigationControlItemType . LinuxDistro ;
621
637
}
622
638
}
0 commit comments