diff --git a/src/Artemis.Core/Models/Profile/Folder.cs b/src/Artemis.Core/Models/Profile/Folder.cs index 47e0694c6..52296fb74 100644 --- a/src/Artemis.Core/Models/Profile/Folder.cs +++ b/src/Artemis.Core/Models/Profile/Folder.cs @@ -256,6 +256,18 @@ namespace Artemis.Core /// public event EventHandler? RenderPropertiesUpdated; + /// + public override void Activate() + { + throw new NotImplementedException(); + } + + /// + public override void Deactivate() + { + throw new NotImplementedException(); + } + /// protected override void Dispose(bool disposing) { diff --git a/src/Artemis.Core/Utilities/EnumUtilities.cs b/src/Artemis.Core/Utilities/EnumUtilities.cs index 31cce8113..1efe771d6 100644 --- a/src/Artemis.Core/Utilities/EnumUtilities.cs +++ b/src/Artemis.Core/Utilities/EnumUtilities.cs @@ -13,7 +13,7 @@ namespace Artemis.Core /// /// Creates a list containing a tuple for each value in the enum type /// - /// The enum type to create value descriptions for + /// The enum type to create value descriptions for /// A list containing a value-description tuple for each value in the enum type public static List<(T, string)> GetAllValuesAndDescriptions() where T : struct, Enum { diff --git a/src/Artemis.Core/Utilities/MaxStack.cs b/src/Artemis.Core/Utilities/MaxStack.cs index 8767522d2..8af6f9a2b 100644 --- a/src/Artemis.Core/Utilities/MaxStack.cs +++ b/src/Artemis.Core/Utilities/MaxStack.cs @@ -45,7 +45,7 @@ namespace Artemis.Core { if (_list.Count > 0) { - T value = _list.First.Value; + T value = _list.First!.Value; _list.RemoveFirst(); return value; } @@ -61,7 +61,7 @@ namespace Artemis.Core { if (_list.Count > 0) { - T value = _list.First.Value; + T value = _list.First!.Value; return value; } else @@ -92,7 +92,7 @@ namespace Artemis.Core bool result = false; if (this.Count > 0) { - result = Peek().Equals(value); + result = Peek()!.Equals(value); } return result; } diff --git a/src/Artemis.UI.Avalonia.Shared/Artemis.UI.Avalonia.Shared.xml b/src/Artemis.UI.Avalonia.Shared/Artemis.UI.Avalonia.Shared.xml index 02a5517ec..9f20fca3a 100644 --- a/src/Artemis.UI.Avalonia.Shared/Artemis.UI.Avalonia.Shared.xml +++ b/src/Artemis.UI.Avalonia.Shared/Artemis.UI.Avalonia.Shared.xml @@ -4,16 +4,26 @@ Artemis.UI.Shared + + + Represents a control that can display an arbitrary kind of icon. + + + + + Creates a new instance of the class. + + - Gets or sets the currently displayed icon as either a or an pointing - to an SVG + Gets or sets the currently displayed icon as either a or an + pointing to an SVG - Gets or sets the currently displayed icon as either a or an pointing - to an SVG + Gets or sets the currently displayed icon as either a or an + pointing to an SVG @@ -80,11 +90,21 @@ + + + Represents a combobox that can display the values of an enum. + + Gets or sets the currently selected value + + + Creates a new instance of the class. + + Gets or sets the currently selected value @@ -126,6 +146,16 @@ + + + Represents a control that can display the icon of a specific . + + + + + Creates a new instance of the class. + + Gets or sets the to display @@ -158,7 +188,17 @@ - Defines the property. + Defines the property. + + + + + Defines the property. + + + + + Defines the property. @@ -179,6 +219,24 @@ Gets or sets the width of the control's border + + + Gets or sets the element that captures input for the selection rectangle. + + + + + Gets or sets the command to execute when the selection has been updated. + + + + + Gets or sets the command to execute when the selection has finished. + + + + + @@ -781,10 +839,96 @@ Adds the provided extension to the filter + + + Represents a builder that can be used to create notifications. + + + + + Creates a new instance of the class. + + The parent window that will host the notification. + + + + Changes the title of the notification. + + The new title. + The notification builder that can be used to further build the notification. + + + + Changes the message of the notification. + + The new message. + The notification builder that can be used to further build the notification. + + + + Changes the timeout of the notification after which it disappears automatically. + + The timeout of the notification after which it disappears automatically. + The notification builder that can be used to further build the notification. + + + + Changes the vertical position of the notification inside the parent window. + + The vertical position of the notification inside the parent window. + The notification builder that can be used to further build the notification. + + + + Changes the horizontal position of the notification inside the parent window. + + The horizontal position of the notification inside the parent window. + The notification builder that can be used to further build the notification. + + + + Changes the severity (color) of the notification. + + The severity (color) of the notification. + The notification builder that can be used to further build the notification. + - Add a filter to the dialog + Changes the action button of the dialog. + An action to configure the button. + The notification builder that can be used to further build the notification. + + + + Shows the notification. + + + + + Represents a builder that can be used to create buttons inside notifications. + + + + + Changes text message of the button. + + The new text. + The notification builder that can be used to further build the button. + + + + Changes action that is called when the button is clicked. + + The action to call when the button is clicked. + The notification builder that can be used to further build the button. + + + + Changes command that is called when the button is clicked. + + The command to call when the button is clicked. + The notification builder that can be used to further build the button. diff --git a/src/Artemis.UI/packages.lock.json b/src/Artemis.UI/packages.lock.json index e5ce3ca56..6f1ac5c24 100644 --- a/src/Artemis.UI/packages.lock.json +++ b/src/Artemis.UI/packages.lock.json @@ -128,6 +128,15 @@ "resolved": "1.0.0-prerelease1", "contentHash": "aaCPk++kr1TaV/qWYeol5975IN3XifDuuQ9wrCD+nw1cy05BMdGVhuQ72ITb0YRBedssd/btkM51ZABsBd8CEQ==" }, + "RGB.NET.Layout": { + "type": "Direct", + "requested": "[1.0.0-prerelease1, )", + "resolved": "1.0.0-prerelease1", + "contentHash": "nbaHbcY59tzFSeTDbImhrcR1ZyJpoC0x6WawXdtGXO7x3F91ajM7kM5SJwi/5jHdD61vGV0ARuznmR8ErAWegQ==", + "dependencies": { + "RGB.NET.Core": "1.0.0-prerelease1" + } + }, "Serilog": { "type": "Direct", "requested": "[2.10.0, )", @@ -401,14 +410,6 @@ "Microsoft.Extensions.ObjectPool": "5.0.9" } }, - "RGB.NET.Layout": { - "type": "Transitive", - "resolved": "1.0.0-prerelease1", - "contentHash": "nbaHbcY59tzFSeTDbImhrcR1ZyJpoC0x6WawXdtGXO7x3F91ajM7kM5SJwi/5jHdD61vGV0ARuznmR8ErAWegQ==", - "dependencies": { - "RGB.NET.Core": "1.0.0-prerelease1" - } - }, "RGB.NET.Presets": { "type": "Transitive", "resolved": "1.0.0-prerelease1", diff --git a/src/Avalonia/Artemis.UI.Linux/ApplicationStateManager.cs b/src/Avalonia/Artemis.UI.Linux/ApplicationStateManager.cs index 75d346164..146a90751 100644 --- a/src/Avalonia/Artemis.UI.Linux/ApplicationStateManager.cs +++ b/src/Avalonia/Artemis.UI.Linux/ApplicationStateManager.cs @@ -31,7 +31,7 @@ namespace Artemis.UI.Linux Core.Utilities.RestartRequested += UtilitiesOnRestartRequested; // On OS shutdown dispose the kernel just so device providers get a chance to clean up - if (Application.Current.ApplicationLifetime is IControlledApplicationLifetime controlledApplicationLifetime) + if (Application.Current?.ApplicationLifetime is IControlledApplicationLifetime controlledApplicationLifetime) { controlledApplicationLifetime.Exit += (_, _) => { @@ -118,7 +118,7 @@ namespace Artemis.UI.Linux //TODO: start new instance with correct arguments - if (Application.Current.ApplicationLifetime is IControlledApplicationLifetime controlledApplicationLifetime) + if (Application.Current?.ApplicationLifetime is IControlledApplicationLifetime controlledApplicationLifetime) Dispatcher.UIThread.Post(() => controlledApplicationLifetime.Shutdown()); } @@ -126,7 +126,7 @@ namespace Artemis.UI.Linux { RunForcedShutdownIfEnabled(); - if (Application.Current.ApplicationLifetime is IControlledApplicationLifetime controlledApplicationLifetime) + if (Application.Current?.ApplicationLifetime is IControlledApplicationLifetime controlledApplicationLifetime) Dispatcher.UIThread.Post(() => controlledApplicationLifetime.Shutdown()); } diff --git a/src/Avalonia/Artemis.UI.Linux/Artemis.UI.Linux.csproj b/src/Avalonia/Artemis.UI.Linux/Artemis.UI.Linux.csproj index f2c1ccaf9..31ae6b661 100644 --- a/src/Avalonia/Artemis.UI.Linux/Artemis.UI.Linux.csproj +++ b/src/Avalonia/Artemis.UI.Linux/Artemis.UI.Linux.csproj @@ -3,6 +3,7 @@ WinExe net5.0 enable + x64 diff --git a/src/Avalonia/Artemis.UI.Linux/Providers/Input/LinuxInputEventArgs.cs b/src/Avalonia/Artemis.UI.Linux/Providers/Input/LinuxInputEventArgs.cs index 765d7b514..6c42d78f5 100644 --- a/src/Avalonia/Artemis.UI.Linux/Providers/Input/LinuxInputEventArgs.cs +++ b/src/Avalonia/Artemis.UI.Linux/Providers/Input/LinuxInputEventArgs.cs @@ -1,6 +1,9 @@ +// ReSharper disable UnusedMember.Global + +#pragma warning disable CS0649 namespace Artemis.UI.Linux.Providers.Input { - //https://www.kernel.org/doc/Documentation/input/input.txt + // https://www.kernel.org/doc/Documentation/input/input.txt internal readonly struct LinuxInputEventArgs { internal readonly long TimeSeconds; diff --git a/src/Avalonia/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj b/src/Avalonia/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj index f2c1ccaf9..31ae6b661 100644 --- a/src/Avalonia/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj +++ b/src/Avalonia/Artemis.UI.MacOS/Artemis.UI.MacOS.csproj @@ -3,6 +3,7 @@ WinExe net5.0 enable + x64 diff --git a/src/Avalonia/Artemis.UI.Shared/Artemis.UI.Shared.csproj b/src/Avalonia/Artemis.UI.Shared/Artemis.UI.Shared.csproj index 8b99e3d4d..c6c81a462 100644 --- a/src/Avalonia/Artemis.UI.Shared/Artemis.UI.Shared.csproj +++ b/src/Avalonia/Artemis.UI.Shared/Artemis.UI.Shared.csproj @@ -6,6 +6,7 @@ bin\ + x64 C:\Repos\Artemis\src\Artemis.UI.Avalonia.Shared\Artemis.UI.Avalonia.Shared.xml diff --git a/src/Avalonia/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs b/src/Avalonia/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs index cc68222dd..a115738d5 100644 --- a/src/Avalonia/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs +++ b/src/Avalonia/Artemis.UI.Shared/Controls/ArtemisIcon.axaml.cs @@ -10,34 +10,25 @@ using Material.Icons.Avalonia; namespace Artemis.UI.Shared.Controls { - public partial class ArtemisIcon : UserControl + /// + /// Represents a control that can display an arbitrary kind of icon. + /// + public class ArtemisIcon : UserControl { - #region Properties - /// - /// Gets or sets the currently displayed icon as either a or an pointing - /// to an SVG + /// Creates a new instance of the class. /// - public static readonly StyledProperty IconProperty = - AvaloniaProperty.Register(nameof(Icon), notifying: IconChanging); - - - /// - /// Gets or sets the currently displayed icon as either a or an pointing - /// to an SVG - /// - public object? Icon + public ArtemisIcon() { - get => GetValue(IconProperty); - set => SetValue(IconProperty, value); + InitializeComponent(); + DetachedFromLogicalTree += OnDetachedFromLogicalTree; + LayoutUpdated += OnLayoutUpdated; } - #endregion - private static void IconChanging(IAvaloniaObject sender, bool before) { if (before) - ((ArtemisIcon)sender).Update(); + ((ArtemisIcon) sender).Update(); } private void Update() @@ -46,39 +37,37 @@ namespace Artemis.UI.Shared.Controls { // First look for an enum value instead of a string if (Icon is MaterialIconKind materialIcon) - Content = new MaterialIcon { Kind = materialIcon, Width = Bounds.Width, Height = Bounds.Height }; + { + Content = new MaterialIcon {Kind = materialIcon, Width = Bounds.Width, Height = Bounds.Height}; + } // If it's a string there are several options else if (Icon is string iconString) { // An enum defined as a string if (Enum.TryParse(iconString, true, out MaterialIconKind parsedIcon)) - Content = new MaterialIcon { Kind = parsedIcon, Width = Bounds.Width, Height = Bounds.Height }; + { + Content = new MaterialIcon {Kind = parsedIcon, Width = Bounds.Width, Height = Bounds.Height}; + } // An URI pointing to an SVG else if (iconString.EndsWith(".svg")) { SvgSource source = new(); source.Load(iconString); - Content = new SvgImage { Source = source }; + Content = new SvgImage {Source = source}; } // An URI pointing to a different kind of image else - Content = new Image { Source = new Bitmap(iconString), Width = Bounds.Width, Height = Bounds.Height }; + { + Content = new Image {Source = new Bitmap(iconString), Width = Bounds.Width, Height = Bounds.Height}; + } } } catch { - Content = new MaterialIcon { Kind = MaterialIconKind.QuestionMark, Width = Bounds.Width, Height = Bounds.Height }; + Content = new MaterialIcon {Kind = MaterialIconKind.QuestionMark, Width = Bounds.Width, Height = Bounds.Height}; } } - - public ArtemisIcon() - { - InitializeComponent(); - DetachedFromLogicalTree += OnDetachedFromLogicalTree; - LayoutUpdated += OnLayoutUpdated; - } - private void OnLayoutUpdated(object? sender, EventArgs e) { if (Content is Control contentControl) @@ -100,5 +89,27 @@ namespace Artemis.UI.Shared.Controls { AvaloniaXamlLoader.Load(this); } + + #region Properties + + /// + /// Gets or sets the currently displayed icon as either a or an + /// pointing to an SVG + /// + public static readonly StyledProperty IconProperty = + AvaloniaProperty.Register(nameof(Icon), notifying: IconChanging); + + + /// + /// Gets or sets the currently displayed icon as either a or an + /// pointing to an SVG + /// + public object? Icon + { + get => GetValue(IconProperty); + set => SetValue(IconProperty, value); + } + + #endregion } } \ No newline at end of file diff --git a/src/Avalonia/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs b/src/Avalonia/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs index 48ca943c2..f0663ce77 100644 --- a/src/Avalonia/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs +++ b/src/Avalonia/Artemis.UI.Shared/Controls/EnumComboBox.axaml.cs @@ -10,14 +10,29 @@ using Avalonia.Markup.Xaml; namespace Artemis.UI.Shared.Controls { - public partial class EnumComboBox : UserControl + /// + /// Represents a combobox that can display the values of an enum. + /// + public class EnumComboBox : UserControl { /// /// Gets or sets the currently selected value /// - public static readonly StyledProperty ValueProperty = + public static readonly StyledProperty ValueProperty = AvaloniaProperty.Register(nameof(Value), defaultBindingMode: BindingMode.TwoWay, notifying: ValueChanged); + private readonly ObservableCollection<(Enum, string)> _currentValues = new(); + + private ComboBox? _enumComboBox; + + /// + /// Creates a new instance of the class. + /// + public EnumComboBox() + { + InitializeComponent(); + } + /// /// Gets or sets the currently selected value /// @@ -27,9 +42,6 @@ namespace Artemis.UI.Shared.Controls set => SetValue(ValueProperty, value); } - private ComboBox? _enumComboBox; - private readonly ObservableCollection<(Enum, string)> _currentValues = new(); - private static void ValueChanged(IAvaloniaObject sender, bool before) { if (sender is EnumComboBox enumCombo && !before) @@ -39,11 +51,6 @@ namespace Artemis.UI.Shared.Controls } } - public EnumComboBox() - { - InitializeComponent(); - } - private void InitializeComponent() { AvaloniaXamlLoader.Load(this); @@ -54,7 +61,7 @@ namespace Artemis.UI.Shared.Controls if (_enumComboBox == null) return; - var (enumValue, _) = _currentValues[_enumComboBox.SelectedIndex]; + (Enum enumValue, _) = _currentValues[_enumComboBox.SelectedIndex]; if (!Equals(Value, enumValue)) Value = enumValue; } diff --git a/src/Avalonia/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs b/src/Avalonia/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs index 1607738f0..1b1983b75 100644 --- a/src/Avalonia/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs +++ b/src/Avalonia/Artemis.UI.Shared/Controls/HotkeyBox.axaml.cs @@ -54,7 +54,7 @@ namespace Artemis.UI.Shared.Controls private void DisplayTextBoxOnKeyUp(object? sender, KeyEventArgs e) { if (e.KeyModifiers == KeyModifiers.None) - FocusManager.Instance.Focus(null); + FocusManager.Instance?.Focus(null); e.Handled = true; } @@ -79,7 +79,7 @@ namespace Artemis.UI.Shared.Controls private void Button_OnClick(object? sender, RoutedEventArgs e) { Hotkey = null; - FocusManager.Instance.Focus(null); + FocusManager.Instance?.Focus(null); UpdateDisplayTextBox(); } diff --git a/src/Avalonia/Artemis.UI.Shared/Controls/ProfileConfigurationIcon.axaml.cs b/src/Avalonia/Artemis.UI.Shared/Controls/ProfileConfigurationIcon.axaml.cs index 3037af3a8..b145cb84a 100644 --- a/src/Avalonia/Artemis.UI.Shared/Controls/ProfileConfigurationIcon.axaml.cs +++ b/src/Avalonia/Artemis.UI.Shared/Controls/ProfileConfigurationIcon.axaml.cs @@ -12,8 +12,14 @@ using Material.Icons.Avalonia; namespace Artemis.UI.Shared.Controls { + /// + /// Represents a control that can display the icon of a specific . + /// public class ProfileConfigurationIcon : UserControl { + /// + /// Creates a new instance of the class. + /// public ProfileConfigurationIcon() { InitializeComponent(); diff --git a/src/Avalonia/Artemis.UI.Shared/Controls/SelectionRectangle.cs b/src/Avalonia/Artemis.UI.Shared/Controls/SelectionRectangle.cs index 66257929c..72ec5f1f0 100644 --- a/src/Avalonia/Artemis.UI.Shared/Controls/SelectionRectangle.cs +++ b/src/Avalonia/Artemis.UI.Shared/Controls/SelectionRectangle.cs @@ -19,14 +19,14 @@ namespace Artemis.UI.Shared.Controls /// public static readonly StyledProperty BackgroundProperty = AvaloniaProperty.Register(nameof(Background), - new SolidColorBrush(AvaloniaLocator.Current.GetService().CustomAccentColor ?? Colors.Transparent, 0.25)); + new SolidColorBrush(AvaloniaLocator.Current.GetService()?.CustomAccentColor ?? Colors.Transparent, 0.25)); /// /// Defines the property. /// public static readonly StyledProperty BorderBrushProperty = AvaloniaProperty.Register(nameof(BorderBrush), - new SolidColorBrush(AvaloniaLocator.Current.GetService().CustomAccentColor ?? Colors.Transparent)); + new SolidColorBrush(AvaloniaLocator.Current.GetService()?.CustomAccentColor ?? Colors.Transparent)); /// /// Defines the property. @@ -35,14 +35,20 @@ namespace Artemis.UI.Shared.Controls AvaloniaProperty.Register(nameof(BorderThickness), 1); /// - /// Defines the property. + /// Defines the property. /// public static readonly StyledProperty InputElementProperty = AvaloniaProperty.Register(nameof(InputElement), notifying: OnInputElementChanged); + /// + /// Defines the property. + /// public static readonly StyledProperty SelectionUpdatedProperty = AvaloniaProperty.Register(nameof(SelectionUpdated)); + /// + /// Defines the property. + /// public static readonly StyledProperty SelectionFinishedProperty = AvaloniaProperty.Register(nameof(SelectionUpdated)); @@ -84,18 +90,27 @@ namespace Artemis.UI.Shared.Controls set => SetValue(BorderThicknessProperty, value); } + /// + /// Gets or sets the element that captures input for the selection rectangle. + /// public IControl? InputElement { get => GetValue(InputElementProperty); set => SetValue(InputElementProperty, value); } + /// + /// Gets or sets the command to execute when the selection has been updated. + /// public ICommand? SelectionUpdated { get => GetValue(SelectionUpdatedProperty); set => SetValue(SelectionUpdatedProperty, value); } + /// + /// Gets or sets the command to execute when the selection has finished. + /// public ICommand? SelectionFinished { get => GetValue(SelectionFinishedProperty); @@ -168,6 +183,7 @@ namespace Artemis.UI.Shared.Controls #region Overrides of Visual + /// public override void Render(DrawingContext drawingContext) { if (_displayRect != null) diff --git a/src/Avalonia/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs b/src/Avalonia/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs index e66117255..57167bb6b 100644 --- a/src/Avalonia/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs +++ b/src/Avalonia/Artemis.UI.Shared/Services/Builders/NotificationBuilder.cs @@ -1,5 +1,6 @@ using System; using System.Threading.Tasks; +using System.Windows.Input; using Avalonia.Controls; using Avalonia.Layout; using Avalonia.Threading; @@ -9,12 +10,19 @@ using Button = Avalonia.Controls.Button; namespace Artemis.UI.Shared.Services.Builders { + /// + /// Represents a builder that can be used to create notifications. + /// public class NotificationBuilder { private readonly InfoBar _infoBar; private readonly Window _parent; private TimeSpan _timeout = TimeSpan.FromSeconds(5); + /// + /// Creates a new instance of the class. + /// + /// The parent window that will host the notification. public NotificationBuilder(Window parent) { _parent = parent; @@ -26,30 +34,55 @@ namespace Artemis.UI.Shared.Services.Builders }; } + /// + /// Changes the title of the notification. + /// + /// The new title. + /// The notification builder that can be used to further build the notification. public NotificationBuilder WithTitle(string? title) { _infoBar.Title = title; return this; } + /// + /// Changes the message of the notification. + /// + /// The new message. + /// The notification builder that can be used to further build the notification. public NotificationBuilder WithMessage(string? content) { _infoBar.Message = content; return this; } + /// + /// Changes the timeout of the notification after which it disappears automatically. + /// + /// The timeout of the notification after which it disappears automatically. + /// The notification builder that can be used to further build the notification. public NotificationBuilder WithTimeout(TimeSpan timeout) { _timeout = timeout; return this; } + /// + /// Changes the vertical position of the notification inside the parent window. + /// + /// The vertical position of the notification inside the parent window. + /// The notification builder that can be used to further build the notification. public NotificationBuilder WithVerticalPosition(VerticalAlignment position) { _infoBar.VerticalAlignment = position; return this; } + /// + /// Changes the horizontal position of the notification inside the parent window. + /// + /// The horizontal position of the notification inside the parent window. + /// The notification builder that can be used to further build the notification. public NotificationBuilder WithHorizontalPosition(HorizontalAlignment position) { _infoBar.HorizontalAlignment = position; @@ -57,8 +90,21 @@ namespace Artemis.UI.Shared.Services.Builders } /// - /// Add a filter to the dialog + /// Changes the severity (color) of the notification. /// + /// The severity (color) of the notification. + /// The notification builder that can be used to further build the notification. + public NotificationBuilder WithSeverity(NotificationSeverity severity) + { + _infoBar.Severity = (InfoBarSeverity) severity; + return this; + } + + /// + /// Changes the action button of the dialog. + /// + /// An action to configure the button. + /// The notification builder that can be used to further build the notification. public NotificationBuilder HavingButton(Action configure) { NotificationButtonBuilder builder = new(); @@ -68,12 +114,9 @@ namespace Artemis.UI.Shared.Services.Builders return this; } - public NotificationBuilder WithSeverity(NotificationSeverity severity) - { - _infoBar.Severity = (InfoBarSeverity) severity; - return this; - } - + /// + /// Shows the notification. + /// public void Show() { if (_parent.Content is not Panel panel) @@ -103,28 +146,57 @@ namespace Artemis.UI.Shared.Services.Builders } } + /// + /// Represents a builder that can be used to create buttons inside notifications. + /// public class NotificationButtonBuilder { - private string _text = "Text"; private Action? _action; + private ICommand? _command; + private string _text = "Text"; + /// + /// Changes text message of the button. + /// + /// The new text. + /// The notification builder that can be used to further build the button. public NotificationButtonBuilder WithText(string text) { _text = text; return this; } + /// + /// Changes action that is called when the button is clicked. + /// + /// The action to call when the button is clicked. + /// The notification builder that can be used to further build the button. public NotificationButtonBuilder WithAction(Action action) { + _command = null; _action = action; return this; } - public IControl Build() + /// + /// Changes command that is called when the button is clicked. + /// + /// The command to call when the button is clicked. + /// The notification builder that can be used to further build the button. + public NotificationButtonBuilder WithCommand(ICommand command) { - return _action != null - ? new Button {Content = _text, Command = ReactiveCommand.Create(() => _action())} - : new Button {Content = _text}; + _action = null; + _command = command; + return this; + } + + internal IControl Build() + { + if (_action != null) + return new Button {Content = _text, Command = ReactiveCommand.Create(() => _action())}; + if (_command != null) + return new Button {Content = _text, Command = _command}; + return new Button {Content = _text}; } } diff --git a/src/Avalonia/Artemis.UI.Windows/Utilities/ProcessUtilities.cs b/src/Avalonia/Artemis.UI.Windows/Utilities/ProcessUtilities.cs index ea4146487..fc61a664c 100644 --- a/src/Avalonia/Artemis.UI.Windows/Utilities/ProcessUtilities.cs +++ b/src/Avalonia/Artemis.UI.Windows/Utilities/ProcessUtilities.cs @@ -7,7 +7,7 @@ namespace Artemis.UI.Windows.Utilities { public static class ProcessUtilities { - public static Process RunAsDesktopUser(string fileName, string arguments, bool hideWindow) + public static Process? RunAsDesktopUser(string fileName, string arguments, bool hideWindow) { if (string.IsNullOrWhiteSpace(fileName)) throw new ArgumentException("Value cannot be null or whitespace.", nameof(fileName)); diff --git a/src/Avalonia/Artemis.UI/Artemis.UI.csproj b/src/Avalonia/Artemis.UI/Artemis.UI.csproj index 832eb789a..b3f745f09 100644 --- a/src/Avalonia/Artemis.UI/Artemis.UI.csproj +++ b/src/Avalonia/Artemis.UI/Artemis.UI.csproj @@ -4,6 +4,7 @@ net5.0 enable bin\ + x64 diff --git a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Commands/RemoveProfileElement.cs b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Commands/RemoveProfileElement.cs index 54257cf61..6bd983906 100644 --- a/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Commands/RemoveProfileElement.cs +++ b/src/Avalonia/Artemis.UI/Screens/ProfileEditor/Commands/RemoveProfileElement.cs @@ -46,14 +46,14 @@ namespace Artemis.UI.Screens.ProfileEditor.Commands { _isRemoved = true; _target.RemoveChild(_subject); - _target.Deactivate(); + _subject.Deactivate(); } /// public void Undo() { _isRemoved = false; - _target.Activate(); + _subject.Activate(); _target.AddChild(_subject, _index); }