|
9 | 9 | using Microsoft.UI.Xaml.Input; |
10 | 10 | using Microsoft.UI.Xaml.Media; |
11 | 11 | using Microsoft.UI.Xaml.Navigation; |
12 | | -using System.Windows.Input; |
13 | 12 | using Windows.System; |
14 | | -using FocusManager = Microsoft.UI.Xaml.Input.FocusManager; |
15 | 13 |
|
16 | 14 | namespace Files.App.UserControls |
17 | 15 | { |
@@ -41,26 +39,16 @@ public sealed partial class NavigationToolbar : UserControl |
41 | 39 | [GeneratedDependencyProperty] |
42 | 40 | public partial NavigationToolbarViewModel ViewModel { get; set; } |
43 | 41 |
|
44 | | - // Commands |
45 | | - |
46 | | - private readonly ICommand historyItemClickedCommand; |
47 | | - |
48 | 42 | // Constructor |
49 | 43 |
|
50 | 44 | public NavigationToolbar() |
51 | 45 | { |
52 | 46 | InitializeComponent(); |
53 | | - |
54 | | - historyItemClickedCommand = new RelayCommand<ToolbarHistoryItemModel?>(HistoryItemClicked); |
55 | 47 | } |
56 | 48 |
|
57 | | - private void NavToolbar_Loading(FrameworkElement _, object e) |
58 | | - { |
59 | | - Loading -= NavToolbar_Loading; |
60 | | - if (OngoingTasksViewModel is not null) |
61 | | - OngoingTasksViewModel.NewItemAdded += OngoingTasksActions_ProgressBannerPosted; |
62 | | - } |
| 49 | + // Methods |
63 | 50 |
|
| 51 | + #region Legacy navigation box impl |
64 | 52 | private void VisiblePath_Loaded(object _, RoutedEventArgs e) |
65 | 53 | { |
66 | 54 | // AutoSuggestBox won't receive focus unless it's fully loaded |
@@ -135,17 +123,25 @@ private void SearchRegion_AccessKeyInvoked(UIElement sender, AccessKeyInvokedEve |
135 | 123 | private void VisiblePath_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) |
136 | 124 | => ViewModel.VisiblePath_QuerySubmitted(sender, args); |
137 | 125 |
|
138 | | - private void OngoingTasksActions_ProgressBannerPosted(object? _, StatusCenterItem e) |
| 126 | + private void ClickablePath_GettingFocus(UIElement sender, GettingFocusEventArgs args) |
| 127 | + { |
| 128 | + if (args.InputDevice != FocusInputDeviceKind.Keyboard) |
| 129 | + return; |
| 130 | + |
| 131 | + var previousControl = args.OldFocusedElement as FrameworkElement; |
| 132 | + if (previousControl?.Name == nameof(HomeButton) || previousControl?.Name == nameof(Refresh)) |
| 133 | + ViewModel.IsEditModeEnabled = true; |
| 134 | + } |
| 135 | + #endregion |
| 136 | + |
| 137 | + private void NewBreadcrumbBar_ItemDropDownFlyoutOpening(object sender, Controls.BreadcrumbBarItemDropDownFlyoutEventArgs e) |
| 138 | + { |
| 139 | + |
| 140 | + } |
| 141 | + |
| 142 | + private void NewBreadcrumbBar_ItemDropDownFlyoutClosed(object sender, Controls.BreadcrumbBarItemDropDownFlyoutEventArgs e) |
139 | 143 | { |
140 | | - if (OngoingTasksViewModel is not null) |
141 | | - OngoingTasksViewModel.NewItemAdded -= OngoingTasksActions_ProgressBannerPosted; |
142 | 144 |
|
143 | | - // Displays a teaching tip the first time a banner is posted |
144 | | - if (userSettingsService.AppSettingsService.ShowStatusCenterTeachingTip) |
145 | | - { |
146 | | - StatusCenterTeachingTip.IsOpen = true; |
147 | | - userSettingsService.AppSettingsService.ShowStatusCenterTeachingTip = false; |
148 | | - } |
149 | 145 | } |
150 | 146 |
|
151 | 147 | private void Button_AccessKeyInvoked(UIElement sender, AccessKeyInvokedEventArgs args) |
@@ -195,68 +191,58 @@ private async Task AddHistoryItemsAsync(IEnumerable<PageStackEntry> items, IList |
195 | 191 |
|
196 | 192 | var flyoutItem = new MenuFlyoutItem |
197 | 193 | { |
198 | | - Icon = new FontIcon { Glyph = "\uE8B7" }, // Use font icon as placeholder |
| 194 | + Icon = new FontIcon() { Glyph = "\uE8B7" }, // Placeholder icon |
199 | 195 | Text = fileName, |
200 | | - Command = historyItemClickedCommand, |
| 196 | + Command = new RelayCommand<ToolbarHistoryItemModel?>(HistoryItemClicked), |
201 | 197 | CommandParameter = new ToolbarHistoryItemModel(item, isBackMode) |
202 | 198 | }; |
203 | 199 |
|
204 | 200 | flyoutItems?.Add(flyoutItem); |
205 | 201 |
|
206 | 202 | // Start loading the thumbnail in the background |
207 | 203 | _ = LoadFlyoutItemIconAsync(flyoutItem, args.NavPathParam); |
208 | | - } |
209 | | - } |
210 | | - |
211 | | - private async Task LoadFlyoutItemIconAsync(MenuFlyoutItem flyoutItem, string path) |
212 | | - { |
213 | | - var imageSource = await NavigationHelpers.GetIconForPathAsync(path); |
214 | 204 |
|
215 | | - if (imageSource is not null) |
216 | | - flyoutItem.Icon = new ImageIcon { Source = imageSource }; |
217 | | - } |
218 | | - |
219 | | - private void HistoryItemClicked(ToolbarHistoryItemModel? itemModel) |
220 | | - { |
221 | | - if (itemModel is null) |
222 | | - return; |
223 | | - |
224 | | - var shellPage = Ioc.Default.GetRequiredService<IContentPageContext>().ShellPage; |
225 | | - if (shellPage is null) |
226 | | - return; |
227 | | - |
228 | | - if (itemModel.IsBackMode) |
229 | | - { |
230 | | - // Remove all entries after the target entry in the BackwardStack |
231 | | - while (shellPage.BackwardStack.Last() != itemModel.PageStackEntry) |
| 205 | + void HistoryItemClicked(ToolbarHistoryItemModel? itemModel) |
232 | 206 | { |
233 | | - shellPage.BackwardStack.RemoveAt(shellPage.BackwardStack.Count - 1); |
| 207 | + if (itemModel is null) |
| 208 | + return; |
| 209 | + |
| 210 | + var shellPage = Ioc.Default.GetRequiredService<IContentPageContext>().ShellPage; |
| 211 | + if (shellPage is null) |
| 212 | + return; |
| 213 | + |
| 214 | + if (itemModel.IsBackMode) |
| 215 | + { |
| 216 | + // Remove all entries after the target entry in the BackwardStack |
| 217 | + while (shellPage.BackwardStack.Last() != itemModel.PageStackEntry) |
| 218 | + { |
| 219 | + shellPage.BackwardStack.RemoveAt(shellPage.BackwardStack.Count - 1); |
| 220 | + } |
| 221 | + |
| 222 | + // Navigate back |
| 223 | + shellPage.Back_Click(); |
| 224 | + } |
| 225 | + else |
| 226 | + { |
| 227 | + // Remove all entries before the target entry in the ForwardStack |
| 228 | + while (shellPage.ForwardStack.First() != itemModel.PageStackEntry) |
| 229 | + { |
| 230 | + shellPage.ForwardStack.RemoveAt(0); |
| 231 | + } |
| 232 | + |
| 233 | + // Navigate forward |
| 234 | + shellPage.Forward_Click(); |
| 235 | + } |
234 | 236 | } |
235 | 237 |
|
236 | | - // Navigate back |
237 | | - shellPage.Back_Click(); |
238 | | - } |
239 | | - else |
240 | | - { |
241 | | - // Remove all entries before the target entry in the ForwardStack |
242 | | - while (shellPage.ForwardStack.First() != itemModel.PageStackEntry) |
| 238 | + async Task LoadFlyoutItemIconAsync(MenuFlyoutItem flyoutItem, string path) |
243 | 239 | { |
244 | | - shellPage.ForwardStack.RemoveAt(0); |
245 | | - } |
| 240 | + var imageSource = await NavigationHelpers.GetIconForPathAsync(path); |
246 | 241 |
|
247 | | - // Navigate forward |
248 | | - shellPage.Forward_Click(); |
| 242 | + if (imageSource is not null) |
| 243 | + flyoutItem.Icon = new ImageIcon() { Source = imageSource }; |
| 244 | + } |
249 | 245 | } |
250 | 246 | } |
251 | | - |
252 | | - private void ClickablePath_GettingFocus(UIElement sender, GettingFocusEventArgs args) |
253 | | - { |
254 | | - if (args.InputDevice != FocusInputDeviceKind.Keyboard) |
255 | | - return; |
256 | | - |
257 | | - var previousControl = args.OldFocusedElement as FrameworkElement; |
258 | | - if (previousControl?.Name == nameof(HomeButton) || previousControl?.Name == nameof(Refresh)) |
259 | | - ViewModel.IsEditModeEnabled = true; |
260 | | - } |
261 | 247 | } |
262 | 248 | } |
0 commit comments