mirror of
https://git.ryujinx.app/kenji-nx/ryujinx.git
synced 2025-12-14 16:37:07 +00:00
UI: Only allow right click to create a context menu if a game is selected.
This commit is contained in:
parent
6bfcdeee8c
commit
f244157979
5 changed files with 64 additions and 27 deletions
|
|
@ -15,7 +15,6 @@
|
||||||
x:DataType="viewModels:MainWindowViewModel">
|
x:DataType="viewModels:MainWindowViewModel">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||||
<controls:ApplicationContextMenu x:Key="ApplicationContextMenu" />
|
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
|
@ -26,10 +25,10 @@
|
||||||
Padding="8"
|
Padding="8"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
ContextFlyout="{StaticResource ApplicationContextMenu}"
|
SelectedItem="{Binding GridSelectedApplication}"
|
||||||
|
ContextFlyout="{Binding GridAppContextMenu}"
|
||||||
DoubleTapped="GameList_DoubleTapped"
|
DoubleTapped="GameList_DoubleTapped"
|
||||||
ItemsSource="{Binding AppsObservableList}"
|
ItemsSource="{Binding AppsObservableList}">
|
||||||
SelectionChanged="GameList_SelectionChanged">
|
|
||||||
<ListBox.ItemsPanel>
|
<ListBox.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<WrapPanel
|
<WrapPanel
|
||||||
|
|
|
||||||
|
|
@ -35,14 +35,6 @@ namespace Ryujinx.Ava.UI.Controls
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
private void SearchBox_OnKeyUp(object sender, KeyEventArgs args)
|
||||||
{
|
{
|
||||||
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox).Text;
|
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox).Text;
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,6 @@
|
||||||
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
xmlns:helpers="clr-namespace:Ryujinx.Ava.UI.Helpers"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
xmlns:ui="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
|
||||||
xmlns:converters="clr-namespace:Avalonia.Data.Converters;assembly=Avalonia.Base"
|
|
||||||
d:DesignHeight="450"
|
d:DesignHeight="450"
|
||||||
d:DesignWidth="800"
|
d:DesignWidth="800"
|
||||||
Focusable="True"
|
Focusable="True"
|
||||||
|
|
@ -16,7 +15,6 @@
|
||||||
x:DataType="viewModels:MainWindowViewModel">
|
x:DataType="viewModels:MainWindowViewModel">
|
||||||
<UserControl.Resources>
|
<UserControl.Resources>
|
||||||
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
<helpers:BitmapArrayValueConverter x:Key="ByteImage" />
|
||||||
<controls:ApplicationContextMenu x:Key="ApplicationContextMenu" />
|
|
||||||
</UserControl.Resources>
|
</UserControl.Resources>
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
|
|
@ -28,10 +26,10 @@
|
||||||
Padding="8"
|
Padding="8"
|
||||||
HorizontalAlignment="Stretch"
|
HorizontalAlignment="Stretch"
|
||||||
VerticalAlignment="Stretch"
|
VerticalAlignment="Stretch"
|
||||||
ContextFlyout="{StaticResource ApplicationContextMenu}"
|
SelectedItem="{Binding ListSelectedApplication}"
|
||||||
|
ContextFlyout="{Binding ListAppContextMenu}"
|
||||||
DoubleTapped="GameList_DoubleTapped"
|
DoubleTapped="GameList_DoubleTapped"
|
||||||
ItemsSource="{Binding AppsObservableList}"
|
ItemsSource="{Binding AppsObservableList}">
|
||||||
SelectionChanged="GameList_SelectionChanged">
|
|
||||||
<ListBox.ItemsPanel>
|
<ListBox.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<StackPanel
|
<StackPanel
|
||||||
|
|
|
||||||
|
|
@ -36,14 +36,6 @@ namespace Ryujinx.Ava.UI.Controls
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GameList_SelectionChanged(object sender, SelectionChangedEventArgs args)
|
|
||||||
{
|
|
||||||
if (sender is ListBox listBox)
|
|
||||||
{
|
|
||||||
(DataContext as MainWindowViewModel).ListSelectedApplication = listBox.SelectedItem as ApplicationData;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void SearchBox_OnKeyUp(object sender, KeyEventArgs args)
|
private void SearchBox_OnKeyUp(object sender, KeyEventArgs args)
|
||||||
{
|
{
|
||||||
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox).Text;
|
(DataContext as MainWindowViewModel).SearchText = (sender as TextBox).Text;
|
||||||
|
|
|
||||||
|
|
@ -117,9 +117,43 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
private bool _isActive;
|
private bool _isActive;
|
||||||
private bool _isSubMenuOpen;
|
private bool _isSubMenuOpen;
|
||||||
|
|
||||||
public ApplicationData ListSelectedApplication;
|
private ApplicationData _listSelectedApplication;
|
||||||
public ApplicationData GridSelectedApplication;
|
private ApplicationData _gridSelectedApplication;
|
||||||
|
private ApplicationContextMenu _listAppContextMenu;
|
||||||
|
private ApplicationContextMenu _gridAppContextMenu;
|
||||||
|
|
||||||
|
public ApplicationData ListSelectedApplication
|
||||||
|
{
|
||||||
|
get => _listSelectedApplication;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_listSelectedApplication = value;
|
||||||
|
|
||||||
|
if (_listSelectedApplication != null && _listAppContextMenu == null)
|
||||||
|
ListAppContextMenu = new ApplicationContextMenu();
|
||||||
|
else if (_listSelectedApplication == null && _listAppContextMenu != null)
|
||||||
|
ListAppContextMenu = null;
|
||||||
|
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationData GridSelectedApplication
|
||||||
|
{
|
||||||
|
get => _gridSelectedApplication;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gridSelectedApplication = value;
|
||||||
|
|
||||||
|
if (_gridSelectedApplication != null && _gridAppContextMenu == null)
|
||||||
|
GridAppContextMenu = new ApplicationContextMenu();
|
||||||
|
else if (_gridSelectedApplication == null && _gridAppContextMenu != null)
|
||||||
|
GridAppContextMenu = null;
|
||||||
|
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<LdnGameData> LastLdnGameData;
|
public IEnumerable<LdnGameData> LastLdnGameData;
|
||||||
|
|
||||||
internal AppHost AppHost { get; set; }
|
internal AppHost AppHost { get; set; }
|
||||||
|
|
@ -229,6 +263,28 @@ namespace Ryujinx.Ava.UI.ViewModels
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ApplicationContextMenu ListAppContextMenu
|
||||||
|
{
|
||||||
|
get => _listAppContextMenu;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_listAppContextMenu = value;
|
||||||
|
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ApplicationContextMenu GridAppContextMenu
|
||||||
|
{
|
||||||
|
get => _gridAppContextMenu;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_gridAppContextMenu = value;
|
||||||
|
|
||||||
|
OnPropertyChanged();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public bool IsPaused
|
public bool IsPaused
|
||||||
{
|
{
|
||||||
get => _isPaused;
|
get => _isPaused;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue