misc: Code cleanup

This commit is contained in:
Evan Husted
2024-10-25 08:34:50 -05:00
parent c69904afc6
commit 281be7ca62
19 changed files with 136 additions and 156 deletions

View File

@@ -31,15 +31,11 @@ namespace Ryujinx.Ava.UI.Applet
public bool DisplayMessageDialog(ControllerAppletUIArgs args)
{
ManualResetEvent dialogCloseEvent = new(false);
bool ignoreApplet = ConfigurationState.Instance.IgnoreApplet;
bool okPressed = false;
if (ignoreApplet)
{
if (ConfigurationState.Instance.IgnoreApplet)
return false;
}
Dispatcher.UIThread.InvokeAsync(async () =>
{
@@ -74,9 +70,9 @@ namespace Ryujinx.Ava.UI.Applet
UserResult response = await ContentDialogHelper.ShowDeferredContentDialog(_parent,
title,
message,
"",
string.Empty,
LocaleManager.Instance[LocaleKeys.DialogOpenSettingsWindowLabel],
"",
string.Empty,
LocaleManager.Instance[LocaleKeys.SettingsButtonClose],
(int)Symbol.Important,
deferEvent,
@@ -179,12 +175,12 @@ namespace Ryujinx.Ava.UI.Applet
{
Title = title,
WindowStartupLocation = WindowStartupLocation.CenterScreen,
Width = 400,
Width = 400
};
object response = await msgDialog.Run();
if (response != null && buttons != null && buttons.Length > 1 && (int)response != buttons.Length - 1)
if (response != null && buttons is { Length: > 1 } && (int)response != buttons.Length - 1)
{
showDetails = true;
}

View File

@@ -24,10 +24,13 @@ namespace Ryujinx.Ava.UI.Applet
public AvaloniaDynamicTextInputHandler(MainWindow parent)
{
_parent = parent;
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).KeyPressed += AvaloniaDynamicTextInputHandler_KeyPressed;
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).KeyRelease += AvaloniaDynamicTextInputHandler_KeyRelease;
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).TextInput += AvaloniaDynamicTextInputHandler_TextInput;
if (_parent.InputManager.KeyboardDriver is AvaloniaKeyboardDriver avaloniaKeyboardDriver)
{
avaloniaKeyboardDriver.KeyPressed += AvaloniaDynamicTextInputHandler_KeyPressed;
avaloniaKeyboardDriver.KeyRelease += AvaloniaDynamicTextInputHandler_KeyRelease;
avaloniaKeyboardDriver.TextInput += AvaloniaDynamicTextInputHandler_TextInput;
}
_hiddenTextBox = _parent.HiddenTextBox;
@@ -44,7 +47,7 @@ namespace Ryujinx.Ava.UI.Applet
TextChangedEvent?.Invoke(text ?? string.Empty, _hiddenTextBox.SelectionStart, _hiddenTextBox.SelectionEnd, false);
}
private void SelectionChanged(int selection)
private void SelectionChanged(int _)
{
TextChangedEvent?.Invoke(_hiddenTextBox.Text ?? string.Empty, _hiddenTextBox.SelectionStart, _hiddenTextBox.SelectionEnd, false);
}
@@ -112,10 +115,13 @@ namespace Ryujinx.Ava.UI.Applet
public void Dispose()
{
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).KeyPressed -= AvaloniaDynamicTextInputHandler_KeyPressed;
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).KeyRelease -= AvaloniaDynamicTextInputHandler_KeyRelease;
(_parent.InputManager.KeyboardDriver as AvaloniaKeyboardDriver).TextInput -= AvaloniaDynamicTextInputHandler_TextInput;
if (_parent.InputManager.KeyboardDriver is AvaloniaKeyboardDriver avaloniaKeyboardDriver)
{
avaloniaKeyboardDriver.KeyPressed -= AvaloniaDynamicTextInputHandler_KeyPressed;
avaloniaKeyboardDriver.KeyRelease -= AvaloniaDynamicTextInputHandler_KeyRelease;
avaloniaKeyboardDriver.TextInput -= AvaloniaDynamicTextInputHandler_TextInput;
}
_textChangedSubscription?.Dispose();
_selectionStartChangedSubscription?.Dispose();
_selectionEndtextChangedSubscription?.Dispose();