|
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; |
12 | 13 | using Windows.System; |
13 | 14 |
|
14 | 15 | namespace Files.App.UserControls |
@@ -48,7 +49,13 @@ public NavigationToolbar() |
48 | 49 |
|
49 | 50 | // Methods |
50 | 51 |
|
51 | | - #region Legacy navigation box impl |
| 52 | + private void NavToolbar_Loading(FrameworkElement _, object e) |
| 53 | + { |
| 54 | + Loading -= NavToolbar_Loading; |
| 55 | + if (OngoingTasksViewModel is not null) |
| 56 | + OngoingTasksViewModel.NewItemAdded += OngoingTasksActions_ProgressBannerPosted; |
| 57 | + } |
| 58 | + |
52 | 59 | private void VisiblePath_Loaded(object _, RoutedEventArgs e) |
53 | 60 | { |
54 | 61 | // AutoSuggestBox won't receive focus unless it's fully loaded |
@@ -123,26 +130,17 @@ private void SearchRegion_AccessKeyInvoked(UIElement sender, AccessKeyInvokedEve |
123 | 130 | private void VisiblePath_QuerySubmitted(AutoSuggestBox sender, AutoSuggestBoxQuerySubmittedEventArgs args) |
124 | 131 | => ViewModel.VisiblePath_QuerySubmitted(sender, args); |
125 | 132 |
|
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 async void BreadcrumbBar_ItemDropDownFlyoutOpening(object sender, Controls.BreadcrumbBarItemDropDownFlyoutEventArgs e) |
| 133 | + private void OngoingTasksActions_ProgressBannerPosted(object? _, StatusCenterItem e) |
138 | 134 | { |
139 | | - await ViewModel.SetPathBoxDropDownFlyoutAsync(e.Flyout, ViewModel.PathComponents[e.Index]); |
140 | | - } |
| 135 | + if (OngoingTasksViewModel is not null) |
| 136 | + OngoingTasksViewModel.NewItemAdded -= OngoingTasksActions_ProgressBannerPosted; |
141 | 137 |
|
142 | | - private void BreadcrumbBar_ItemDropDownFlyoutClosed(object sender, Controls.BreadcrumbBarItemDropDownFlyoutEventArgs e) |
143 | | - { |
144 | | - // Clear the flyout items to save memory |
145 | | - e.Flyout.Items.Clear(); |
| 138 | + // Displays a teaching tip the first time a banner is posted |
| 139 | + if (userSettingsService.AppSettingsService.ShowStatusCenterTeachingTip) |
| 140 | + { |
| 141 | + StatusCenterTeachingTip.IsOpen = true; |
| 142 | + userSettingsService.AppSettingsService.ShowStatusCenterTeachingTip = false; |
| 143 | + } |
146 | 144 | } |
147 | 145 |
|
148 | 146 | private void Button_AccessKeyInvoked(UIElement sender, AccessKeyInvokedEventArgs args) |
@@ -203,6 +201,14 @@ private async Task AddHistoryItemsAsync(IEnumerable<PageStackEntry> items, IList |
203 | 201 | // Start loading the thumbnail in the background |
204 | 202 | _ = LoadFlyoutItemIconAsync(flyoutItem, args.NavPathParam); |
205 | 203 |
|
| 204 | + async Task LoadFlyoutItemIconAsync(MenuFlyoutItem flyoutItem, string path) |
| 205 | + { |
| 206 | + var imageSource = await NavigationHelpers.GetIconForPathAsync(path); |
| 207 | + |
| 208 | + if (imageSource is not null) |
| 209 | + flyoutItem.Icon = new ImageIcon() { Source = imageSource }; |
| 210 | + } |
| 211 | + |
206 | 212 | void HistoryItemClicked(ToolbarHistoryItemModel? itemModel) |
207 | 213 | { |
208 | 214 | if (itemModel is null) |
@@ -235,15 +241,33 @@ void HistoryItemClicked(ToolbarHistoryItemModel? itemModel) |
235 | 241 | shellPage.Forward_Click(); |
236 | 242 | } |
237 | 243 | } |
| 244 | + } |
| 245 | + } |
238 | 246 |
|
239 | | - async Task LoadFlyoutItemIconAsync(MenuFlyoutItem flyoutItem, string path) |
240 | | - { |
241 | | - var imageSource = await NavigationHelpers.GetIconForPathAsync(path); |
| 247 | + private void ClickablePath_GettingFocus(UIElement sender, GettingFocusEventArgs args) |
| 248 | + { |
| 249 | + if (args.InputDevice != FocusInputDeviceKind.Keyboard) |
| 250 | + return; |
242 | 251 |
|
243 | | - if (imageSource is not null) |
244 | | - flyoutItem.Icon = new ImageIcon() { Source = imageSource }; |
245 | | - } |
246 | | - } |
| 252 | + var previousControl = args.OldFocusedElement as FrameworkElement; |
| 253 | + if (previousControl?.Name == nameof(HomeButton) || previousControl?.Name == nameof(Refresh)) |
| 254 | + ViewModel.IsEditModeEnabled = true; |
| 255 | + } |
| 256 | + |
| 257 | + private void BreadcrumbBar_ItemClicked(Controls.BreadcrumbBar sender, Controls.BreadcrumbBarItemClickedEventArgs args) |
| 258 | + { |
| 259 | + |
| 260 | + } |
| 261 | + |
| 262 | + private async void BreadcrumbBar_ItemDropDownFlyoutOpening(object sender, Controls.BreadcrumbBarItemDropDownFlyoutEventArgs e) |
| 263 | + { |
| 264 | + await ViewModel.SetPathBoxDropDownFlyoutAsync(e.Flyout, ViewModel.PathComponents[e.Index]); |
| 265 | + } |
| 266 | + |
| 267 | + private void BreadcrumbBar_ItemDropDownFlyoutClosed(object sender, Controls.BreadcrumbBarItemDropDownFlyoutEventArgs e) |
| 268 | + { |
| 269 | + // Clear the flyout items to save memory |
| 270 | + e.Flyout.Items.Clear(); |
247 | 271 | } |
248 | 272 | } |
249 | 273 | } |
0 commit comments