diff options
Diffstat (limited to 'src/Ryujinx.Ava/UI/Helpers')
| -rw-r--r-- | src/Ryujinx.Ava/UI/Helpers/GlyphValueConverter.cs | 10 | ||||
| -rw-r--r-- | src/Ryujinx.Ava/UI/Helpers/HotKeyControl.cs | 52 | ||||
| -rw-r--r-- | src/Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs | 15 | ||||
| -rw-r--r-- | src/Ryujinx.Ava/UI/Helpers/OffscreenTextBox.cs | 1 | ||||
| -rw-r--r-- | src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs | 28 |
5 files changed, 29 insertions, 77 deletions
diff --git a/src/Ryujinx.Ava/UI/Helpers/GlyphValueConverter.cs b/src/Ryujinx.Ava/UI/Helpers/GlyphValueConverter.cs index 4e4b971e..7da23648 100644 --- a/src/Ryujinx.Ava/UI/Helpers/GlyphValueConverter.cs +++ b/src/Ryujinx.Ava/UI/Helpers/GlyphValueConverter.cs @@ -1,6 +1,4 @@ -using Avalonia.Data; using Avalonia.Markup.Xaml; -using Avalonia.Markup.Xaml.MarkupExtensions; using FluentAvalonia.UI.Controls; using System; using System.Collections.Generic; @@ -38,13 +36,7 @@ namespace Ryujinx.Ava.UI.Helpers public override object ProvideValue(IServiceProvider serviceProvider) { - ReflectionBindingExtension binding = new($"[{_key}]") - { - Mode = BindingMode.OneWay, - Source = this, - }; - - return binding.ProvideValue(serviceProvider); + return this[_key]; } } } diff --git a/src/Ryujinx.Ava/UI/Helpers/HotKeyControl.cs b/src/Ryujinx.Ava/UI/Helpers/HotKeyControl.cs deleted file mode 100644 index 4ae903b4..00000000 --- a/src/Ryujinx.Ava/UI/Helpers/HotKeyControl.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Avalonia; -using Avalonia.Controls; -using Avalonia.Input; -using System; -using System.Windows.Input; - -namespace Ryujinx.Ava.UI.Helpers -{ - public class HotKeyControl : ContentControl, ICommandSource - { - public static readonly StyledProperty<object> CommandParameterProperty = - AvaloniaProperty.Register<HotKeyControl, object>(nameof(CommandParameter)); - - public static readonly DirectProperty<HotKeyControl, ICommand> CommandProperty = - AvaloniaProperty.RegisterDirect<HotKeyControl, ICommand>(nameof(Command), - control => control.Command, (control, command) => control.Command = command, enableDataValidation: true); - - public static readonly StyledProperty<KeyGesture> HotKeyProperty = HotKeyManager.HotKeyProperty.AddOwner<Button>(); - - private ICommand _command; - private bool _commandCanExecute; - - public ICommand Command - { - get { return _command; } - set { SetAndRaise(CommandProperty, ref _command, value); } - } - - public KeyGesture HotKey - { - get { return GetValue(HotKeyProperty); } - set { SetValue(HotKeyProperty, value); } - } - - public object CommandParameter - { - get { return GetValue(CommandParameterProperty); } - set { SetValue(CommandParameterProperty, value); } - } - - public void CanExecuteChanged(object sender, EventArgs e) - { - var canExecute = Command == null || Command.CanExecute(CommandParameter); - - if (canExecute != _commandCanExecute) - { - _commandCanExecute = canExecute; - UpdateIsEffectivelyEnabled(); - } - } - } -} diff --git a/src/Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs b/src/Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs index dc8e3f94..0b178988 100644 --- a/src/Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs +++ b/src/Ryujinx.Ava/UI/Helpers/LoggerAdapter.cs @@ -42,21 +42,6 @@ namespace Ryujinx.Ava.UI.Helpers GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, null)); } - public void Log<T0>(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0) - { - GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, new object[] { propertyValue0 })); - } - - public void Log<T0, T1>(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1) - { - GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, new object[] { propertyValue0, propertyValue1 })); - } - - public void Log<T0, T1, T2>(AvaLogLevel level, string area, object source, string messageTemplate, T0 propertyValue0, T1 propertyValue1, T2 propertyValue2) - { - GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, new object[] { propertyValue0, propertyValue1, propertyValue2 })); - } - public void Log(AvaLogLevel level, string area, object source, string messageTemplate, params object[] propertyValues) { GetLog(level)?.PrintMsg(RyuLogClass.Ui, Format(level, area, messageTemplate, source, propertyValues)); diff --git a/src/Ryujinx.Ava/UI/Helpers/OffscreenTextBox.cs b/src/Ryujinx.Ava/UI/Helpers/OffscreenTextBox.cs index 670d3b36..a055f335 100644 --- a/src/Ryujinx.Ava/UI/Helpers/OffscreenTextBox.cs +++ b/src/Ryujinx.Ava/UI/Helpers/OffscreenTextBox.cs @@ -31,7 +31,6 @@ namespace Ryujinx.Ava.UI.Helpers OnTextInput(new TextInputEventArgs { Text = text, - Device = KeyboardDevice.Instance, Source = this, RoutedEvent = TextInputEvent, }); diff --git a/src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs b/src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs new file mode 100644 index 00000000..4ec0ff30 --- /dev/null +++ b/src/Ryujinx.Ava/UI/Helpers/TimeZoneConverter.cs @@ -0,0 +1,28 @@ +using Avalonia.Data.Converters; +using System; +using System.Globalization; +using TimeZone = Ryujinx.Ava.UI.Models.TimeZone; + +namespace Ryujinx.Ava.UI.Helpers +{ + internal class TimeZoneConverter : IValueConverter + { + public static TimeZoneConverter Instance = new(); + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + if (value == null) + { + return null; + } + + var timeZone = (TimeZone)value; + return string.Format("{0} {1} {2}", timeZone.UtcDifference, timeZone.Location, timeZone.Abbreviation); + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + throw new NotImplementedException(); + } + } +} |
