Skip to content

Commit fdf7c95

Browse files
el-evyaira2
authored andcommitted
codestyle
1 parent 8acc5e1 commit fdf7c95

File tree

2 files changed

+26
-20
lines changed

2 files changed

+26
-20
lines changed

src/Files.App/ViewModels/UserControls/AddressToolbarViewModel.cs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -527,23 +527,30 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () =>
527527

528528
public void PathBoxItem_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
529529
{
530-
if (e.Key is Windows.System.VirtualKey.Down)
530+
switch (e.Key)
531531
{
532-
var item = e.OriginalSource as ListViewItem;
533-
var button = item?.FindDescendant<Button>();
534-
button?.Flyout.ShowAt(button);
535-
e.Handled = true;
536-
} else if (e.Key is Windows.System.VirtualKey.Space or Windows.System.VirtualKey.Enter)
537-
{
538-
var item = e.OriginalSource as ListViewItem;
539-
var path = (item?.Content as PathBoxItem)?.Path;
540-
if (path == null || path == PathControlDisplayText)
541-
return;
542-
ToolbarPathItemInvoked?.Invoke(this, new PathNavigationEventArgs()
532+
case Windows.System.VirtualKey.Down:
543533
{
544-
ItemPath = path
545-
});
546-
e.Handled = true;
534+
var item = e.OriginalSource as ListViewItem;
535+
var button = item?.FindDescendant<Button>();
536+
button?.Flyout.ShowAt(button);
537+
e.Handled = true;
538+
break;
539+
}
540+
case Windows.System.VirtualKey.Space:
541+
case Windows.System.VirtualKey.Enter:
542+
{
543+
var item = e.OriginalSource as ListViewItem;
544+
var path = (item?.Content as PathBoxItem)?.Path;
545+
if (path == PathControlDisplayText)
546+
return;
547+
ToolbarPathItemInvoked?.Invoke(this, new PathNavigationEventArgs()
548+
{
549+
ItemPath = path
550+
});
551+
e.Handled = true;
552+
break;
553+
}
547554
}
548555
}
549556

src/Files.App/Views/MainPage.xaml.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,19 +235,18 @@ private async Task OnPreviewKeyDownAsync(KeyRoutedEventArgs e)
235235
default:
236236
var currentModifiers = HotKeyHelpers.GetCurrentKeyModifiers();
237237
HotKey hotKey = new((Keys)e.Key, currentModifiers);
238-
var source = (DependencyObject)e.OriginalSource;
238+
var source = e.OriginalSource as DependencyObject;
239239

240240
// A textbox takes precedence over certain hotkeys.
241-
if (source.FindAscendantOrSelf<TextBox>() is not null)
241+
if (source?.FindAscendantOrSelf<TextBox>() is not null)
242242
break;
243243

244244
// Execute command for hotkey
245245
var command = Commands[hotKey];
246246

247-
if (command.Code is CommandCodes.OpenItem && source.FindAscendantOrSelf<PathBreadcrumb>() is not null)
248-
{
247+
if (command.Code is CommandCodes.OpenItem && source?.FindAscendantOrSelf<PathBreadcrumb>() is not null)
249248
break;
250-
}
249+
251250

252251
if (command.Code is not CommandCodes.None && keyReleased)
253252
{

0 commit comments

Comments
 (0)