sourcegit/src/Views/LauncherPageSwitcher.axaml.cs
leo aff003fd6d
Some checks are pending
Continuous Integration / Build (push) Waiting to run
Continuous Integration / Prepare version string (push) Waiting to run
Continuous Integration / Package (push) Blocked by required conditions
Localization Check / localization-check (push) Waiting to run
enhance: cleanup unused resources
Signed-off-by: leo <longshuang@msn.cn>
2025-05-18 22:00:35 +08:00

49 lines
1.3 KiB
C#

using Avalonia.Controls;
using Avalonia.Input;
namespace SourceGit.Views
{
public partial class LauncherPageSwitcher : UserControl
{
public LauncherPageSwitcher()
{
InitializeComponent();
}
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
if (e.Key == Key.Enter && DataContext is ViewModels.LauncherPageSwitcher switcher)
{
switcher.Switch();
e.Handled = true;
}
}
private void OnItemDoubleTapped(object sender, TappedEventArgs e)
{
if (DataContext is ViewModels.LauncherPageSwitcher switcher)
{
switcher.Switch();
e.Handled = true;
}
}
private void OnSearchBoxKeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Down && PagesListBox.ItemCount > 0)
{
PagesListBox.Focus(NavigationMethod.Directional);
if (PagesListBox.SelectedIndex < 0)
PagesListBox.SelectedIndex = 0;
else if (PagesListBox.SelectedIndex < PagesListBox.ItemCount)
PagesListBox.SelectedIndex++;
e.Handled = true;
}
}
}
}