Skip to content

Commit 8efec3b

Browse files
committed
codestyle
1 parent 93a488b commit 8efec3b

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
@@ -553,23 +553,30 @@ await MainWindow.Instance.DispatcherQueue.EnqueueOrInvokeAsync(async () =>
553553

554554
public void PathBoxItem_PreviewKeyDown(object sender, KeyRoutedEventArgs e)
555555
{
556-
if (e.Key is Windows.System.VirtualKey.Down)
556+
switch (e.Key)
557557
{
558-
var item = e.OriginalSource as ListViewItem;
559-
var button = item?.FindDescendant<Button>();
560-
button?.Flyout.ShowAt(button);
561-
e.Handled = true;
562-
} else if (e.Key is Windows.System.VirtualKey.Space or Windows.System.VirtualKey.Enter)
563-
{
564-
var item = e.OriginalSource as ListViewItem;
565-
var path = (item?.Content as PathBoxItem)?.Path;
566-
if (path == null || path == PathControlDisplayText)
567-
return;
568-
ToolbarPathItemInvoked?.Invoke(this, new PathNavigationEventArgs()
558+
case Windows.System.VirtualKey.Down:
569559
{
570-
ItemPath = path
571-
});
572-
e.Handled = true;
560+
var item = e.OriginalSource as ListViewItem;
561+
var button = item?.FindDescendant<Button>();
562+
button?.Flyout.ShowAt(button);
563+
e.Handled = true;
564+
break;
565+
}
566+
case Windows.System.VirtualKey.Space:
567+
case Windows.System.VirtualKey.Enter:
568+
{
569+
var item = e.OriginalSource as ListViewItem;
570+
var path = (item?.Content as PathBoxItem)?.Path;
571+
if (path == PathControlDisplayText)
572+
return;
573+
ToolbarPathItemInvoked?.Invoke(this, new PathNavigationEventArgs()
574+
{
575+
ItemPath = path
576+
});
577+
e.Handled = true;
578+
break;
579+
}
573580
}
574581
}
575582

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

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

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

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

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

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

0 commit comments

Comments
 (0)