Formatting and error

More Ava 11-ness

Whoops
This commit is contained in:
Isaac Marovitz 2023-08-12 11:52:46 +01:00 committed by Isaac Marovitz
parent 5e8eedae37
commit 02b355eebf
12 changed files with 260 additions and 258 deletions

View file

@ -1,7 +1,7 @@
using Avalonia; using Avalonia;
using Avalonia.Data;
using Avalonia.Controls; using Avalonia.Controls;
using Avalonia.Controls.Primitives; using Avalonia.Controls.Primitives;
using Avalonia.Data;
using Avalonia.LogicalTree; using Avalonia.LogicalTree;
using Avalonia.Threading; using Avalonia.Threading;
using Ryujinx.Ava.Common.Locale; using Ryujinx.Ava.Common.Locale;

View file

@ -25,8 +25,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{ {
if (visual is ToggleButton button && !(visual is CheckBox)) if (visual is ToggleButton button && !(visual is CheckBox))
{ {
button.Checked += Button_Checked; button.IsCheckedChanged += Button_IsCheckedChanged;
button.Unchecked += Button_Unchecked;
} }
} }
} }
@ -41,9 +40,11 @@ namespace Ryujinx.Ava.UI.Views.Input
} }
} }
private void Button_Checked(object sender, RoutedEventArgs e) private void Button_IsCheckedChanged(object sender, RoutedEventArgs e)
{ {
if (sender is ToggleButton button) if (sender is ToggleButton button)
{
if ((bool)button.IsChecked)
{ {
if (_currentAssigner != null && button == _currentAssigner.ToggledButton) if (_currentAssigner != null && button == _currentAssigner.ToggledButton)
{ {
@ -56,7 +57,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{ {
_currentAssigner = new ButtonKeyAssigner(button); _currentAssigner = new ButtonKeyAssigner(button);
FocusManager.Instance.Focus(this, NavigationMethod.Pointer); this.Focus(NavigationMethod.Pointer);
PointerPressed += MouseClick; PointerPressed += MouseClick;
@ -156,13 +157,13 @@ namespace Ryujinx.Ava.UI.Views.Input
} }
} }
} }
} else
private void Button_Unchecked(object sender, RoutedEventArgs e)
{ {
_currentAssigner?.Cancel(); _currentAssigner?.Cancel();
_currentAssigner = null; _currentAssigner = null;
} }
}
}
private void MouseClick(object sender, PointerPressedEventArgs e) private void MouseClick(object sender, PointerPressedEventArgs e)
{ {

View file

@ -63,7 +63,7 @@
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Center" VerticalAlignment="Center"
SelectionChanged="PlayerIndexBox_OnSelectionChanged" SelectionChanged="PlayerIndexBox_OnSelectionChanged"
Items="{Binding PlayerIndexes}" ItemsSource="{Binding PlayerIndexes}"
SelectedIndex="{Binding PlayerId}"> SelectedIndex="{Binding PlayerId}">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate> <DataTemplate>
@ -91,14 +91,14 @@
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Center"
Text="{locale:Locale ControllerSettingsProfile}" /> Text="{locale:Locale ControllerSettingsProfile}" />
<ui:ComboBox <ui:FAComboBox
Grid.Column="1" Grid.Column="1"
IsEditable="True" IsEditable="True"
Name="ProfileBox" Name="ProfileBox"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Center" VerticalAlignment="Center"
SelectedIndex="0" SelectedIndex="0"
Items="{Binding ProfilesList}" ItemsSource="{Binding ProfilesList}"
Text="{Binding ProfileName}" /> Text="{Binding ProfileName}" />
<Button <Button
Grid.Column="2" Grid.Column="2"
@ -167,7 +167,7 @@
Name="DeviceBox" Name="DeviceBox"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Center" VerticalAlignment="Center"
Items="{Binding DeviceList}" ItemsSource="{Binding DeviceList}"
SelectedIndex="{Binding Device}" /> SelectedIndex="{Binding Device}" />
<Button <Button
Grid.Column="2" Grid.Column="2"
@ -200,7 +200,7 @@
<ComboBox <ComboBox
Grid.Column="1" Grid.Column="1"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
Items="{ReflectionBinding Controllers}" ItemsSource="{ReflectionBinding Controllers}"
SelectedIndex="{ReflectionBinding Controller}"> SelectedIndex="{ReflectionBinding Controller}">
<ComboBox.ItemTemplate> <ComboBox.ItemTemplate>
<DataTemplate DataType="models:ControllerModel"> <DataTemplate DataType="models:ControllerModel">

View file

@ -24,8 +24,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{ {
if (visual is ToggleButton button && !(visual is CheckBox)) if (visual is ToggleButton button && !(visual is CheckBox))
{ {
button.Checked += Button_Checked; button.IsCheckedChanged += Button_IsCheckedChanged;
button.Unchecked += Button_Unchecked;
} }
} }
} }
@ -40,9 +39,11 @@ namespace Ryujinx.Ava.UI.Views.Input
} }
} }
private void Button_Checked(object sender, RoutedEventArgs e) private void Button_IsCheckedChanged(object sender, RoutedEventArgs e)
{ {
if (sender is ToggleButton button) if (sender is ToggleButton button)
{
if ((bool)button.IsChecked)
{ {
if (_currentAssigner != null && button == _currentAssigner.ToggledButton) if (_currentAssigner != null && button == _currentAssigner.ToggledButton)
{ {
@ -55,7 +56,7 @@ namespace Ryujinx.Ava.UI.Views.Input
{ {
_currentAssigner = new ButtonKeyAssigner(button); _currentAssigner = new ButtonKeyAssigner(button);
FocusManager.Instance.Focus(this, NavigationMethod.Pointer); this.Focus(NavigationMethod.Pointer);
PointerPressed += MouseClick; PointerPressed += MouseClick;
@ -173,13 +174,13 @@ namespace Ryujinx.Ava.UI.Views.Input
} }
} }
} }
} else
private void Button_Unchecked(object sender, RoutedEventArgs e)
{ {
_currentAssigner?.Cancel(); _currentAssigner?.Cancel();
_currentAssigner = null; _currentAssigner = null;
} }
}
}
private void MouseClick(object sender, PointerPressedEventArgs e) private void MouseClick(object sender, PointerPressedEventArgs e)
{ {