mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Meta - Fixed a whole bunch of warnings
This commit is contained in:
parent
503cc89cd5
commit
1c15fbe983
@ -256,6 +256,18 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public event EventHandler? RenderPropertiesUpdated;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Activate()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Deactivate()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
|
||||
@ -13,7 +13,7 @@ namespace Artemis.Core
|
||||
/// <summary>
|
||||
/// Creates a list containing a tuple for each value in the enum type
|
||||
/// </summary>
|
||||
/// <param name="t">The enum type to create value descriptions for</param>
|
||||
/// <typeparam name="T">The enum type to create value descriptions for</typeparam>
|
||||
/// <returns>A list containing a value-description tuple for each value in the enum type</returns>
|
||||
public static List<(T, string)> GetAllValuesAndDescriptions<T>() where T : struct, Enum
|
||||
{
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -4,16 +4,26 @@
|
||||
<name>Artemis.UI.Shared</name>
|
||||
</assembly>
|
||||
<members>
|
||||
<member name="T:Artemis.UI.Shared.Controls.ArtemisIcon">
|
||||
<summary>
|
||||
Represents a control that can display an arbitrary kind of icon.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Controls.ArtemisIcon.#ctor">
|
||||
<summary>
|
||||
Creates a new instance of the <see cref="T:Artemis.UI.Shared.Controls.ArtemisIcon" /> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Artemis.UI.Shared.Controls.ArtemisIcon.IconProperty">
|
||||
<summary>
|
||||
Gets or sets the currently displayed icon as either a <see cref="T:Material.Icons.MaterialIconKind" /> or an <see cref="T:System.Uri" /> pointing
|
||||
to an SVG
|
||||
Gets or sets the currently displayed icon as either a <see cref="T:Material.Icons.MaterialIconKind" /> or an <see cref="T:System.Uri" />
|
||||
pointing to an SVG
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Artemis.UI.Shared.Controls.ArtemisIcon.Icon">
|
||||
<summary>
|
||||
Gets or sets the currently displayed icon as either a <see cref="T:Material.Icons.MaterialIconKind" /> or an <see cref="T:System.Uri" /> pointing
|
||||
to an SVG
|
||||
Gets or sets the currently displayed icon as either a <see cref="T:Material.Icons.MaterialIconKind" /> or an <see cref="T:System.Uri" />
|
||||
pointing to an SVG
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Artemis.UI.Shared.Controls.DeviceVisualizer">
|
||||
@ -80,11 +90,21 @@
|
||||
<member name="M:Artemis.UI.Shared.Controls.DeviceVisualizer.MeasureOverride(Avalonia.Size)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="T:Artemis.UI.Shared.Controls.EnumComboBox">
|
||||
<summary>
|
||||
Represents a combobox that can display the values of an enum.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Artemis.UI.Shared.Controls.EnumComboBox.ValueProperty">
|
||||
<summary>
|
||||
Gets or sets the currently selected value
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Controls.EnumComboBox.#ctor">
|
||||
<summary>
|
||||
Creates a new instance of the <see cref="T:Artemis.UI.Shared.Controls.EnumComboBox" /> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Artemis.UI.Shared.Controls.EnumComboBox.Value">
|
||||
<summary>
|
||||
Gets or sets the currently selected value
|
||||
@ -126,6 +146,16 @@
|
||||
<member name="M:Artemis.UI.Shared.Controls.NoInputTextBox.OnKeyUp(Avalonia.Input.KeyEventArgs)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="T:Artemis.UI.Shared.Controls.ProfileConfigurationIcon">
|
||||
<summary>
|
||||
Represents a control that can display the icon of a specific <see cref="T:Artemis.Core.ProfileConfiguration"/>.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Controls.ProfileConfigurationIcon.#ctor">
|
||||
<summary>
|
||||
Creates a new instance of the <see cref="T:Artemis.UI.Shared.Controls.ProfileConfigurationIcon" /> class.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Artemis.UI.Shared.Controls.ProfileConfigurationIcon.ConfigurationIconProperty">
|
||||
<summary>
|
||||
Gets or sets the <see cref="T:Artemis.Core.ProfileConfigurationIcon" /> to display
|
||||
@ -158,7 +188,17 @@
|
||||
</member>
|
||||
<member name="F:Artemis.UI.Shared.Controls.SelectionRectangle.InputElementProperty">
|
||||
<summary>
|
||||
Defines the <see cref="M:Artemis.UI.Shared.Controls.SelectionRectangle.get_InputElement" /> property.
|
||||
Defines the <see cref="P:Artemis.UI.Shared.Controls.SelectionRectangle.InputElement" /> property.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Artemis.UI.Shared.Controls.SelectionRectangle.SelectionUpdatedProperty">
|
||||
<summary>
|
||||
Defines the <see cref="P:Artemis.UI.Shared.Controls.SelectionRectangle.SelectionUpdated" /> property.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="F:Artemis.UI.Shared.Controls.SelectionRectangle.SelectionFinishedProperty">
|
||||
<summary>
|
||||
Defines the <see cref="P:Artemis.UI.Shared.Controls.SelectionRectangle.SelectionFinished" /> property.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Controls.SelectionRectangle.#ctor">
|
||||
@ -179,6 +219,24 @@
|
||||
Gets or sets the width of the control's border
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Artemis.UI.Shared.Controls.SelectionRectangle.InputElement">
|
||||
<summary>
|
||||
Gets or sets the element that captures input for the selection rectangle.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Artemis.UI.Shared.Controls.SelectionRectangle.SelectionUpdated">
|
||||
<summary>
|
||||
Gets or sets the command to execute when the selection has been updated.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="P:Artemis.UI.Shared.Controls.SelectionRectangle.SelectionFinished">
|
||||
<summary>
|
||||
Gets or sets the command to execute when the selection has finished.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Controls.SelectionRectangle.Render(Avalonia.Media.DrawingContext)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Controls.SelectionRectangle.OnAttachedToVisualTree(Avalonia.VisualTreeAttachmentEventArgs)">
|
||||
<inheritdoc />
|
||||
</member>
|
||||
@ -781,10 +839,96 @@
|
||||
Adds the provided extension to the filter
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Artemis.UI.Shared.Services.Builders.NotificationBuilder">
|
||||
<summary>
|
||||
Represents a builder that can be used to create notifications.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationBuilder.#ctor(Avalonia.Controls.Window)">
|
||||
<summary>
|
||||
Creates a new instance of the <see cref="T:Artemis.UI.Shared.Services.Builders.NotificationBuilder" /> class.
|
||||
</summary>
|
||||
<param name="parent">The parent window that will host the notification.</param>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationBuilder.WithTitle(System.String)">
|
||||
<summary>
|
||||
Changes the title of the notification.
|
||||
</summary>
|
||||
<param name="title">The new title.</param>
|
||||
<returns>The notification builder that can be used to further build the notification.</returns>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationBuilder.WithMessage(System.String)">
|
||||
<summary>
|
||||
Changes the message of the notification.
|
||||
</summary>
|
||||
<param name="content">The new message.</param>
|
||||
<returns>The notification builder that can be used to further build the notification.</returns>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationBuilder.WithTimeout(System.TimeSpan)">
|
||||
<summary>
|
||||
Changes the timeout of the notification after which it disappears automatically.
|
||||
</summary>
|
||||
<param name="timeout">The timeout of the notification after which it disappears automatically.</param>
|
||||
<returns>The notification builder that can be used to further build the notification.</returns>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationBuilder.WithVerticalPosition(Avalonia.Layout.VerticalAlignment)">
|
||||
<summary>
|
||||
Changes the vertical position of the notification inside the parent window.
|
||||
</summary>
|
||||
<param name="position">The vertical position of the notification inside the parent window.</param>
|
||||
<returns>The notification builder that can be used to further build the notification.</returns>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationBuilder.WithHorizontalPosition(Avalonia.Layout.HorizontalAlignment)">
|
||||
<summary>
|
||||
Changes the horizontal position of the notification inside the parent window.
|
||||
</summary>
|
||||
<param name="position">The horizontal position of the notification inside the parent window.</param>
|
||||
<returns>The notification builder that can be used to further build the notification.</returns>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationBuilder.WithSeverity(Artemis.UI.Shared.Services.Builders.NotificationSeverity)">
|
||||
<summary>
|
||||
Changes the severity (color) of the notification.
|
||||
</summary>
|
||||
<param name="severity">The severity (color) of the notification.</param>
|
||||
<returns>The notification builder that can be used to further build the notification.</returns>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationBuilder.HavingButton(System.Action{Artemis.UI.Shared.Services.Builders.NotificationButtonBuilder})">
|
||||
<summary>
|
||||
Add a filter to the dialog
|
||||
Changes the action button of the dialog.
|
||||
</summary>
|
||||
<param name="configure">An action to configure the button.</param>
|
||||
<returns>The notification builder that can be used to further build the notification.</returns>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationBuilder.Show">
|
||||
<summary>
|
||||
Shows the notification.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="T:Artemis.UI.Shared.Services.Builders.NotificationButtonBuilder">
|
||||
<summary>
|
||||
Represents a builder that can be used to create buttons inside notifications.
|
||||
</summary>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationButtonBuilder.WithText(System.String)">
|
||||
<summary>
|
||||
Changes text message of the button.
|
||||
</summary>
|
||||
<param name="text">The new text.</param>
|
||||
<returns>The notification builder that can be used to further build the button.</returns>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationButtonBuilder.WithAction(System.Action)">
|
||||
<summary>
|
||||
Changes action that is called when the button is clicked.
|
||||
</summary>
|
||||
<param name="action">The action to call when the button is clicked.</param>
|
||||
<returns>The notification builder that can be used to further build the button.</returns>
|
||||
</member>
|
||||
<member name="M:Artemis.UI.Shared.Services.Builders.NotificationButtonBuilder.WithCommand(System.Windows.Input.ICommand)">
|
||||
<summary>
|
||||
Changes command that is called when the button is clicked.
|
||||
</summary>
|
||||
<param name="command">The command to call when the button is clicked.</param>
|
||||
<returns>The notification builder that can be used to further build the button.</returns>
|
||||
</member>
|
||||
<member name="T:Artemis.UI.Shared.Services.Builders.OpenFileDialogBuilder">
|
||||
<summary>
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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());
|
||||
}
|
||||
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<AvaloniaResource Include="Assets\**" />
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -3,6 +3,7 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<AvaloniaResource Include="Assets\**" />
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
<ApplicationIcon />
|
||||
<StartupObject />
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
|
||||
<DocumentationFile>C:\Repos\Artemis\src\Artemis.UI.Avalonia.Shared\Artemis.UI.Avalonia.Shared.xml</DocumentationFile>
|
||||
|
||||
@ -10,34 +10,25 @@ using Material.Icons.Avalonia;
|
||||
|
||||
namespace Artemis.UI.Shared.Controls
|
||||
{
|
||||
public partial class ArtemisIcon : UserControl
|
||||
/// <summary>
|
||||
/// Represents a control that can display an arbitrary kind of icon.
|
||||
/// </summary>
|
||||
public class ArtemisIcon : UserControl
|
||||
{
|
||||
#region Properties
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the currently displayed icon as either a <see cref="MaterialIconKind" /> or an <see cref="Uri" /> pointing
|
||||
/// to an SVG
|
||||
/// Creates a new instance of the <see cref="ArtemisIcon" /> class.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<object?> IconProperty =
|
||||
AvaloniaProperty.Register<ArtemisIcon, object?>(nameof(Icon), notifying: IconChanging);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the currently displayed icon as either a <see cref="MaterialIconKind" /> or an <see cref="Uri" /> pointing
|
||||
/// to an SVG
|
||||
/// </summary>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the currently displayed icon as either a <see cref="MaterialIconKind" /> or an <see cref="Uri" />
|
||||
/// pointing to an SVG
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<object?> IconProperty =
|
||||
AvaloniaProperty.Register<ArtemisIcon, object?>(nameof(Icon), notifying: IconChanging);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the currently displayed icon as either a <see cref="MaterialIconKind" /> or an <see cref="Uri" />
|
||||
/// pointing to an SVG
|
||||
/// </summary>
|
||||
public object? Icon
|
||||
{
|
||||
get => GetValue(IconProperty);
|
||||
set => SetValue(IconProperty, value);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@ -10,14 +10,29 @@ using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Artemis.UI.Shared.Controls
|
||||
{
|
||||
public partial class EnumComboBox : UserControl
|
||||
/// <summary>
|
||||
/// Represents a combobox that can display the values of an enum.
|
||||
/// </summary>
|
||||
public class EnumComboBox : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the currently selected value
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<object?> ValueProperty =
|
||||
public static readonly StyledProperty<object?> ValueProperty =
|
||||
AvaloniaProperty.Register<EnumComboBox, object?>(nameof(Value), defaultBindingMode: BindingMode.TwoWay, notifying: ValueChanged);
|
||||
|
||||
private readonly ObservableCollection<(Enum, string)> _currentValues = new();
|
||||
|
||||
private ComboBox? _enumComboBox;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="EnumComboBox" /> class.
|
||||
/// </summary>
|
||||
public EnumComboBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the currently selected value
|
||||
/// </summary>
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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();
|
||||
}
|
||||
|
||||
@ -12,8 +12,14 @@ using Material.Icons.Avalonia;
|
||||
|
||||
namespace Artemis.UI.Shared.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a control that can display the icon of a specific <see cref="ProfileConfiguration"/>.
|
||||
/// </summary>
|
||||
public class ProfileConfigurationIcon : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="ProfileConfigurationIcon" /> class.
|
||||
/// </summary>
|
||||
public ProfileConfigurationIcon()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
@ -19,14 +19,14 @@ namespace Artemis.UI.Shared.Controls
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<IBrush> BackgroundProperty =
|
||||
AvaloniaProperty.Register<SelectionRectangle, IBrush>(nameof(Background),
|
||||
new SolidColorBrush(AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>().CustomAccentColor ?? Colors.Transparent, 0.25));
|
||||
new SolidColorBrush(AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>()?.CustomAccentColor ?? Colors.Transparent, 0.25));
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="BorderBrush" /> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<IBrush> BorderBrushProperty =
|
||||
AvaloniaProperty.Register<SelectionRectangle, IBrush>(nameof(BorderBrush),
|
||||
new SolidColorBrush(AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>().CustomAccentColor ?? Colors.Transparent));
|
||||
new SolidColorBrush(AvaloniaLocator.Current.GetService<FluentAvaloniaTheme>()?.CustomAccentColor ?? Colors.Transparent));
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="BorderBrush" /> property.
|
||||
@ -35,14 +35,20 @@ namespace Artemis.UI.Shared.Controls
|
||||
AvaloniaProperty.Register<SelectionRectangle, double>(nameof(BorderThickness), 1);
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="get_InputElement" /> property.
|
||||
/// Defines the <see cref="InputElement" /> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<IControl?> InputElementProperty =
|
||||
AvaloniaProperty.Register<SelectionRectangle, IControl?>(nameof(InputElement), notifying: OnInputElementChanged);
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="SelectionUpdated" /> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<ICommand?> SelectionUpdatedProperty
|
||||
= AvaloniaProperty.Register<SelectionRectangle, ICommand?>(nameof(SelectionUpdated));
|
||||
|
||||
/// <summary>
|
||||
/// Defines the <see cref="SelectionFinished" /> property.
|
||||
/// </summary>
|
||||
public static readonly StyledProperty<ICommand?> SelectionFinishedProperty
|
||||
= AvaloniaProperty.Register<SelectionRectangle, ICommand?>(nameof(SelectionUpdated));
|
||||
|
||||
@ -84,18 +90,27 @@ namespace Artemis.UI.Shared.Controls
|
||||
set => SetValue(BorderThicknessProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the element that captures input for the selection rectangle.
|
||||
/// </summary>
|
||||
public IControl? InputElement
|
||||
{
|
||||
get => GetValue(InputElementProperty);
|
||||
set => SetValue(InputElementProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the command to execute when the selection has been updated.
|
||||
/// </summary>
|
||||
public ICommand? SelectionUpdated
|
||||
{
|
||||
get => GetValue(SelectionUpdatedProperty);
|
||||
set => SetValue(SelectionUpdatedProperty, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the command to execute when the selection has finished.
|
||||
/// </summary>
|
||||
public ICommand? SelectionFinished
|
||||
{
|
||||
get => GetValue(SelectionFinishedProperty);
|
||||
@ -168,6 +183,7 @@ namespace Artemis.UI.Shared.Controls
|
||||
|
||||
#region Overrides of Visual
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Render(DrawingContext drawingContext)
|
||||
{
|
||||
if (_displayRect != null)
|
||||
|
||||
@ -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
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a builder that can be used to create notifications.
|
||||
/// </summary>
|
||||
public class NotificationBuilder
|
||||
{
|
||||
private readonly InfoBar _infoBar;
|
||||
private readonly Window _parent;
|
||||
private TimeSpan _timeout = TimeSpan.FromSeconds(5);
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new instance of the <see cref="NotificationBuilder" /> class.
|
||||
/// </summary>
|
||||
/// <param name="parent">The parent window that will host the notification.</param>
|
||||
public NotificationBuilder(Window parent)
|
||||
{
|
||||
_parent = parent;
|
||||
@ -26,30 +34,55 @@ namespace Artemis.UI.Shared.Services.Builders
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the title of the notification.
|
||||
/// </summary>
|
||||
/// <param name="title">The new title.</param>
|
||||
/// <returns>The notification builder that can be used to further build the notification.</returns>
|
||||
public NotificationBuilder WithTitle(string? title)
|
||||
{
|
||||
_infoBar.Title = title;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the message of the notification.
|
||||
/// </summary>
|
||||
/// <param name="content">The new message.</param>
|
||||
/// <returns>The notification builder that can be used to further build the notification.</returns>
|
||||
public NotificationBuilder WithMessage(string? content)
|
||||
{
|
||||
_infoBar.Message = content;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the timeout of the notification after which it disappears automatically.
|
||||
/// </summary>
|
||||
/// <param name="timeout">The timeout of the notification after which it disappears automatically.</param>
|
||||
/// <returns>The notification builder that can be used to further build the notification.</returns>
|
||||
public NotificationBuilder WithTimeout(TimeSpan timeout)
|
||||
{
|
||||
_timeout = timeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the vertical position of the notification inside the parent window.
|
||||
/// </summary>
|
||||
/// <param name="position">The vertical position of the notification inside the parent window.</param>
|
||||
/// <returns>The notification builder that can be used to further build the notification.</returns>
|
||||
public NotificationBuilder WithVerticalPosition(VerticalAlignment position)
|
||||
{
|
||||
_infoBar.VerticalAlignment = position;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the horizontal position of the notification inside the parent window.
|
||||
/// </summary>
|
||||
/// <param name="position">The horizontal position of the notification inside the parent window.</param>
|
||||
/// <returns>The notification builder that can be used to further build the notification.</returns>
|
||||
public NotificationBuilder WithHorizontalPosition(HorizontalAlignment position)
|
||||
{
|
||||
_infoBar.HorizontalAlignment = position;
|
||||
@ -57,8 +90,21 @@ namespace Artemis.UI.Shared.Services.Builders
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add a filter to the dialog
|
||||
/// Changes the severity (color) of the notification.
|
||||
/// </summary>
|
||||
/// <param name="severity">The severity (color) of the notification.</param>
|
||||
/// <returns>The notification builder that can be used to further build the notification.</returns>
|
||||
public NotificationBuilder WithSeverity(NotificationSeverity severity)
|
||||
{
|
||||
_infoBar.Severity = (InfoBarSeverity) severity;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes the action button of the dialog.
|
||||
/// </summary>
|
||||
/// <param name="configure">An action to configure the button.</param>
|
||||
/// <returns>The notification builder that can be used to further build the notification.</returns>
|
||||
public NotificationBuilder HavingButton(Action<NotificationButtonBuilder> 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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Shows the notification.
|
||||
/// </summary>
|
||||
public void Show()
|
||||
{
|
||||
if (_parent.Content is not Panel panel)
|
||||
@ -103,28 +146,57 @@ namespace Artemis.UI.Shared.Services.Builders
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents a builder that can be used to create buttons inside notifications.
|
||||
/// </summary>
|
||||
public class NotificationButtonBuilder
|
||||
{
|
||||
private string _text = "Text";
|
||||
private Action? _action;
|
||||
private ICommand? _command;
|
||||
private string _text = "Text";
|
||||
|
||||
/// <summary>
|
||||
/// Changes text message of the button.
|
||||
/// </summary>
|
||||
/// <param name="text">The new text.</param>
|
||||
/// <returns>The notification builder that can be used to further build the button.</returns>
|
||||
public NotificationButtonBuilder WithText(string text)
|
||||
{
|
||||
_text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Changes action that is called when the button is clicked.
|
||||
/// </summary>
|
||||
/// <param name="action">The action to call when the button is clicked.</param>
|
||||
/// <returns>The notification builder that can be used to further build the button.</returns>
|
||||
public NotificationButtonBuilder WithAction(Action action)
|
||||
{
|
||||
_command = null;
|
||||
_action = action;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IControl Build()
|
||||
/// <summary>
|
||||
/// Changes command that is called when the button is clicked.
|
||||
/// </summary>
|
||||
/// <param name="command">The command to call when the button is clicked.</param>
|
||||
/// <returns>The notification builder that can be used to further build the button.</returns>
|
||||
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};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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));
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<OutputPath>bin\</OutputPath>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<AvaloniaResource Include="Assets\**" />
|
||||
|
||||
@ -46,14 +46,14 @@ namespace Artemis.UI.Screens.ProfileEditor.Commands
|
||||
{
|
||||
_isRemoved = true;
|
||||
_target.RemoveChild(_subject);
|
||||
_target.Deactivate();
|
||||
_subject.Deactivate();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Undo()
|
||||
{
|
||||
_isRemoved = false;
|
||||
_target.Activate();
|
||||
_subject.Activate();
|
||||
_target.AddChild(_subject, _index);
|
||||
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user