12
12
using System . Collections . Generic ;
13
13
using System . Linq ;
14
14
using static Files . App . Constants ;
15
+ using static Files . App . Helpers . PathNormalization ;
15
16
16
17
namespace Files . App . Views . LayoutModes
17
18
{
@@ -20,6 +21,9 @@ public sealed partial class ColumnViewBrowser : BaseLayout
20
21
protected override uint IconSize => Browser . ColumnViewBrowser . ColumnViewSizeSmall ;
21
22
protected override ItemsControl ItemsControl => ColumnHost ;
22
23
24
+ public string ? OwnerPath { get ; private set ; }
25
+ public int FocusIndex { get ; private set ; }
26
+
23
27
public ColumnViewBrowser ( ) : base ( )
24
28
{
25
29
InitializeComponent ( ) ;
@@ -66,6 +70,8 @@ private void ColumnViewBase_ItemInvoked(object? sender, EventArgs e)
66
70
Column = ColumnHost . ActiveBlades . IndexOf ( newblade ) ,
67
71
NavPathParam = column . NavPathParam
68
72
} ) ;
73
+ navigationArguments . NavPathParam = column . NavPathParam ;
74
+ ParentShellPageInstance . TabItemArguments . NavigationArg = column . NavPathParam ;
69
75
}
70
76
}
71
77
@@ -78,7 +84,21 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
78
84
{
79
85
base . OnNavigatedTo ( eventArgs ) ;
80
86
81
- var navigationArguments = ( NavigationArguments ) eventArgs . Parameter ;
87
+ var path = navigationArguments . NavPathParam ;
88
+ var pathStack = new Stack < string > ( ) ;
89
+
90
+ if ( path is not null )
91
+ {
92
+ var rootPathList = App . QuickAccessManager . Model . FavoriteItems . Select ( x => NormalizePath ( x ) ) . ToList ( ) ;
93
+ rootPathList . Add ( NormalizePath ( GetPathRoot ( path ) ) ) ;
94
+
95
+ while ( ! rootPathList . Contains ( NormalizePath ( path ) ) )
96
+ {
97
+ pathStack . Push ( path ) ;
98
+ path = GetParentDir ( path ) ;
99
+ }
100
+ }
101
+
82
102
MainPageFrame . Navigated += Frame_Navigated ;
83
103
MainPageFrame . Navigate ( typeof ( ColumnShellPage ) , new ColumnParam
84
104
{
@@ -87,8 +107,21 @@ protected override void OnNavigatedTo(NavigationEventArgs eventArgs)
87
107
SearchQuery = navigationArguments . SearchQuery ,
88
108
SearchUnindexedItems = navigationArguments . SearchUnindexedItems ,
89
109
SearchPathParam = navigationArguments . SearchPathParam ,
90
- NavPathParam = navigationArguments . NavPathParam
110
+ NavPathParam = path
91
111
} ) ;
112
+ OwnerPath = navigationArguments . NavPathParam ;
113
+ FocusIndex = pathStack . Count ;
114
+ var index = 0 ;
115
+ while ( pathStack . TryPop ( out path ) )
116
+ {
117
+ var ( frame , _) = CreateAndAddNewBlade ( ) ;
118
+
119
+ frame . Navigate ( typeof ( ColumnShellPage ) , new ColumnParam
120
+ {
121
+ Column = ++ index ,
122
+ NavPathParam = path
123
+ } ) ;
124
+ }
92
125
}
93
126
94
127
protected override void InitializeCommandsViewModel ( )
@@ -163,6 +196,11 @@ private void DismissOtherBlades(int index)
163
196
ColumnHost . Items . RemoveAt ( index + 1 ) ;
164
197
ColumnHost . ActiveBlades . RemoveAt ( index + 1 ) ;
165
198
}
199
+ if ( ( ColumnHost . ActiveBlades [ index ] . Content as Frame ) ? . Content is ColumnShellPage s )
200
+ {
201
+ navigationArguments . NavPathParam = s . FilesystemViewModel . WorkingDirectory ;
202
+ ParentShellPageInstance . TabItemArguments . NavigationArg = s . FilesystemViewModel . WorkingDirectory ;
203
+ }
166
204
} ) ;
167
205
}
168
206
ContentChanged ( ActiveColumnShellPage ) ;
@@ -242,6 +280,7 @@ public void MoveFocusToPreviousBlade(int currentBladeIndex)
242
280
243
281
var activeBlade = ColumnHost . ActiveBlades [ currentBladeIndex - 1 ] ;
244
282
activeBlade . Focus ( FocusState . Programmatic ) ;
283
+ FocusIndex = currentBladeIndex - 1 ;
245
284
246
285
var activeBladeColumnViewBase = RetrieveBladeColumnViewBase ( activeBlade ) ;
247
286
if ( activeBladeColumnViewBase is null )
@@ -260,6 +299,7 @@ public void MoveFocusToNextBlade(int currentBladeIndex)
260
299
261
300
var activeBlade = ColumnHost . ActiveBlades [ currentBladeIndex ] ;
262
301
activeBlade . Focus ( FocusState . Programmatic ) ;
302
+ FocusIndex = currentBladeIndex ;
263
303
264
304
var activeBladeColumnViewBase = RetrieveBladeColumnViewBase ( activeBlade ) ;
265
305
if ( activeBladeColumnViewBase is not null )
0 commit comments