diff options
| author | Ac_K <Acoustik666@gmail.com> | 2023-05-04 16:41:06 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-04 14:41:06 +0000 |
| commit | 3b8ac1641a8a40849915396813e26384b5894911 (patch) | |
| tree | 5355d6601917146809323990a1a0de8f3a7e893b /src/Ryujinx.Ava/UI/Controls/ApplicationGridView.axaml.cs | |
| parent | 42507323535443ad79be071367f3d4815afca688 (diff) | |
UI: Move ApplicationContextMenu in a separated class (#4755)
* UI: Move ApplicationContextMenu in a separated class
This PR remove duplicated code related to the context menu on the Application list/grid by create a control for the menu which include related handler.
I've renamed "GameList/GameGrid" by "Application" for consistencies. And I've removed all uneeded field from the project file too.
While I cleaned up things, I've found an issue about purging Ptc/Shader cache, both methods list files even if the user say "No", shader cache is purged even if the user say "No". It's fixed.
* Adresses feedbacks
Diffstat (limited to 'src/Ryujinx.Ava/UI/Controls/ApplicationGridView.axaml.cs')
| -rw-r--r-- | src/Ryujinx.Ava/UI/Controls/ApplicationGridView.axaml.cs | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/Ryujinx.Ava/UI/Controls/ApplicationGridView.axaml.cs b/src/Ryujinx.Ava/UI/Controls/ApplicationGridView.axaml.cs new file mode 100644 index 00000000..c30c75b3 --- /dev/null +++ b/src/Ryujinx.Ava/UI/Controls/ApplicationGridView.axaml.cs @@ -0,0 +1,57 @@ +using Avalonia.Controls; +using Avalonia.Input; +using Avalonia.Interactivity; +using Avalonia.Markup.Xaml; +using Ryujinx.Ava.UI.Helpers; +using Ryujinx.Ava.UI.ViewModels; +using Ryujinx.Ui.App.Common; +using System; + +namespace Ryujinx.Ava.UI.Controls +{ + public partial class ApplicationGridView : UserControl + { + public static readonly RoutedEvent<ApplicationOpenedEventArgs> ApplicationOpenedEvent = + RoutedEvent.Register<ApplicationGridView, ApplicationOpenedEventArgs>(nameof(ApplicationOpened), RoutingStrategies.Bubble); + + public event EventHandler<ApplicationOpenedEventArgs> ApplicationOpened + { + add { AddHandler(ApplicationOpenedEvent, value); } + remove { RemoveHandler(ApplicationOpenedEvent, value); } + } + + public ApplicationGridView() + { + InitializeComponent(); + } + + private void InitializeComponent() + { + AvaloniaXamlLoader.Load(this); + } + + public void GameList_DoubleTapped(object sender, RoutedEventArgs args) + { + if (sender is ListBox listBox) + { + if (listBox.SelectedItem is ApplicationData selected) + { + RaiseEvent(new ApplicationOpenedEventArgs(selected, ApplicationOpenedEvent)); + } + } + } + + public void GameList_SelectionChanged(object sender, SelectionChangedEventArgs args) + { + if (sender is ListBox listBox) + { + (DataContext as MainWindowViewModel).GridSelectedApplication = listBox.SelectedItem as ApplicationData; + } + } + + private void SearchBox_OnKeyUp(object sender, KeyEventArgs args) + { + (DataContext as MainWindowViewModel).SearchText = (sender as TextBox).Text; + } + } +} |
