mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-22 05:40:43 +08:00
refactor: rewrite Ctrl+P/⌘+P feature
Signed-off-by: leo <longshuang@msn.cn>
This commit is contained in:
@@ -512,6 +512,7 @@
|
||||
<x:String x:Key="Text.IssueLinkCM.OpenInBrowser" xml:space="preserve">Open in Browser</x:String>
|
||||
<x:String x:Key="Text.Launcher.Error" xml:space="preserve">ERROR</x:String>
|
||||
<x:String x:Key="Text.Launcher.Info" xml:space="preserve">NOTICE</x:String>
|
||||
<x:String x:Key="Text.Launcher.OpenRepository" xml:space="preserve">Open Repositories</x:String>
|
||||
<x:String x:Key="Text.Launcher.Pages" xml:space="preserve">Tabs</x:String>
|
||||
<x:String x:Key="Text.Launcher.Workspaces" xml:space="preserve">Workspaces</x:String>
|
||||
<x:String x:Key="Text.Merge" xml:space="preserve">Merge Branch</x:String>
|
||||
|
||||
@@ -516,6 +516,7 @@
|
||||
<x:String x:Key="Text.IssueLinkCM.OpenInBrowser" xml:space="preserve">在浏览器中访问</x:String>
|
||||
<x:String x:Key="Text.Launcher.Error" xml:space="preserve">出错了</x:String>
|
||||
<x:String x:Key="Text.Launcher.Info" xml:space="preserve">系统提示</x:String>
|
||||
<x:String x:Key="Text.Launcher.OpenRepository" xml:space="preserve">打开其他仓库</x:String>
|
||||
<x:String x:Key="Text.Launcher.Pages" xml:space="preserve">页面列表</x:String>
|
||||
<x:String x:Key="Text.Launcher.Workspaces" xml:space="preserve">工作区列表</x:String>
|
||||
<x:String x:Key="Text.Merge" xml:space="preserve">合并分支</x:String>
|
||||
|
||||
@@ -516,6 +516,7 @@
|
||||
<x:String x:Key="Text.IssueLinkCM.OpenInBrowser" xml:space="preserve">在瀏覽器中開啟連結</x:String>
|
||||
<x:String x:Key="Text.Launcher.Error" xml:space="preserve">發生錯誤</x:String>
|
||||
<x:String x:Key="Text.Launcher.Info" xml:space="preserve">系統提示</x:String>
|
||||
<x:String x:Key="Text.Launcher.OpenRepository" xml:space="preserve">開啟存放庫</x:String>
|
||||
<x:String x:Key="Text.Launcher.Pages" xml:space="preserve">頁面列表</x:String>
|
||||
<x:String x:Key="Text.Launcher.Workspaces" xml:space="preserve">工作區列表</x:String>
|
||||
<x:String x:Key="Text.Merge" xml:space="preserve">合併分支</x:String>
|
||||
|
||||
@@ -43,10 +43,10 @@ namespace SourceGit.ViewModels
|
||||
}
|
||||
}
|
||||
|
||||
public IDisposable Switcher
|
||||
public QuickLauncher QuickLauncher
|
||||
{
|
||||
get => _switcher;
|
||||
private set => SetProperty(ref _switcher, value);
|
||||
get => _quickLauncher;
|
||||
set => SetProperty(ref _quickLauncher, value);
|
||||
}
|
||||
|
||||
public Launcher(string startupRepo)
|
||||
@@ -127,17 +127,6 @@ namespace SourceGit.ViewModels
|
||||
_ignoreIndexChange = false;
|
||||
}
|
||||
|
||||
public void OpenTabSwitcher()
|
||||
{
|
||||
Switcher = new LauncherPageSwitcher(this);
|
||||
}
|
||||
|
||||
public void CancelSwitcher()
|
||||
{
|
||||
Switcher?.Dispose();
|
||||
Switcher = null;
|
||||
}
|
||||
|
||||
public void SwitchWorkspace(Workspace to)
|
||||
{
|
||||
if (to == null || to.IsActive)
|
||||
@@ -492,6 +481,6 @@ namespace SourceGit.ViewModels
|
||||
private LauncherPage _activePage = null;
|
||||
private bool _ignoreIndexChange = false;
|
||||
private string _title = string.Empty;
|
||||
private IDisposable _switcher = null;
|
||||
private QuickLauncher _quickLauncher = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class LauncherPageSwitcher : ObservableObject, IDisposable
|
||||
{
|
||||
public List<LauncherPage> VisiblePages
|
||||
{
|
||||
get => _visiblePages;
|
||||
private set => SetProperty(ref _visiblePages, value);
|
||||
}
|
||||
|
||||
public string SearchFilter
|
||||
{
|
||||
get => _searchFilter;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _searchFilter, value))
|
||||
UpdateVisiblePages();
|
||||
}
|
||||
}
|
||||
|
||||
public LauncherPage SelectedPage
|
||||
{
|
||||
get => _selectedPage;
|
||||
set => SetProperty(ref _selectedPage, value);
|
||||
}
|
||||
|
||||
public LauncherPageSwitcher(Launcher launcher)
|
||||
{
|
||||
_launcher = launcher;
|
||||
UpdateVisiblePages();
|
||||
SelectedPage = launcher.ActivePage;
|
||||
}
|
||||
|
||||
public void ClearFilter()
|
||||
{
|
||||
SearchFilter = string.Empty;
|
||||
}
|
||||
|
||||
public void Switch()
|
||||
{
|
||||
_launcher.ActivePage = _selectedPage ?? _launcher.ActivePage;
|
||||
_launcher.CancelSwitcher();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_visiblePages.Clear();
|
||||
_selectedPage = null;
|
||||
_searchFilter = string.Empty;
|
||||
}
|
||||
|
||||
private void UpdateVisiblePages()
|
||||
{
|
||||
var visible = new List<LauncherPage>();
|
||||
if (string.IsNullOrEmpty(_searchFilter))
|
||||
{
|
||||
visible.AddRange(_launcher.Pages);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var page in _launcher.Pages)
|
||||
{
|
||||
if (page.Node.Name.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase) ||
|
||||
(page.Node.IsRepository && page.Node.Id.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
visible.Add(page);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
VisiblePages = visible;
|
||||
SelectedPage = visible.Count > 0 ? visible[0] : null;
|
||||
}
|
||||
|
||||
private Launcher _launcher = null;
|
||||
private List<LauncherPage> _visiblePages = [];
|
||||
private string _searchFilter = string.Empty;
|
||||
private LauncherPage _selectedPage = null;
|
||||
}
|
||||
}
|
||||
125
src/ViewModels/QuickLauncher.cs
Normal file
125
src/ViewModels/QuickLauncher.cs
Normal file
@@ -0,0 +1,125 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
|
||||
namespace SourceGit.ViewModels
|
||||
{
|
||||
public class QuickLauncher : ObservableObject
|
||||
{
|
||||
public List<LauncherPage> VisiblePages
|
||||
{
|
||||
get => _visiblePages;
|
||||
private set => SetProperty(ref _visiblePages, value);
|
||||
}
|
||||
|
||||
public List<RepositoryNode> VisibleRepos
|
||||
{
|
||||
get => _visibleRepos;
|
||||
private set => SetProperty(ref _visibleRepos, value);
|
||||
}
|
||||
|
||||
public string SearchFilter
|
||||
{
|
||||
get => _searchFilter;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _searchFilter, value))
|
||||
UpdateVisible();
|
||||
}
|
||||
}
|
||||
|
||||
public LauncherPage SelectedPage
|
||||
{
|
||||
get => _selectedPage;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _selectedPage, value) && value != null)
|
||||
SelectedRepo = null;
|
||||
}
|
||||
}
|
||||
|
||||
public RepositoryNode SelectedRepo
|
||||
{
|
||||
get => _selectedRepo;
|
||||
set
|
||||
{
|
||||
if (SetProperty(ref _selectedRepo, value) && value != null)
|
||||
SelectedPage = null;
|
||||
}
|
||||
}
|
||||
|
||||
public QuickLauncher(Launcher launcher)
|
||||
{
|
||||
_launcher = launcher;
|
||||
|
||||
foreach (var page in _launcher.Pages)
|
||||
{
|
||||
if (page.Node.IsRepository)
|
||||
_opened.Add(page.Node.Id);
|
||||
}
|
||||
|
||||
UpdateVisible();
|
||||
}
|
||||
|
||||
public void ClearFilter()
|
||||
{
|
||||
SearchFilter = string.Empty;
|
||||
}
|
||||
|
||||
public void OpenOrSwitchTo()
|
||||
{
|
||||
if (_selectedPage != null)
|
||||
_launcher.ActivePage = _selectedPage;
|
||||
else if (_selectedRepo != null)
|
||||
_launcher.OpenRepositoryInTab(_selectedRepo, null);
|
||||
|
||||
_launcher.QuickLauncher = null;
|
||||
}
|
||||
|
||||
private void UpdateVisible()
|
||||
{
|
||||
var pages = new List<LauncherPage>();
|
||||
foreach (var page in _launcher.Pages)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_searchFilter) ||
|
||||
page.Node.Name.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase) ||
|
||||
(page.Node.IsRepository && page.Node.Id.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase)))
|
||||
pages.Add(page);
|
||||
}
|
||||
|
||||
var repos = new List<RepositoryNode>();
|
||||
CollectVisibleRepository(repos, Preferences.Instance.RepositoryNodes);
|
||||
|
||||
VisiblePages = pages;
|
||||
VisibleRepos = repos;
|
||||
}
|
||||
|
||||
private void CollectVisibleRepository(List<RepositoryNode> outs, List<RepositoryNode> nodes)
|
||||
{
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
if (!node.IsRepository)
|
||||
{
|
||||
CollectVisibleRepository(outs, node.SubNodes);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (_opened.Contains(node.Id))
|
||||
continue;
|
||||
|
||||
if (string.IsNullOrEmpty(_searchFilter) ||
|
||||
node.Id.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase) ||
|
||||
node.Name.Contains(_searchFilter, StringComparison.OrdinalIgnoreCase))
|
||||
outs.Add(node);
|
||||
}
|
||||
}
|
||||
|
||||
private Launcher _launcher = null;
|
||||
private HashSet<string> _opened = new HashSet<string>();
|
||||
private List<LauncherPage> _visiblePages = [];
|
||||
private List<RepositoryNode> _visibleRepos = [];
|
||||
private string _searchFilter = string.Empty;
|
||||
private LauncherPage _selectedPage = null;
|
||||
private RepositoryNode _selectedRepo = null;
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@
|
||||
</Button>
|
||||
|
||||
<!-- Pages Switcher Toggle Button -->
|
||||
<Button Grid.Column="2" Classes="icon_button" VerticalAlignment="Bottom" Margin="0,0,0,1" Command="{Binding OpenTabSwitcher}" HotKey="{OnPlatform Ctrl+P, macOS=⌘+P}">
|
||||
<Button Grid.Column="2" Classes="icon_button" VerticalAlignment="Bottom" Margin="0,0,0,1" Click="OnOpenQuickLauncher" HotKey="{OnPlatform Ctrl+P, macOS=⌘+P}">
|
||||
<ToolTip.Tip>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="{DynamicResource Text.Launcher.Pages}"
|
||||
@@ -123,17 +123,17 @@
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
|
||||
<!-- Pages Switcher -->
|
||||
<!-- Quick Launcher Popup -->
|
||||
<Border Grid.Row="0" Grid.RowSpan="2"
|
||||
Background="Transparent"
|
||||
IsVisible="{Binding Switcher, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
PointerPressed="OnCancelSwitcher">
|
||||
IsVisible="{Binding QuickLauncher, Converter={x:Static ObjectConverters.IsNotNull}}"
|
||||
PointerPressed="OnCloseQuickLauncher">
|
||||
<Border HorizontalAlignment="Center" VerticalAlignment="Center" Effect="drop-shadow(0 0 12 #A0000000)">
|
||||
<Border Background="{DynamicResource Brush.Popup}" CornerRadius="8">
|
||||
<ContentControl Margin="16,10,16,12" Content="{Binding Switcher}">
|
||||
<ContentControl Margin="16,10,16,12" Content="{Binding QuickLauncher}">
|
||||
<ContentControl.DataTemplates>
|
||||
<DataTemplate DataType="vm:LauncherPageSwitcher">
|
||||
<v:LauncherPageSwitcher/>
|
||||
<DataTemplate DataType="vm:QuickLauncher">
|
||||
<v:QuickLauncher/>
|
||||
</DataTemplate>
|
||||
</ContentControl.DataTemplates>
|
||||
</ContentControl>
|
||||
|
||||
@@ -250,8 +250,8 @@ namespace SourceGit.Views
|
||||
}
|
||||
else if (e.Key == Key.Escape)
|
||||
{
|
||||
if (vm.Switcher != null)
|
||||
vm.CancelSwitcher();
|
||||
if (vm.QuickLauncher != null)
|
||||
vm.QuickLauncher = null;
|
||||
else
|
||||
vm.ActivePage.CancelPopup();
|
||||
|
||||
@@ -355,10 +355,17 @@ namespace SourceGit.Views
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnCancelSwitcher(object sender, PointerPressedEventArgs e)
|
||||
private void OnOpenQuickLauncher(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if (e.Source == sender)
|
||||
(DataContext as ViewModels.Launcher)?.CancelSwitcher();
|
||||
if (DataContext is ViewModels.Launcher launcher)
|
||||
launcher.QuickLauncher = new ViewModels.QuickLauncher(launcher);
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
private void OnCloseQuickLauncher(object sender, PointerPressedEventArgs e)
|
||||
{
|
||||
if (e.Source == sender && DataContext is ViewModels.Launcher launcher)
|
||||
launcher.QuickLauncher = null;
|
||||
e.Handled = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
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 OnItemTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.LauncherPageSwitcher switcher)
|
||||
{
|
||||
switcher.Switch();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnSearchBoxKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (PagesListBox.ItemCount == 0)
|
||||
return;
|
||||
|
||||
if (e.Key == Key.Down)
|
||||
{
|
||||
PagesListBox.Focus(NavigationMethod.Directional);
|
||||
|
||||
if (PagesListBox.SelectedIndex < PagesListBox.ItemCount - 1)
|
||||
PagesListBox.SelectedIndex++;
|
||||
else
|
||||
PagesListBox.SelectedIndex = 0;
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Up)
|
||||
{
|
||||
PagesListBox.Focus(NavigationMethod.Directional);
|
||||
|
||||
if (PagesListBox.SelectedIndex > 0)
|
||||
PagesListBox.SelectedIndex--;
|
||||
else
|
||||
PagesListBox.SelectedIndex = PagesListBox.ItemCount - 1;
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,21 +6,16 @@
|
||||
xmlns:v="using:SourceGit.Views"
|
||||
xmlns:c="using:SourceGit.Converters"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
x:Class="SourceGit.Views.LauncherPageSwitcher"
|
||||
x:DataType="vm:LauncherPageSwitcher">
|
||||
<Grid RowDefinitions="Auto,Auto,Auto">
|
||||
<TextBlock Grid.Row="0"
|
||||
Text="{DynamicResource Text.Launcher.Pages}"
|
||||
FontWeight="Bold"
|
||||
HorizontalAlignment="Center"/>
|
||||
|
||||
<TextBox Grid.Row="1"
|
||||
x:Class="SourceGit.Views.QuickLauncher"
|
||||
x:DataType="vm:QuickLauncher">
|
||||
<Grid RowDefinitions="Auto,Auto,Auto,Auto,Auto">
|
||||
<TextBox Grid.Row="0"
|
||||
x:Name="FilterTextBox"
|
||||
Height="24"
|
||||
Margin="4,8,4,0"
|
||||
BorderThickness="1"
|
||||
CornerRadius="12"
|
||||
Text="{Binding SearchFilter, Mode=TwoWay}"
|
||||
KeyDown="OnSearchBoxKeyDown"
|
||||
BorderBrush="{DynamicResource Brush.Border2}"
|
||||
VerticalContentAlignment="Center"
|
||||
v:AutoFocusBehaviour.IsEnabled="True">
|
||||
@@ -46,11 +41,17 @@
|
||||
</TextBox.InnerRightContent>
|
||||
</TextBox>
|
||||
|
||||
<TextBlock Grid.Row="1"
|
||||
Margin="6,8,0,4"
|
||||
Text="{DynamicResource Text.Launcher.Pages}"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
|
||||
<ListBox Grid.Row="2"
|
||||
x:Name="PagesListBox"
|
||||
x:Name="PageListBox"
|
||||
Width="300"
|
||||
MaxHeight="400"
|
||||
Margin="4,8,4,0"
|
||||
MaxHeight="250"
|
||||
Margin="4,0"
|
||||
BorderThickness="0"
|
||||
SelectionMode="Single"
|
||||
Background="Transparent"
|
||||
@@ -110,5 +111,66 @@
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
|
||||
<TextBlock Grid.Row="3"
|
||||
Margin="6,8,0,4"
|
||||
Text="{DynamicResource Text.Launcher.OpenRepository}"
|
||||
FontWeight="Bold"
|
||||
Foreground="{DynamicResource Brush.FG2}"/>
|
||||
|
||||
<ListBox Grid.Row="4"
|
||||
x:Name="RepoListBox"
|
||||
Width="300"
|
||||
MaxHeight="300"
|
||||
Margin="4,0"
|
||||
BorderThickness="0"
|
||||
SelectionMode="Single"
|
||||
Background="Transparent"
|
||||
Focusable="True"
|
||||
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Auto"
|
||||
ItemsSource="{Binding VisibleRepos, Mode=OneWay}"
|
||||
SelectedItem="{Binding SelectedRepo, Mode=TwoWay}">
|
||||
<ListBox.Styles>
|
||||
<Style Selector="ListBoxItem">
|
||||
<Setter Property="Padding" Value="8,0"/>
|
||||
<Setter Property="MinHeight" Value="26"/>
|
||||
<Setter Property="CornerRadius" Value="4"/>
|
||||
</Style>
|
||||
|
||||
<Style Selector="ListBox">
|
||||
<Setter Property="FocusAdorner">
|
||||
<FocusAdornerTemplate>
|
||||
<Grid/>
|
||||
</FocusAdornerTemplate>
|
||||
</Setter>
|
||||
</Style>
|
||||
</ListBox.Styles>
|
||||
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<StackPanel Orientation="Vertical"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate DataType="vm:RepositoryNode">
|
||||
<Grid ColumnDefinitions="Auto,*" Background="Transparent" Tapped="OnItemTapped">
|
||||
<Path Grid.Column="0"
|
||||
Width="12" Height="12"
|
||||
Fill="{Binding Bookmark, Converter={x:Static c:IntConverters.ToBookmarkBrush}}"
|
||||
Data="{StaticResource Icons.Bookmark}"
|
||||
IsHitTestVisible="False"/>
|
||||
<TextBlock Grid.Column="1"
|
||||
Margin="6,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
IsHitTestVisible="False">
|
||||
<Run Text="{Binding Name, Mode=OneWay}"/>
|
||||
<Run Text="{Binding Id, Mode=OneWay, StringFormat=({0})}" Foreground="{DynamicResource Brush.FG2}"/>
|
||||
</TextBlock>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
92
src/Views/QuickLauncher.axaml.cs
Normal file
92
src/Views/QuickLauncher.axaml.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
|
||||
namespace SourceGit.Views
|
||||
{
|
||||
public partial class QuickLauncher : UserControl
|
||||
{
|
||||
public QuickLauncher()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(KeyEventArgs e)
|
||||
{
|
||||
base.OnKeyDown(e);
|
||||
|
||||
if (DataContext is not ViewModels.QuickLauncher switcher)
|
||||
return;
|
||||
|
||||
if (e.Key == Key.Enter)
|
||||
{
|
||||
switcher.OpenOrSwitchTo();
|
||||
e.Handled = true;
|
||||
}
|
||||
else if (e.Key == Key.Up)
|
||||
{
|
||||
if (RepoListBox.IsKeyboardFocusWithin)
|
||||
{
|
||||
if (switcher.VisiblePages.Count > 0)
|
||||
{
|
||||
PageListBox.Focus(NavigationMethod.Directional);
|
||||
switcher.SelectedPage = switcher.VisiblePages[^1];
|
||||
}
|
||||
else
|
||||
{
|
||||
FilterTextBox.Focus(NavigationMethod.Directional);
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (PageListBox.IsKeyboardFocusWithin)
|
||||
{
|
||||
FilterTextBox.Focus(NavigationMethod.Directional);
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (e.Key == Key.Down)
|
||||
{
|
||||
if (FilterTextBox.IsKeyboardFocusWithin)
|
||||
{
|
||||
if (switcher.VisiblePages.Count > 0)
|
||||
{
|
||||
PageListBox.Focus(NavigationMethod.Directional);
|
||||
switcher.SelectedPage = switcher.VisiblePages[0];
|
||||
}
|
||||
else if (switcher.VisibleRepos.Count > 0)
|
||||
{
|
||||
RepoListBox.Focus(NavigationMethod.Directional);
|
||||
switcher.SelectedRepo = switcher.VisibleRepos[0];
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
if (PageListBox.IsKeyboardFocusWithin)
|
||||
{
|
||||
if (switcher.VisibleRepos.Count > 0)
|
||||
{
|
||||
RepoListBox.Focus(NavigationMethod.Directional);
|
||||
switcher.SelectedRepo = switcher.VisibleRepos[0];
|
||||
}
|
||||
|
||||
e.Handled = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnItemTapped(object sender, TappedEventArgs e)
|
||||
{
|
||||
if (DataContext is ViewModels.QuickLauncher switcher)
|
||||
{
|
||||
switcher.OpenOrSwitchTo();
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user