diff --git a/Nitrox.Launcher/MainWindow.axaml.cs b/Nitrox.Launcher/MainWindow.axaml.cs index d71f932044..9a54ccc404 100644 --- a/Nitrox.Launcher/MainWindow.axaml.cs +++ b/Nitrox.Launcher/MainWindow.axaml.cs @@ -34,6 +34,7 @@ public MainWindow() UnhandledExceptionHandler(args.Exception); } }; + RxApp.DefaultExceptionHandler = Observer.Create(UnhandledExceptionHandler); RegisterModal(() => ViewModel!.ErrorDialog); diff --git a/Nitrox.Launcher/Models/Converters/EqualsMultiConveter.cs b/Nitrox.Launcher/Models/Converters/EqualsMultiConveter.cs index 5e84a1bb2e..aded4f65a2 100644 --- a/Nitrox.Launcher/Models/Converters/EqualsMultiConveter.cs +++ b/Nitrox.Launcher/Models/Converters/EqualsMultiConveter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Globalization; using Avalonia.Data.Converters; @@ -11,9 +11,10 @@ namespace Nitrox.Launcher.Models.Converters; /// public class EqualityConverter : Converter, IMultiValueConverter, IValueConverter { - public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException(); public object Convert(object value, Type targetType, object parameter, CultureInfo culture) => Equals(value, parameter); + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotSupportedException(); + public object Convert(IList values, Type targetType, object parameter, CultureInfo culture) { foreach (object val1 in values) diff --git a/Nitrox.Launcher/Models/Converters/ToStringConverter.cs b/Nitrox.Launcher/Models/Converters/ToStringConverter.cs index 05f8398721..25122e87b9 100644 --- a/Nitrox.Launcher/Models/Converters/ToStringConverter.cs +++ b/Nitrox.Launcher/Models/Converters/ToStringConverter.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Globalization; using Avalonia.Data; using Avalonia.Data.Converters; diff --git a/Nitrox.Launcher/Models/Design/Controls/RadioButtonGroup.cs b/Nitrox.Launcher/Models/Design/Controls/RadioButtonGroup.cs index f3301a4803..04b5d3f573 100644 --- a/Nitrox.Launcher/Models/Design/Controls/RadioButtonGroup.cs +++ b/Nitrox.Launcher/Models/Design/Controls/RadioButtonGroup.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Reactive; using Avalonia; using Avalonia.Controls; @@ -12,8 +12,7 @@ public class RadioButtonGroup : ItemsControl, IStyleable public static readonly DirectProperty EnumProperty = AvaloniaProperty.RegisterDirect(nameof(Enum), o => o.Enum, (o, v) => o.Enum = v); public static readonly StyledProperty SelectedItemProperty = AvaloniaProperty.Register(nameof(SelectedItem)); - public static readonly DirectProperty> ItemClickCommandProperty = - AvaloniaProperty.RegisterDirect>(nameof(ItemClickCommand), o => o.ItemClickCommand, (o, v) => o.ItemClickCommand = v); + public static readonly DirectProperty> ItemClickCommandProperty = AvaloniaProperty.RegisterDirect>(nameof(ItemClickCommand), o => o.ItemClickCommand, (o, v) => o.ItemClickCommand = v); private Type @enum; private ReactiveCommand itemClickCommand; @@ -28,7 +27,8 @@ public Type Enum { return; } - Items = System.Enum.GetValues(value); + + ItemsSource = System.Enum.GetValues(value); SetAndRaise(EnumProperty, ref @enum, value); } } diff --git a/Nitrox.Launcher/Models/Design/MultiDataTemplate.cs b/Nitrox.Launcher/Models/Design/MultiDataTemplate.cs index 53dc6b753c..3a55ea790e 100644 --- a/Nitrox.Launcher/Models/Design/MultiDataTemplate.cs +++ b/Nitrox.Launcher/Models/Design/MultiDataTemplate.cs @@ -1,5 +1,5 @@ -extern alias JB; -using System; +extern alias JB; + using System.Collections.Generic; using Avalonia.Collections; using Avalonia.Controls; @@ -10,8 +10,6 @@ namespace Nitrox.Launcher.Models.Design; -extern alias JB; - /// /// Selects a based on its . /// @@ -34,7 +32,7 @@ public bool Match(object data) return false; } - public IControl Build(object param) + public Control Build(object param) { foreach (DataTemplate template in Content) { @@ -44,6 +42,6 @@ public IControl Build(object param) } } - return new TextBlock { Text = param.ToString() }; + return new TextBlock() { Text = param.ToString() }; } } diff --git a/Nitrox.Launcher/Models/Design/NavigationHeader.cs b/Nitrox.Launcher/Models/Design/NavigationHeader.cs index ee85aca566..66d49f95c4 100644 --- a/Nitrox.Launcher/Models/Design/NavigationHeader.cs +++ b/Nitrox.Launcher/Models/Design/NavigationHeader.cs @@ -1,4 +1,4 @@ -namespace Nitrox.Launcher.Models.Design; +namespace Nitrox.Launcher.Models.Design; public class NavigationHeader : INavigationItem { diff --git a/Nitrox.Launcher/Models/Design/NavigationItem.cs b/Nitrox.Launcher/Models/Design/NavigationItem.cs index 5ede1176cd..589d7de040 100644 --- a/Nitrox.Launcher/Models/Design/NavigationItem.cs +++ b/Nitrox.Launcher/Models/Design/NavigationItem.cs @@ -1,19 +1,22 @@ -using System.Windows.Input; +using System.Windows.Input; using ReactiveUI; namespace Nitrox.Launcher.Models.Design; -internal class NavigationItem : INavigationItem +public class NavigationItem : INavigationItem { private readonly string icon; + public ICommand ClickCommand { get; init; } + public string ToolTipText { get; init; } + public string Text { get; } public string Icon { get => icon; - init => icon = value ?? ""; + init => icon = value ?? string.Empty; } public NavigationItem(string text) diff --git a/Nitrox.Launcher/Models/Design/NitroxAttached.cs b/Nitrox.Launcher/Models/Design/NitroxAttached.cs index 174a8bb712..947d7dc624 100644 --- a/Nitrox.Launcher/Models/Design/NitroxAttached.cs +++ b/Nitrox.Launcher/Models/Design/NitroxAttached.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading.Tasks; using Avalonia; using Avalonia.Controls; @@ -45,12 +45,12 @@ public static void SetSubtext(AvaloniaObject element, string value) public static string GetSubtext(AvaloniaObject element) => element.GetValue(SubtextProperty); - public static object GetFocus(IAvaloniaObject obj) => obj.GetValue(FocusProperty); + public static object GetFocus(AvaloniaObject obj) => obj.GetValue(FocusProperty); /// /// Sets the focus to this control when view is loaded. /// - public static void SetFocus(IAvaloniaObject obj, object value) + public static void SetFocus(AvaloniaObject obj, object value) { static async void TryFocusButton(Button btn) { @@ -79,12 +79,12 @@ static async void TryFocusButton(Button btn) public static bool GetSelected(AvaloniaObject element) => element.GetValue(SelectedProperty); - public static void SetSelected(IAvaloniaObject obj, bool value) => obj.SetValue(SelectedProperty, value); + public static void SetSelected(AvaloniaObject obj, bool value) => obj.SetValue(SelectedProperty, value); - public static ThemeOption GetTheme(IAvaloniaObject avaloniaObject) => (ThemeOption)(avaloniaObject.GetValue(ThemeProperty) ?? ThemeOption.DARK); + public static ThemeOption GetTheme(AvaloniaObject avaloniaObject) => avaloniaObject.GetValue(ThemeProperty); /// /// Sets the theme of the current visual and its children to the given theme. /// - public static void SetTheme(IAvaloniaObject avaloniaObject, ThemeOption value) => avaloniaObject.SetValue(ThemeProperty, value); + public static void SetTheme(AvaloniaObject avaloniaObject, ThemeOption value) => avaloniaObject.SetValue(ThemeProperty, value); } diff --git a/Nitrox.Launcher/Models/Design/TitleBarItem.cs b/Nitrox.Launcher/Models/Design/TitleBarItem.cs index 603faf0428..40d72e4ddb 100644 --- a/Nitrox.Launcher/Models/Design/TitleBarItem.cs +++ b/Nitrox.Launcher/Models/Design/TitleBarItem.cs @@ -1,4 +1,4 @@ -using System.Windows.Input; +using System.Windows.Input; using ReactiveUI; namespace Nitrox.Launcher.Models.Design; diff --git a/Nitrox.Launcher/Nitrox.Launcher.csproj b/Nitrox.Launcher/Nitrox.Launcher.csproj index 90aa7fa1e3..8549b347c9 100644 --- a/Nitrox.Launcher/Nitrox.Launcher.csproj +++ b/Nitrox.Launcher/Nitrox.Launcher.csproj @@ -1,11 +1,14 @@  + $(LangVersion) WinExe net7.0 true + true app.manifest + @@ -15,13 +18,13 @@ - - - - + + + + - + - - + + \ No newline at end of file diff --git a/Nitrox.Launcher/Styles/Nitrox.axaml b/Nitrox.Launcher/Styles/Nitrox.axaml index 8d174b5851..dff9c7249a 100644 --- a/Nitrox.Launcher/Styles/Nitrox.axaml +++ b/Nitrox.Launcher/Styles/Nitrox.axaml @@ -1,5 +1,5 @@ - +