1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-13 05:48:35 +00:00

Icons - Dropped SVG support and fixed filling

This commit is contained in:
Robert 2022-06-06 20:54:39 +02:00
parent dd40bdd544
commit 0d3890e560
30 changed files with 163 additions and 571 deletions

View File

@ -14,7 +14,9 @@
<entry key="Artemis.UI.Avalonia/Screens/Sidebar/Views/SidebarProfileConfigurationView.axaml" value="Artemis.UI.Avalonia/Artemis.UI.Avalonia.csproj" />
<entry key="Artemis.UI.Avalonia/Screens/SidebarView.axaml" value="Artemis.UI.Avalonia/Artemis.UI.Avalonia.csproj" />
<entry key="Artemis.UI.Avalonia/Views/MainWindow.axaml" value="Artemis.UI.Avalonia/Artemis.UI.Avalonia.csproj" />
<entry key="Artemis.UI.Shared/Controls/ArtemisIcon.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI.Shared/Controls/EnumComboBox.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI.Shared/Controls/ProfileConfigurationIcon.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI.Shared/Styles/Border.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI.Shared/Styles/TextBlock.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI.Windows/App.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
@ -53,7 +55,8 @@
<entry key="Artemis.UI/Screens/ProfileEditor/Panels/VisualEditor/VisualEditorView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
<entry key="Artemis.UI/Screens/ProfileEditor/ProfileEditorTitleBarView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/ProfileEditor/ProfileEditorView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/Root/SplashView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/Root/SplashView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
<entry key="Artemis.UI/Screens/Settings/Tabs/AboutTabView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/Settings/Tabs/GeneralTabView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/Sidebar/ContentDialogs/SidebarCategoryEditView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/Sidebar/Dialogs/ModuleActivationRequirementView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
@ -69,7 +72,7 @@
<entry key="Artemis.UI/Screens/VisualScripting/NodeScriptView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/VisualScripting/NodeScriptWindowView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
<entry key="Artemis.UI/Screens/VisualScripting/NodeView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/Workshop/WorkshopView.axaml" value="Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Artemis.UI/Screens/Workshop/WorkshopView.axaml" value="Artemis.UI.Windows/Artemis.UI.Windows.csproj" />
<entry key="Avalonia/Artemis.UI/Screens/Debugger/Tabs/Render/RenderDebugView.axaml" value="Avalonia/Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
<entry key="Avalonia/Artemis.UI/Styles/Artemis.axaml" value="Avalonia/Artemis.UI.Linux/Artemis.UI.Linux.csproj" />
</map>

View File

@ -8,10 +8,14 @@ namespace Artemis.Core
/// <summary>
/// Represents the icon of a <see cref="ProfileConfiguration" />
/// </summary>
public class ProfileConfigurationIcon : IStorageModel
public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
{
private readonly ProfileConfigurationEntity _entity;
private Stream? _iconStream;
private ProfileConfigurationIconType _iconType;
private string? _iconName;
private string? _originalFileName;
private bool _fill;
internal ProfileConfigurationIcon(ProfileConfigurationEntity entity)
{
@ -21,17 +25,38 @@ namespace Artemis.Core
/// <summary>
/// Gets the type of icon this profile configuration uses
/// </summary>
public ProfileConfigurationIconType IconType { get; private set; }
public ProfileConfigurationIconType IconType
{
get => _iconType;
private set => SetAndNotify(ref _iconType, value);
}
/// <summary>
/// Gets the name of the icon if <see cref="IconType" /> is <see cref="ProfileConfigurationIconType.MaterialIcon" />
/// </summary>
public string? IconName { get; private set; }
public string? IconName
{
get => _iconName;
private set => SetAndNotify(ref _iconName, value);
}
/// <summary>
/// Gets the original file name of the icon (if applicable)
/// </summary>
public string? OriginalFileName { get; private set; }
public string? OriginalFileName
{
get => _originalFileName;
private set => SetAndNotify(ref _originalFileName, value);
}
/// <summary>
/// Gets or sets a boolean indicating whether or not this icon should be filled.
/// </summary>
public bool Fill
{
get => _fill;
set => SetAndNotify(ref _fill, value);
}
/// <summary>
/// Updates the <see cref="IconName" /> to the provided value and changes the <see cref="IconType" /> is
@ -68,7 +93,7 @@ namespace Artemis.Core
IconName = null;
OriginalFileName = originalFileName;
IconType = OriginalFileName.EndsWith(".svg") ? ProfileConfigurationIconType.SvgImage : ProfileConfigurationIconType.BitmapImage;
IconType = ProfileConfigurationIconType.BitmapImage;
OnIconUpdated();
}
@ -108,7 +133,8 @@ namespace Artemis.Core
public void Load()
{
IconType = (ProfileConfigurationIconType) _entity.IconType;
if (IconType != ProfileConfigurationIconType.MaterialIcon)
Fill = _entity.IconFill;
if (IconType != ProfileConfigurationIconType.MaterialIcon)
return;
IconName = _entity.MaterialIcon;
@ -120,6 +146,7 @@ namespace Artemis.Core
{
_entity.IconType = (int) IconType;
_entity.MaterialIcon = IconType == ProfileConfigurationIconType.MaterialIcon ? IconName : null;
_entity.IconFill = Fill;
}
#endregion
@ -139,10 +166,5 @@ namespace Artemis.Core
/// A bitmap image icon
/// </summary>
[Description("Bitmap Image")] BitmapImage,
/// <summary>
/// An SVG image icon
/// </summary>
[Description("SVG Image")] SvgImage
}
}

View File

@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text.RegularExpressions;
namespace Artemis.Core.LayerBrushes
{
@ -42,7 +43,7 @@ namespace Artemis.Core.LayerBrushes
if (!IsEnabled)
throw new ArtemisPluginException(Plugin, "Can only add a layer brush descriptor when the plugin is enabled");
if (icon.ToLower().EndsWith(".svg"))
if (icon.Contains('.'))
icon = Plugin.ResolveRelativePath(icon);
LayerBrushDescriptor descriptor = new(displayName, description, icon, typeof(T), this);
_layerBrushDescriptors.Add(descriptor);

View File

@ -43,7 +43,7 @@ namespace Artemis.Core.LayerEffects
if (!IsEnabled)
throw new ArtemisPluginFeatureException(this, "Can only add a layer effect descriptor when the plugin is enabled");
if (icon.ToLower().EndsWith(".svg"))
if (icon.Contains('.'))
icon = Plugin.ResolveRelativePath(icon);
LayerEffectDescriptor descriptor = new(displayName, description, icon, typeof(T), this);
_layerEffectDescriptors.Add(descriptor);

View File

@ -151,7 +151,7 @@ namespace Artemis.Core
{
if (Icon == null)
return null;
return Icon.EndsWith(".svg") ? Plugin.ResolveRelativePath(Icon) : Icon;
return Icon.Contains('.') ? Plugin.ResolveRelativePath(Icon) : Icon;
}
}

View File

@ -161,7 +161,7 @@ namespace Artemis.Core
{
if (Icon == null)
return null;
return Icon.EndsWith(".svg") ? Plugin.ResolveRelativePath(Icon) : Icon;
return Icon.Contains('.') ? Plugin.ResolveRelativePath(Icon) : Icon;
}
}

View File

@ -304,10 +304,7 @@ namespace Artemis.Core.Services
{
if (profileConfiguration.Icon.IconType == ProfileConfigurationIconType.MaterialIcon)
return;
// This can happen if the icon was saved before the original file name was stored (pre-Avalonia)
profileConfiguration.Entity.IconOriginalFileName ??= profileConfiguration.Icon.IconType == ProfileConfigurationIconType.BitmapImage ? "icon.png" : "icon.svg";
using Stream? stream = _profileCategoryRepository.GetProfileIconStream(profileConfiguration.Entity.FileIconId);
if (stream != null)
profileConfiguration.Icon.SetIconByStream(profileConfiguration.Entity.IconOriginalFileName, stream);

View File

@ -1,5 +1,4 @@
using System;
using Artemis.Storage.Entities.Profile.Conditions;
using Artemis.Storage.Entities.Profile.Nodes;
namespace Artemis.Storage.Entities.Profile
@ -11,6 +10,7 @@ namespace Artemis.Storage.Entities.Profile
public string IconOriginalFileName { get; set; }
public Guid FileIconId { get; set; }
public int IconType { get; set; }
public bool IconFill { get; set; }
public int Order { get; set; }
public bool IsSuspended { get; set; }

View File

@ -123,17 +123,6 @@
"SkiaSharp.NativeAssets.WebAssembly": "2.88.0-preview.178"
}
},
"Avalonia.Svg.Skia": {
"type": "Transitive",
"resolved": "0.10.12",
"contentHash": "qsXKdm5eWpfoVPe0xgtxhbOYlhG8QdbYNJZTTihg/c4iPFYuh1G7DldiNskuVFuGiGxLVZ0g6ebql7ZkwbO1pA==",
"dependencies": {
"Avalonia": "0.10.12",
"Avalonia.Skia": "0.10.12",
"SkiaSharp": "2.88.0-preview.178",
"Svg.Skia": "0.5.12"
}
},
"Avalonia.Win32": {
"type": "Transitive",
"resolved": "0.10.13",
@ -215,11 +204,6 @@
"Unosquare.Swan.Lite": "3.0.0"
}
},
"Fizzler": {
"type": "Transitive",
"resolved": "1.2.0",
"contentHash": "CPxuWF8EPvM0rwAtMTR5G+7EuLoGNXsEfqyx06upN9JyVALZ73KgbGn3SLFwGosifiUAXrvNHtXlUwGGytdECg=="
},
"FluentAvaloniaUI": {
"type": "Transitive",
"resolved": "1.3.4",
@ -722,11 +706,6 @@
"Serilog": "2.10.0"
}
},
"ShimSkiaSharp": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "oUGM7gQHRzbGPRs3E1pe5e8VwML21YyEz9xdo+r2ov1mAqSDPyXErVQP6pN4gnfYMVf5ADR7BVkVzt4R9Iz3gQ=="
},
"SkiaSharp": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
@ -737,15 +716,6 @@
"System.Memory": "4.5.3"
}
},
"SkiaSharp.HarfBuzz": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
"contentHash": "qTf3PbRJsTVOttQkYWOCswa1QnkH0dEOqMSgr3iXZQuKPNlj1qpGY8+OGPs25WKgUEqOpv2nog/AYQ/bpyOXzA==",
"dependencies": {
"HarfBuzzSharp": "2.8.2-preview.178",
"SkiaSharp": "2.88.0-preview.178"
}
},
"SkiaSharp.NativeAssets.Linux": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
@ -783,37 +753,6 @@
"Splat": "14.1.45"
}
},
"Svg.Custom": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "kmjLQf5U5WC7tRGBedUhtrOUCR0NaNL2auzOA2a/oMwEA0Bjrpd6qvMTpJUS3HITxi8vJazGl270K+i0JvdJog==",
"dependencies": {
"Fizzler": "1.2.0",
"System.Memory": "4.5.3",
"System.ObjectModel": "4.3.0",
"System.ValueTuple": "4.5.0"
}
},
"Svg.Model": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "/CPiXIugg4oVyYlQr26fB1X9iQfICALF8AJXbTWnXGoP2WZa1t6aZbAXPk3HoPApA0w5waf3XXkBiYYnWwawaQ==",
"dependencies": {
"ShimSkiaSharp": "0.5.12",
"Svg.Custom": "0.5.12"
}
},
"Svg.Skia": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "KjKpjz0FKge+WpRzjD1bqywAW3vZhXwpR5c7Ej5OuP4xDrQjBwtFeB0iZ+yEJMzwXf/Rs4ImuN8m3bmBDJvMHg==",
"dependencies": {
"SkiaSharp": "2.88.0-preview.178",
"SkiaSharp.HarfBuzz": "2.88.0-preview.178",
"Svg.Custom": "0.5.12",
"Svg.Model": "0.5.12"
}
},
"System.AppContext": {
"type": "Transitive",
"resolved": "4.3.0",
@ -1777,7 +1716,6 @@
"Avalonia.Desktop": "0.10.13",
"Avalonia.Diagnostics": "0.10.13",
"Avalonia.ReactiveUI": "0.10.13",
"Avalonia.Svg.Skia": "0.10.12",
"Avalonia.Xaml.Behaviors": "0.10.13.3",
"DynamicData": "7.5.4",
"FluentAvaloniaUI": "1.3.4",
@ -1798,7 +1736,6 @@
"Artemis.Core": "1.0.0",
"Avalonia": "0.10.13",
"Avalonia.ReactiveUI": "0.10.13",
"Avalonia.Svg.Skia": "0.10.12",
"Avalonia.Xaml.Behaviors": "0.10.13.3",
"DynamicData": "7.5.4",
"FluentAvaloniaUI": "1.3.4",

View File

@ -123,17 +123,6 @@
"SkiaSharp.NativeAssets.WebAssembly": "2.88.0-preview.178"
}
},
"Avalonia.Svg.Skia": {
"type": "Transitive",
"resolved": "0.10.12",
"contentHash": "qsXKdm5eWpfoVPe0xgtxhbOYlhG8QdbYNJZTTihg/c4iPFYuh1G7DldiNskuVFuGiGxLVZ0g6ebql7ZkwbO1pA==",
"dependencies": {
"Avalonia": "0.10.12",
"Avalonia.Skia": "0.10.12",
"SkiaSharp": "2.88.0-preview.178",
"Svg.Skia": "0.5.12"
}
},
"Avalonia.Win32": {
"type": "Transitive",
"resolved": "0.10.13",
@ -215,11 +204,6 @@
"Unosquare.Swan.Lite": "3.0.0"
}
},
"Fizzler": {
"type": "Transitive",
"resolved": "1.2.0",
"contentHash": "CPxuWF8EPvM0rwAtMTR5G+7EuLoGNXsEfqyx06upN9JyVALZ73KgbGn3SLFwGosifiUAXrvNHtXlUwGGytdECg=="
},
"FluentAvaloniaUI": {
"type": "Transitive",
"resolved": "1.3.4",
@ -722,11 +706,6 @@
"Serilog": "2.10.0"
}
},
"ShimSkiaSharp": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "oUGM7gQHRzbGPRs3E1pe5e8VwML21YyEz9xdo+r2ov1mAqSDPyXErVQP6pN4gnfYMVf5ADR7BVkVzt4R9Iz3gQ=="
},
"SkiaSharp": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
@ -737,15 +716,6 @@
"System.Memory": "4.5.3"
}
},
"SkiaSharp.HarfBuzz": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
"contentHash": "qTf3PbRJsTVOttQkYWOCswa1QnkH0dEOqMSgr3iXZQuKPNlj1qpGY8+OGPs25WKgUEqOpv2nog/AYQ/bpyOXzA==",
"dependencies": {
"HarfBuzzSharp": "2.8.2-preview.178",
"SkiaSharp": "2.88.0-preview.178"
}
},
"SkiaSharp.NativeAssets.Linux": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
@ -783,37 +753,6 @@
"Splat": "14.1.45"
}
},
"Svg.Custom": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "kmjLQf5U5WC7tRGBedUhtrOUCR0NaNL2auzOA2a/oMwEA0Bjrpd6qvMTpJUS3HITxi8vJazGl270K+i0JvdJog==",
"dependencies": {
"Fizzler": "1.2.0",
"System.Memory": "4.5.3",
"System.ObjectModel": "4.3.0",
"System.ValueTuple": "4.5.0"
}
},
"Svg.Model": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "/CPiXIugg4oVyYlQr26fB1X9iQfICALF8AJXbTWnXGoP2WZa1t6aZbAXPk3HoPApA0w5waf3XXkBiYYnWwawaQ==",
"dependencies": {
"ShimSkiaSharp": "0.5.12",
"Svg.Custom": "0.5.12"
}
},
"Svg.Skia": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "KjKpjz0FKge+WpRzjD1bqywAW3vZhXwpR5c7Ej5OuP4xDrQjBwtFeB0iZ+yEJMzwXf/Rs4ImuN8m3bmBDJvMHg==",
"dependencies": {
"SkiaSharp": "2.88.0-preview.178",
"SkiaSharp.HarfBuzz": "2.88.0-preview.178",
"Svg.Custom": "0.5.12",
"Svg.Model": "0.5.12"
}
},
"System.AppContext": {
"type": "Transitive",
"resolved": "4.3.0",
@ -1777,7 +1716,6 @@
"Avalonia.Desktop": "0.10.13",
"Avalonia.Diagnostics": "0.10.13",
"Avalonia.ReactiveUI": "0.10.13",
"Avalonia.Svg.Skia": "0.10.12",
"Avalonia.Xaml.Behaviors": "0.10.13.3",
"DynamicData": "7.5.4",
"FluentAvaloniaUI": "1.3.4",
@ -1798,7 +1736,6 @@
"Artemis.Core": "1.0.0",
"Avalonia": "0.10.13",
"Avalonia.ReactiveUI": "0.10.13",
"Avalonia.Svg.Skia": "0.10.12",
"Avalonia.Xaml.Behaviors": "0.10.13.3",
"DynamicData": "7.5.4",
"FluentAvaloniaUI": "1.3.4",

View File

@ -17,7 +17,6 @@
<ItemGroup>
<PackageReference Include="Avalonia" Version="0.10.13" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.13" />
<PackageReference Include="Avalonia.Svg.Skia" Version="0.10.12" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="0.10.13.3" />
<PackageReference Include="DynamicData" Version="7.5.4" />
<PackageReference Include="FluentAvaloniaUI" Version="1.3.4" />

View File

@ -1,10 +1,12 @@
using System;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Layout;
using Avalonia.LogicalTree;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Svg.Skia;
using Avalonia.Visuals.Media.Imaging;
using Material.Icons;
using Material.Icons.Avalonia;
@ -45,20 +47,29 @@ namespace Artemis.UI.Shared
{
// 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};
}
// An URI pointing to an SVG
else if (iconString.EndsWith(".svg"))
{
SvgSource source = new();
source.Load(iconString);
Content = new Image {Source = new SvgImage {Source = source}};
}
// An URI pointing to a different kind of image
// An URI pointing to an image
else
{
Content = new Image {Source = new Bitmap(iconString), Width = Bounds.Width, Height = Bounds.Height};
if (!Fill)
{
Content = new Image
{
Source = new Bitmap(iconString),
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch
};
}
else
{
Content = new Border
{
Background = TextBlock.GetForeground(this),
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
OpacityMask = new ImageBrush(new Bitmap(iconString)) {BitmapInterpolationMode = BitmapInterpolationMode.MediumQuality}
};
}
}
}
}
@ -108,6 +119,23 @@ namespace Artemis.UI.Shared
set => SetValue(IconProperty, value);
}
/// <summary>
/// Gets or sets a boolean indicating whether or not the icon should be filled in with the primary text color of the
/// theme
/// </summary>
public static readonly StyledProperty<bool> FillProperty =
AvaloniaProperty.Register<ArtemisIcon, bool>(nameof(Icon), defaultValue: true, notifying: IconChanging);
/// <summary>
/// Gets or sets a boolean indicating whether or not the icon should be filled in with the primary text color of the
/// theme
/// </summary>
public bool Fill
{
get => GetValue(FillProperty);
set => SetValue(FillProperty, value);
}
#endregion
}
}

View File

@ -3,10 +3,13 @@ using System.IO;
using Artemis.Core;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Layout;
using Avalonia.LogicalTree;
using Avalonia.Markup.Xaml;
using Avalonia.Media;
using Avalonia.Media.Imaging;
using Avalonia.Svg.Skia;
using Avalonia.Threading;
using Avalonia.Visuals.Media.Imaging;
using Material.Icons;
using Material.Icons.Avalonia;
@ -15,8 +18,10 @@ namespace Artemis.UI.Shared
/// <summary>
/// Represents a control that can display the icon of a specific <see cref="ProfileConfiguration"/>.
/// </summary>
public class ProfileConfigurationIcon : UserControl
public class ProfileConfigurationIcon : UserControl, IDisposable
{
private Stream? _stream;
/// <summary>
/// Creates a new instance of the <see cref="ProfileConfigurationIcon" /> class.
/// </summary>
@ -27,11 +32,11 @@ namespace Artemis.UI.Shared
PropertyChanged += OnPropertyChanged;
}
private void Update()
{
if (ConfigurationIcon == null)
return;
Dispose();
try
{
@ -40,37 +45,40 @@ namespace Artemis.UI.Shared
Content = Enum.TryParse(ConfigurationIcon.IconName, true, out MaterialIconKind parsedIcon)
? new MaterialIcon {Kind = parsedIcon!}
: new MaterialIcon {Kind = MaterialIconKind.QuestionMark};
return;
}
Stream? stream = ConfigurationIcon.GetIconStream();
if (stream == null)
{
Content = new MaterialIcon {Kind = MaterialIconKind.QuestionMark};
return;
}
if (ConfigurationIcon.IconType == ProfileConfigurationIconType.SvgImage)
{
SvgSource source = new();
source.Load(stream);
Content = new Image {Source = new SvgImage {Source = source}};
}
else if (ConfigurationIcon.IconType == ProfileConfigurationIconType.BitmapImage)
{
Content = new Image {Source = new Bitmap(ConfigurationIcon.GetIconStream())};
}
else
{
Content = new MaterialIcon {Kind = MaterialIconKind.QuestionMark};
Stream? stream = ConfigurationIcon.GetIconStream();
if (stream == null)
Content = new MaterialIcon {Kind = MaterialIconKind.QuestionMark};
else
LoadFromBitmap(ConfigurationIcon, stream);
}
}
catch
catch (Exception)
{
Content = new MaterialIcon {Kind = MaterialIconKind.QuestionMark};
}
}
private void LoadFromBitmap(Core.ProfileConfigurationIcon configurationIcon, Stream stream)
{
_stream = stream;
if (!configurationIcon.Fill)
{
Content = new Image {Source = new Bitmap(stream)};
return;
}
Content = new Border
{
Background = TextBlock.GetForeground(this),
VerticalAlignment = VerticalAlignment.Stretch,
HorizontalAlignment = HorizontalAlignment.Stretch,
OpacityMask = new ImageBrush(new Bitmap(stream)) {BitmapInterpolationMode = BitmapInterpolationMode.MediumQuality}
};
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);
@ -81,8 +89,7 @@ namespace Artemis.UI.Shared
if (ConfigurationIcon != null)
ConfigurationIcon.IconUpdated -= ConfigurationIconOnIconUpdated;
if (Content is Image image && image.Source is IDisposable disposable)
disposable.Dispose();
Dispose();
}
private void OnPropertyChanged(object? sender, AvaloniaPropertyChangedEventArgs e)
@ -95,12 +102,12 @@ namespace Artemis.UI.Shared
if (e.NewValue is Core.ProfileConfigurationIcon newIcon)
newIcon.IconUpdated += ConfigurationIconOnIconUpdated;
Update();
Dispatcher.UIThread.Post(Update, DispatcherPriority.ApplicationIdle);
}
private void ConfigurationIconOnIconUpdated(object? sender, EventArgs e)
{
Update();
Dispatcher.UIThread.Post(Update, DispatcherPriority.ApplicationIdle);
}
#region Properties
@ -111,6 +118,7 @@ namespace Artemis.UI.Shared
public static readonly StyledProperty<Core.ProfileConfigurationIcon?> ConfigurationIconProperty =
AvaloniaProperty.Register<ProfileConfigurationIcon, Core.ProfileConfigurationIcon?>(nameof(ConfigurationIcon));
/// <summary>
/// Gets or sets the <see cref="Core.ProfileConfigurationIcon" /> to display
/// </summary>
@ -121,5 +129,17 @@ namespace Artemis.UI.Shared
}
#endregion
/// <inheritdoc />
public void Dispose()
{
if (Content is Image {Source: IDisposable d})
{
d.Dispose();
Content = null;
}
_stream?.Dispose();
}
}
}

View File

@ -28,18 +28,6 @@
"System.Reactive": "5.0.0"
}
},
"Avalonia.Svg.Skia": {
"type": "Direct",
"requested": "[0.10.12, )",
"resolved": "0.10.12",
"contentHash": "qsXKdm5eWpfoVPe0xgtxhbOYlhG8QdbYNJZTTihg/c4iPFYuh1G7DldiNskuVFuGiGxLVZ0g6ebql7ZkwbO1pA==",
"dependencies": {
"Avalonia": "0.10.12",
"Avalonia.Skia": "0.10.12",
"SkiaSharp": "2.88.0-preview.178",
"Svg.Skia": "0.5.12"
}
},
"Avalonia.Xaml.Behaviors": {
"type": "Direct",
"requested": "[0.10.13.3, )",
@ -257,11 +245,6 @@
"Unosquare.Swan.Lite": "3.0.0"
}
},
"Fizzler": {
"type": "Transitive",
"resolved": "1.2.0",
"contentHash": "CPxuWF8EPvM0rwAtMTR5G+7EuLoGNXsEfqyx06upN9JyVALZ73KgbGn3SLFwGosifiUAXrvNHtXlUwGGytdECg=="
},
"HarfBuzzSharp": {
"type": "Transitive",
"resolved": "2.8.2-preview.178",
@ -694,20 +677,6 @@
"Serilog": "2.10.0"
}
},
"ShimSkiaSharp": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "oUGM7gQHRzbGPRs3E1pe5e8VwML21YyEz9xdo+r2ov1mAqSDPyXErVQP6pN4gnfYMVf5ADR7BVkVzt4R9Iz3gQ=="
},
"SkiaSharp.HarfBuzz": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
"contentHash": "qTf3PbRJsTVOttQkYWOCswa1QnkH0dEOqMSgr3iXZQuKPNlj1qpGY8+OGPs25WKgUEqOpv2nog/AYQ/bpyOXzA==",
"dependencies": {
"HarfBuzzSharp": "2.8.2-preview.178",
"SkiaSharp": "2.88.0-preview.178"
}
},
"SkiaSharp.NativeAssets.Linux": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
@ -736,37 +705,6 @@
"resolved": "14.1.45",
"contentHash": "ayHdfTUklD5ci0s9m4uYMccjtkKVjZ9fVPT5q3PN+SnvyD6bjQVRozOfUHwdwh4LAz9ETZjR/tAgrm+IapXKrw=="
},
"Svg.Custom": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "kmjLQf5U5WC7tRGBedUhtrOUCR0NaNL2auzOA2a/oMwEA0Bjrpd6qvMTpJUS3HITxi8vJazGl270K+i0JvdJog==",
"dependencies": {
"Fizzler": "1.2.0",
"System.Memory": "4.5.3",
"System.ObjectModel": "4.3.0",
"System.ValueTuple": "4.5.0"
}
},
"Svg.Model": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "/CPiXIugg4oVyYlQr26fB1X9iQfICALF8AJXbTWnXGoP2WZa1t6aZbAXPk3HoPApA0w5waf3XXkBiYYnWwawaQ==",
"dependencies": {
"ShimSkiaSharp": "0.5.12",
"Svg.Custom": "0.5.12"
}
},
"Svg.Skia": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "KjKpjz0FKge+WpRzjD1bqywAW3vZhXwpR5c7Ej5OuP4xDrQjBwtFeB0iZ+yEJMzwXf/Rs4ImuN8m3bmBDJvMHg==",
"dependencies": {
"SkiaSharp": "2.88.0-preview.178",
"SkiaSharp.HarfBuzz": "2.88.0-preview.178",
"Svg.Custom": "0.5.12",
"Svg.Model": "0.5.12"
}
},
"System.AppContext": {
"type": "Transitive",
"resolved": "4.3.0",

View File

@ -160,17 +160,6 @@
"SkiaSharp.NativeAssets.WebAssembly": "2.88.0-preview.178"
}
},
"Avalonia.Svg.Skia": {
"type": "Transitive",
"resolved": "0.10.12",
"contentHash": "qsXKdm5eWpfoVPe0xgtxhbOYlhG8QdbYNJZTTihg/c4iPFYuh1G7DldiNskuVFuGiGxLVZ0g6ebql7ZkwbO1pA==",
"dependencies": {
"Avalonia": "0.10.12",
"Avalonia.Skia": "0.10.12",
"SkiaSharp": "2.88.0-preview.178",
"Svg.Skia": "0.5.12"
}
},
"Avalonia.X11": {
"type": "Transitive",
"resolved": "0.10.13",
@ -241,11 +230,6 @@
"Unosquare.Swan.Lite": "3.0.0"
}
},
"Fizzler": {
"type": "Transitive",
"resolved": "1.2.0",
"contentHash": "CPxuWF8EPvM0rwAtMTR5G+7EuLoGNXsEfqyx06upN9JyVALZ73KgbGn3SLFwGosifiUAXrvNHtXlUwGGytdECg=="
},
"FluentAvaloniaUI": {
"type": "Transitive",
"resolved": "1.3.4",
@ -757,11 +741,6 @@
"System.ValueTuple": "4.4.0"
}
},
"ShimSkiaSharp": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "oUGM7gQHRzbGPRs3E1pe5e8VwML21YyEz9xdo+r2ov1mAqSDPyXErVQP6pN4gnfYMVf5ADR7BVkVzt4R9Iz3gQ=="
},
"SkiaSharp": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
@ -772,15 +751,6 @@
"System.Memory": "4.5.3"
}
},
"SkiaSharp.HarfBuzz": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
"contentHash": "qTf3PbRJsTVOttQkYWOCswa1QnkH0dEOqMSgr3iXZQuKPNlj1qpGY8+OGPs25WKgUEqOpv2nog/AYQ/bpyOXzA==",
"dependencies": {
"HarfBuzzSharp": "2.8.2-preview.178",
"SkiaSharp": "2.88.0-preview.178"
}
},
"SkiaSharp.NativeAssets.Linux": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
@ -818,37 +788,6 @@
"Splat": "14.1.45"
}
},
"Svg.Custom": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "kmjLQf5U5WC7tRGBedUhtrOUCR0NaNL2auzOA2a/oMwEA0Bjrpd6qvMTpJUS3HITxi8vJazGl270K+i0JvdJog==",
"dependencies": {
"Fizzler": "1.2.0",
"System.Memory": "4.5.3",
"System.ObjectModel": "4.3.0",
"System.ValueTuple": "4.5.0"
}
},
"Svg.Model": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "/CPiXIugg4oVyYlQr26fB1X9iQfICALF8AJXbTWnXGoP2WZa1t6aZbAXPk3HoPApA0w5waf3XXkBiYYnWwawaQ==",
"dependencies": {
"ShimSkiaSharp": "0.5.12",
"Svg.Custom": "0.5.12"
}
},
"Svg.Skia": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "KjKpjz0FKge+WpRzjD1bqywAW3vZhXwpR5c7Ej5OuP4xDrQjBwtFeB0iZ+yEJMzwXf/Rs4ImuN8m3bmBDJvMHg==",
"dependencies": {
"SkiaSharp": "2.88.0-preview.178",
"SkiaSharp.HarfBuzz": "2.88.0-preview.178",
"Svg.Custom": "0.5.12",
"Svg.Model": "0.5.12"
}
},
"System.AppContext": {
"type": "Transitive",
"resolved": "4.3.0",
@ -1812,7 +1751,6 @@
"Avalonia.Desktop": "0.10.13",
"Avalonia.Diagnostics": "0.10.13",
"Avalonia.ReactiveUI": "0.10.13",
"Avalonia.Svg.Skia": "0.10.12",
"Avalonia.Xaml.Behaviors": "0.10.13.3",
"DynamicData": "7.5.4",
"FluentAvaloniaUI": "1.3.4",
@ -1833,7 +1771,6 @@
"Artemis.Core": "1.0.0",
"Avalonia": "0.10.13",
"Avalonia.ReactiveUI": "0.10.13",
"Avalonia.Svg.Skia": "0.10.12",
"Avalonia.Xaml.Behaviors": "0.10.13.3",
"DynamicData": "7.5.4",
"FluentAvaloniaUI": "1.3.4",

View File

@ -21,7 +21,6 @@
<PackageReference Include="Avalonia.Desktop" Version="0.10.13" />
<PackageReference Include="Avalonia.Diagnostics" Version="0.10.13" />
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.13" />
<PackageReference Include="Avalonia.Svg.Skia" Version="0.10.12" />
<PackageReference Include="Avalonia.Xaml.Behaviors" Version="0.10.13.3" />
<PackageReference Include="DynamicData" Version="7.5.4" />
<PackageReference Include="FluentAvaloniaUI" Version="1.3.4" />
@ -41,16 +40,12 @@
<ProjectReference Include="..\Artemis.VisualScripting\Artemis.VisualScripting.csproj" />
</ItemGroup>
<ItemGroup>
<Content Include="Assets\Images\Logo\bow-black.ico" />
<Content Include="Assets\Images\Logo\bow-white.ico" />
<Content Include="Assets\Images\Logo\bow.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Assets\Images\Logo\bow-black.ico" />
<Resource Include="Assets\Images\Logo\bow-white.ico" />
<Resource Include="Assets\Images\Logo\bow-white.svg" />
<Resource Include="Assets\Images\Logo\bow.ico" />
<Resource Include="Assets\Images\Logo\bow.svg" />
</ItemGroup>
<ItemGroup>
<Compile Update="DefaultTypes\PropertyInput\StringPropertyInputView.axaml.cs">

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

View File

@ -1,12 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64">
<defs>
<style>.cls-1,.cls-2{fill:#fff;}.cls-2{fill-rule:evenodd;}</style>
</defs>
<g id="Layer_10" data-name="Layer 10">
<path class="cls-1" d="M52.32,17.68l-2.83,5a1.16,1.16,0,0,1-2,0l-.57-1-.54.32c-.22-.44-.46-.88-.71-1.31s-.66-1.1-1-1.63l.53-.3-.63-1.06a1.16,1.16,0,0,1,1-1.74l5.75,0A1.15,1.15,0,0,1,52.32,17.68Z"/>
<path class="cls-1" d="M24.71,25.63l-4.84,2.58-.53.28a38.15,38.15,0,0,1-5.54-2.18c-4.51-1.49-1.48-7,1.93-4.31.34.22.69.44,1,.64.59.35,1.21.67,1.82,1A25.88,25.88,0,0,0,24.71,25.63Z"/>
<path class="cls-1" d="M30.83,36.22c-.15.43-.28.86-.41,1.29a25.74,25.74,0,0,0-.81,4.09,26.72,26.72,0,0,0-.17,3.1c0,.37,0,.75,0,1.12A2.45,2.45,0,0,1,25,47.72c-.56-1-.22-2-.18-3.08s.21-2,.39-3c.12-.74.27-1.47.43-2.2l.53-.33,3.63-2.26Z"/>
<path class="cls-1" d="M35,28.71l-.91.57L31.3,31,24,35.59l-4.45,2.78-2.22,1.37a2.6,2.6,0,0,1-1.26.34,2.45,2.45,0,0,1-.8-4.72l.58-.31,1.3-.69,4.67-2.5,7.6-4.05,2.94-1.57.94-.5a17.91,17.91,0,0,1,1,1.55C34.57,27.75,34.82,28.23,35,28.71Z"/>
<path class="cls-2" d="M39.29,53.89a2.56,2.56,0,0,1-1.09.74l-.34.08a.13.13,0,0,1-.09,0,1.84,1.84,0,0,1-.33,0,2.41,2.41,0,0,1-1.84-4,22.32,22.32,0,0,0,5-18.09c0-.24-.08-.48-.13-.72s-.1-.48-.16-.73-.11-.48-.18-.72-.12-.45-.2-.68a20.49,20.49,0,0,0-.7-1.94c-.06-.18-.14-.34-.21-.51a21.83,21.83,0,0,0-1.09-2.16c-.14-.22-.27-.45-.4-.66-.25-.4-.51-.78-.77-1.16s-.63-.85-1-1.26l-.48-.56c-.35-.4-.72-.78-1.09-1.14a6.51,6.51,0,0,0-.54-.51l-.45-.4a22.08,22.08,0,0,0-3-2.2c-.17-.11-.36-.21-.54-.31s-.42-.24-.63-.35l-.46-.23a19.7,19.7,0,0,0-2.31-1l-.44-.15-.1,0c-.53-.18-1.07-.34-1.63-.48l-.25-.06a19.61,19.61,0,0,0-2-.39c-.35-.06-.7-.1-1-.13s-.8-.07-1.2-.08-.65,0-1,0h0a22.18,22.18,0,0,0-4,.36,3.28,3.28,0,0,1-.43,0,2.42,2.42,0,0,1-.42-4.8A26,26,0,0,1,18,9.26h.62c.43,0,.86,0,1.28,0l1,.07,1.07.11c.52.07,1,.14,1.53.24.23,0,.46.08.7.13l.14,0c.35.08.69.15,1,.25a20.61,20.61,0,0,1,2.16.65c.48.16.94.33,1.4.52h0c.33.14.67.28,1,.44s.58.27.86.42l.27.13c.28.14.56.29.82.45s.64.36,1,.55c.49.31,1,.62,1.45,1l.15.11c.31.22.62.46.93.7l.11.08c.36.28.71.58,1.06.89l0,0c.33.28.64.57,1,.88s.64.62.94.95c.1.1.19.21.29.32.26.29.52.58.77.88,0,0,0,.05.06.09.28.34.55.68.81,1s.55.75.82,1.15l.28.44c.21.33.42.67.62,1A27.14,27.14,0,0,1,39.29,53.89Z"/>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 46 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -1,43 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 512 512">
<defs>
<style>.cls-1{fill:url(#linear-gradient);}.cls-2{fill:url(#linear-gradient-2);}.cls-3{fill:url(#linear-gradient-3);}.cls-4{fill:url(#linear-gradient-4);}.cls-5{fill:url(#linear-gradient-5);}.cls-6{fill:url(#linear-gradient-6);}.cls-7{fill:url(#linear-gradient-7);}.cls-8{fill-rule:evenodd;fill:url(#linear-gradient-8);}</style>
<linearGradient id="linear-gradient" x1="151.25" y1="94.74" x2="810.05" y2="369.54" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#f19d25"/>
<stop offset="0.12" stop-color="#f63d3d"/>
<stop offset="0.28" stop-color="#c93cec"/>
<stop offset="0.44" stop-color="#2667f4"/>
<stop offset="0.56" stop-color="#1cb6e7"/>
<stop offset="0.7" stop-color="#2df4b5"/>
<stop offset="0.87" stop-color="#70ea37"/>
<stop offset="1" stop-color="#cfe726"/>
</linearGradient>
<linearGradient id="linear-gradient-2" x1="132.17" y1="204.4" x2="234.7" y2="230.88" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#ef3d3d"/>
<stop offset="1" stop-color="#b72222"/>
</linearGradient>
<linearGradient id="linear-gradient-3" x1="217.07" y1="354.42" x2="253.03" y2="258.52" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#2b75f6"/>
<stop offset="1" stop-color="#1452aa"/>
</linearGradient>
<linearGradient id="linear-gradient-4" x1="105.18" y1="320.77" x2="311.18" y2="203.81" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#22f15e"/>
<stop offset="1" stop-color="#29af4d"/>
</linearGradient>
<linearGradient id="linear-gradient-5" x1="112.68" y1="187.21" x2="771.48" y2="462.01" xlink:href="#linear-gradient"/>
<linearGradient id="linear-gradient-6" x1="88.75" y1="244.59" x2="747.54" y2="519.39" xlink:href="#linear-gradient"/>
<linearGradient id="linear-gradient-7" x1="102.97" y1="210.49" x2="761.77" y2="485.29" xlink:href="#linear-gradient"/>
<linearGradient id="linear-gradient-8" x1="141.26" y1="116.54" x2="347.22" y2="356.89" gradientTransform="translate(11.74 6.94)" gradientUnits="userSpaceOnUse">
<stop offset="0" stop-color="#009385"/>
<stop offset="1" stop-color="#045e53"/>
</linearGradient>
</defs>
<g id="Teal_Bow" data-name="Teal Bow">
<g id="TealRainbow">
<path class="cls-1" d="M375.54,156.66,340,157a7.14,7.14,0,0,0-6.1,10.76l3.85,6.55-16.8,9.84c2.18,3.26,4.26,6.61,6.24,10,1.54,2.67,3,5.37,4.39,8.09l16.82-9.85,3.53,6a7.14,7.14,0,0,0,12.37-.1l17.53-30.94A7.15,7.15,0,0,0,375.54,156.66Z"/>
<path class="cls-5" d="M235.3,221.27l-34.52,18.41c-6.08-1-12.11-2.36-18.05-4a230.91,230.91,0,0,1-39.4-14.9c-27.91-9.26-9.21-43.22,11.93-26.76,2.11,1.41,4.28,2.76,6.48,4,3.65,2.15,7.42,4.09,11.24,5.91a156.68,156.68,0,0,0,42.24,13.31A130.42,130.42,0,0,0,239.63,219Z"/>
<path class="cls-6" d="M257,258.59l4.09-2.55a135.41,135.41,0,0,0-14.8,34.07,160.44,160.44,0,0,0-5,25.32,158,158,0,0,0-1.06,19.21c0,2.32.11,4.63.26,6.94,4.06,16.9-18.44,27-27.64,11.76-3.51-6-1.35-12.66-1.14-19.08.58-6.21,1.35-12.39,2.39-18.55a200.68,200.68,0,0,1,9.63-36.38l10.53-6.56Z"/>
<path class="cls-7" d="M284,219.06c-1.92-3.33-4-6.55-6.21-9.68h0l-9.46,5.54a17.12,17.12,0,0,0-2.69,1.52l-7.34,3.92L240,230.1q-23.52,12.53-47,25.08L164,270.62l-8,4.27c-1.21.65-2.43,1.29-3.64,1.95C132.81,285.25,146.31,314,165.2,304l13.72-8.55,27.53-17.15,45.22-28.18,17.55-10.94,7-4.39a15.73,15.73,0,0,0,3.58-2.29h0l8.56-5Q286.34,223.21,284,219.06Z"/>
<path class="cls-8" d="M169.2,115.38A169,169,0,0,0,143.28,118a15,15,0,0,0,5.26,29.44A137.81,137.81,0,0,1,278.31,372.15a14.95,14.95,0,0,0,22.82,19.31A167.69,167.69,0,0,0,169.2,115.38Z"/>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 3.6 KiB

View File

@ -2,7 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia"
xmlns:root="clr-namespace:Artemis.UI.Screens.Root"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Root.SplashView"
@ -16,11 +15,7 @@
ExtendClientAreaToDecorationsHint="True"
ExtendClientAreaTitleBarHeightHint="450">
<Grid RowDefinitions="250,50,Auto,*" IsHitTestVisible="False">
<Image Grid.Column="0" Stretch="Uniform" Width="200">
<Image.Source>
<svg:SvgImage Source="/Assets/Images/Logo/bow.svg" />
</Image.Source>
</Image>
<Image Grid.Column="0" Stretch="Uniform" Width="200" Height="150" Source="/Assets/Images/Logo/bow.png" VerticalAlignment="Bottom"/>
<TextBlock Grid.Row="1"
Classes="h5"
HorizontalAlignment="Center"

View File

@ -2,7 +2,6 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
mc:Ignorable="d" d:DesignWidth="1000" d:DesignHeight="1400"
@ -10,11 +9,7 @@
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
<StackPanel Margin="15" MaxWidth="800">
<Grid RowDefinitions="*,*" ColumnDefinitions="Auto,*,Auto">
<Image Grid.Column="0" Grid.RowSpan="2" Width="140" Height="140" VerticalAlignment="Center">
<Image.Source>
<svg:SvgImage Source="/Assets/Images/Logo/bow.svg" />
</Image.Source>
</Image>
<Image Grid.Column="0" Grid.RowSpan="2" Width="65" Height="65" VerticalAlignment="Center" Source="/Assets/Images/Logo/bow.png" Margin="0 0 20 0"/>
<TextBlock Grid.Row="0" Grid.Column="1" FontSize="36" VerticalAlignment="Bottom">
Artemis 2
</TextBlock>

View File

@ -72,34 +72,31 @@
IsChecked="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.MaterialIcon}}" />
<RadioButton Content="Bitmap image"
IsChecked="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.BitmapImage}}" />
<RadioButton Content="SVG image"
IsChecked="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.SvgImage}}" />
</WrapPanel>
<StackPanel Orientation="Horizontal"
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.BitmapImage}}">
<Border Background="{DynamicResource CheckerboardBrush}" CornerRadius="{DynamicResource CardCornerRadius}" Width="78" Height="78">
<Border IsVisible="{CompiledBinding ProfileConfiguration.Icon.Fill}" Background="{DynamicResource CheckerboardBrush}" CornerRadius="{DynamicResource CardCornerRadius}" Width="78" Height="78">
<Border Name="FillPreview" Background="{DynamicResource TextFillColorPrimary}" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Margin="10">
<Border.OpacityMask>
<ImageBrush Source="{CompiledBinding SelectedBitmapSource}" BitmapInterpolationMode="HighQuality" />
</Border.OpacityMask>
</Border>
</Border>
<Border IsVisible="{CompiledBinding !ProfileConfiguration.Icon.Fill}" Background="{DynamicResource CheckerboardBrush}" CornerRadius="{DynamicResource CardCornerRadius}" Width="78" Height="78">
<Image Source="{CompiledBinding SelectedBitmapSource}" Margin="10" />
</Border>
<Button Command="{CompiledBinding BrowseBitmapFile}"
VerticalAlignment="Bottom"
Margin="10 0"
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.BitmapImage}}">
Browse bitmap file
</Button>
<CheckBox VerticalAlignment="Bottom" IsChecked="{CompiledBinding ProfileConfiguration.Icon.Fill}">Fill</CheckBox>
</StackPanel>
<StackPanel Orientation="Horizontal"
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.SvgImage}}">
<Border Background="{DynamicResource CheckerboardBrush}" CornerRadius="{DynamicResource CardCornerRadius}" Width="78" Height="78">
<Image Margin="10" Source="{CompiledBinding SelectedSvgSource}" />
</Border>
<Button Command="{CompiledBinding BrowseSvgFile}"
VerticalAlignment="Bottom"
Margin="10 0"
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.SvgImage}}">
Browse SVG file
</Button>
</StackPanel>
<StackPanel Orientation="Horizontal"
IsVisible="{CompiledBinding IconType, Converter={StaticResource EnumBoolConverter}, ConverterParameter={x:Static core:ProfileConfigurationIconType.MaterialIcon}}">
<Border Background="{DynamicResource CheckerboardBrush}" CornerRadius="{DynamicResource CardCornerRadius}" Width="78" Height="78">

View File

@ -1,6 +1,9 @@
using System;
using System.Reactive.Disposables;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using Avalonia.ReactiveUI;
using ReactiveUI;
namespace Artemis.UI.Screens.Sidebar
{
@ -9,6 +12,8 @@ namespace Artemis.UI.Screens.Sidebar
public ProfileConfigurationEditView()
{
InitializeComponent();
this.WhenActivated(d => ViewModel.WhenAnyValue(vm => vm.SelectedBitmapSource).Subscribe(_ => this.Get<Border>("FillPreview").InvalidateVisual()).DisposeWith(d));
#if DEBUG
this.AttachDevTools();
#endif
@ -19,4 +24,4 @@ namespace Artemis.UI.Screens.Sidebar
AvaloniaXamlLoader.Load(this);
}
}
}
}

View File

@ -14,7 +14,6 @@ using Artemis.UI.Shared;
using Artemis.UI.Shared.Services;
using Artemis.UI.Shared.Services.ProfileEditor;
using Avalonia.Media.Imaging;
using Avalonia.Svg.Skia;
using Avalonia.Threading;
using Material.Icons;
using Newtonsoft.Json;
@ -39,7 +38,6 @@ namespace Artemis.UI.Screens.Sidebar
private string? _selectedIconPath;
private ProfileIconViewModel? _selectedMaterialIcon;
private ProfileModuleViewModel? _selectedModule;
private SvgImage? _selectedSvgSource;
private readonly ObservableAsPropertyHelper<ModuleActivationRequirementsViewModel?> _moduleActivationRequirementsViewModel;
public ProfileConfigurationEditViewModel(
@ -74,7 +72,6 @@ namespace Artemis.UI.Screens.Sidebar
VisualEditorViewModel = nodeVmFactory.NodeScriptViewModel(_profileConfiguration.ActivationCondition, true);
BrowseBitmapFile = ReactiveCommand.CreateFromTask(ExecuteBrowseBitmapFile);
BrowseSvgFile = ReactiveCommand.CreateFromTask(ExecuteBrowseSvgFile);
OpenConditionEditor = ReactiveCommand.CreateFromTask(ExecuteOpenConditionEditor);
Confirm = ReactiveCommand.CreateFromTask(ExecuteConfirm);
Import = ReactiveCommand.CreateFromTask(ExecuteImport);
@ -133,7 +130,6 @@ namespace Artemis.UI.Screens.Sidebar
public ReactiveCommand<Unit, Unit> OpenConditionEditor { get; }
public ReactiveCommand<Unit, Unit> BrowseBitmapFile { get; }
public ReactiveCommand<Unit, Unit> BrowseSvgFile { get; }
public ReactiveCommand<Unit, Unit> Confirm { get; }
public ReactiveCommand<Unit, Unit> Import { get; }
public ReactiveCommand<Unit, Unit> Delete { get; }
@ -237,30 +233,21 @@ namespace Artemis.UI.Screens.Sidebar
set => RaiseAndSetIfChanged(ref _selectedBitmapSource, value);
}
public SvgImage? SelectedSvgSource
{
get => _selectedSvgSource;
set => RaiseAndSetIfChanged(ref _selectedSvgSource, value);
}
private void LoadIcon()
{
// Preselect the icon based on streams if needed
if (_profileConfiguration.Icon.IconType == ProfileConfigurationIconType.BitmapImage)
{
SelectedBitmapSource = new Bitmap(_profileConfiguration.Icon.GetIconStream());
}
else if (_profileConfiguration.Icon.IconType == ProfileConfigurationIconType.SvgImage)
{
Stream? iconStream = _profileConfiguration.Icon.GetIconStream();
if (iconStream != null)
try
{
SvgSource newSource = new();
newSource.Load(iconStream);
SelectedSvgSource = new SvgImage {Source = newSource};
SelectedBitmapSource = new Bitmap(_profileConfiguration.Icon.GetIconStream());
}
catch (Exception e)
{
_windowService.ShowConfirmContentDialog("Failed to load profile icon", e.Message, "Meh", null);
}
}
// Prepare the contents of the dropdown box, it should be virtualized so no need to wait with this
ObservableCollection<ProfileIconViewModel> icons = new(Enum.GetValues<MaterialIconKind>()
.Select(kind => new ProfileIconViewModel(kind))
@ -299,23 +286,7 @@ namespace Artemis.UI.Screens.Sidebar
SelectedBitmapSource = new Bitmap(result[0]);
_selectedIconPath = result[0];
}
private async Task ExecuteBrowseSvgFile()
{
string[]? result = await _windowService.CreateOpenFileDialog()
.HavingFilter(f => f.WithExtension("svg").WithName("SVG image"))
.ShowAsync();
if (result == null)
return;
SvgSource newSource = new();
newSource.Load(result[0]);
SelectedSvgSource = new SvgImage {Source = newSource};
_selectedIconPath = result[0];
}
private async Task ExecuteOpenConditionEditor()
{
await _windowService.ShowDialogAsync<NodeScriptWindowViewModel, bool>(("nodeScript", ProfileConfiguration.ActivationCondition));

View File

@ -4,7 +4,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:avalonia="clr-namespace:Material.Icons.Avalonia;assembly=Material.Icons.Avalonia"
xmlns:controls="clr-namespace:FluentAvalonia.UI.Controls;assembly=FluentAvalonia"
xmlns:svg="clr-namespace:Avalonia.Svg.Skia;assembly=Avalonia.Svg.Skia"
mc:Ignorable="d" d:DesignWidth="240" d:DesignHeight="450"
x:Class="Artemis.UI.Screens.Sidebar.SidebarView">
<UserControl.Styles>
@ -12,11 +11,7 @@
</UserControl.Styles>
<Grid RowDefinitions="60,Auto,Auto,*,Auto,Auto">
<Grid Grid.Row="0" IsHitTestVisible="False" ColumnDefinitions="Auto,*">
<Image Grid.Column="0">
<Image.Source>
<svg:SvgImage Source="/Assets/Images/Logo/bow.svg" />
</Image.Source>
</Image>
<Image Grid.Column="0" Margin="12" Source="/Assets/Images/Logo/bow.png" RenderOptions.BitmapInterpolationMode="HighQuality"/>
<TextBlock Grid.Column="1"
FontSize="24"
VerticalAlignment="Center"

View File

@ -62,18 +62,6 @@
"System.Reactive": "5.0.0"
}
},
"Avalonia.Svg.Skia": {
"type": "Direct",
"requested": "[0.10.12, )",
"resolved": "0.10.12",
"contentHash": "qsXKdm5eWpfoVPe0xgtxhbOYlhG8QdbYNJZTTihg/c4iPFYuh1G7DldiNskuVFuGiGxLVZ0g6ebql7ZkwbO1pA==",
"dependencies": {
"Avalonia": "0.10.12",
"Avalonia.Skia": "0.10.12",
"SkiaSharp": "2.88.0-preview.178",
"Svg.Skia": "0.5.12"
}
},
"Avalonia.Xaml.Behaviors": {
"type": "Direct",
"requested": "[0.10.13.3, )",
@ -307,11 +295,6 @@
"Unosquare.Swan.Lite": "3.0.0"
}
},
"Fizzler": {
"type": "Transitive",
"resolved": "1.2.0",
"contentHash": "CPxuWF8EPvM0rwAtMTR5G+7EuLoGNXsEfqyx06upN9JyVALZ73KgbGn3SLFwGosifiUAXrvNHtXlUwGGytdECg=="
},
"Flurl": {
"type": "Transitive",
"resolved": "3.0.2",
@ -754,20 +737,6 @@
"Serilog": "2.10.0"
}
},
"ShimSkiaSharp": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "oUGM7gQHRzbGPRs3E1pe5e8VwML21YyEz9xdo+r2ov1mAqSDPyXErVQP6pN4gnfYMVf5ADR7BVkVzt4R9Iz3gQ=="
},
"SkiaSharp.HarfBuzz": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
"contentHash": "qTf3PbRJsTVOttQkYWOCswa1QnkH0dEOqMSgr3iXZQuKPNlj1qpGY8+OGPs25WKgUEqOpv2nog/AYQ/bpyOXzA==",
"dependencies": {
"HarfBuzzSharp": "2.8.2-preview.178",
"SkiaSharp": "2.88.0-preview.178"
}
},
"SkiaSharp.NativeAssets.Linux": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
@ -796,37 +765,6 @@
"resolved": "14.1.45",
"contentHash": "ayHdfTUklD5ci0s9m4uYMccjtkKVjZ9fVPT5q3PN+SnvyD6bjQVRozOfUHwdwh4LAz9ETZjR/tAgrm+IapXKrw=="
},
"Svg.Custom": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "kmjLQf5U5WC7tRGBedUhtrOUCR0NaNL2auzOA2a/oMwEA0Bjrpd6qvMTpJUS3HITxi8vJazGl270K+i0JvdJog==",
"dependencies": {
"Fizzler": "1.2.0",
"System.Memory": "4.5.3",
"System.ObjectModel": "4.3.0",
"System.ValueTuple": "4.5.0"
}
},
"Svg.Model": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "/CPiXIugg4oVyYlQr26fB1X9iQfICALF8AJXbTWnXGoP2WZa1t6aZbAXPk3HoPApA0w5waf3XXkBiYYnWwawaQ==",
"dependencies": {
"ShimSkiaSharp": "0.5.12",
"Svg.Custom": "0.5.12"
}
},
"Svg.Skia": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "KjKpjz0FKge+WpRzjD1bqywAW3vZhXwpR5c7Ej5OuP4xDrQjBwtFeB0iZ+yEJMzwXf/Rs4ImuN8m3bmBDJvMHg==",
"dependencies": {
"SkiaSharp": "2.88.0-preview.178",
"SkiaSharp.HarfBuzz": "2.88.0-preview.178",
"Svg.Custom": "0.5.12",
"Svg.Model": "0.5.12"
}
},
"System.AppContext": {
"type": "Transitive",
"resolved": "4.3.0",
@ -1785,7 +1723,6 @@
"Artemis.Core": "1.0.0",
"Avalonia": "0.10.13",
"Avalonia.ReactiveUI": "0.10.13",
"Avalonia.Svg.Skia": "0.10.12",
"Avalonia.Xaml.Behaviors": "0.10.13.3",
"DynamicData": "7.5.4",
"FluentAvaloniaUI": "1.3.4",

View File

@ -163,17 +163,6 @@
"SkiaSharp.NativeAssets.WebAssembly": "2.88.0-preview.178"
}
},
"Avalonia.Svg.Skia": {
"type": "Transitive",
"resolved": "0.10.12",
"contentHash": "qsXKdm5eWpfoVPe0xgtxhbOYlhG8QdbYNJZTTihg/c4iPFYuh1G7DldiNskuVFuGiGxLVZ0g6ebql7ZkwbO1pA==",
"dependencies": {
"Avalonia": "0.10.12",
"Avalonia.Skia": "0.10.12",
"SkiaSharp": "2.88.0-preview.178",
"Svg.Skia": "0.5.12"
}
},
"Avalonia.Win32": {
"type": "Transitive",
"resolved": "0.10.13",
@ -245,11 +234,6 @@
"Unosquare.Swan.Lite": "3.0.0"
}
},
"Fizzler": {
"type": "Transitive",
"resolved": "1.2.0",
"contentHash": "CPxuWF8EPvM0rwAtMTR5G+7EuLoGNXsEfqyx06upN9JyVALZ73KgbGn3SLFwGosifiUAXrvNHtXlUwGGytdECg=="
},
"FluentAvaloniaUI": {
"type": "Transitive",
"resolved": "1.3.4",
@ -704,20 +688,6 @@
"Serilog": "2.10.0"
}
},
"ShimSkiaSharp": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "oUGM7gQHRzbGPRs3E1pe5e8VwML21YyEz9xdo+r2ov1mAqSDPyXErVQP6pN4gnfYMVf5ADR7BVkVzt4R9Iz3gQ=="
},
"SkiaSharp.HarfBuzz": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
"contentHash": "qTf3PbRJsTVOttQkYWOCswa1QnkH0dEOqMSgr3iXZQuKPNlj1qpGY8+OGPs25WKgUEqOpv2nog/AYQ/bpyOXzA==",
"dependencies": {
"HarfBuzzSharp": "2.8.2-preview.178",
"SkiaSharp": "2.88.0-preview.178"
}
},
"SkiaSharp.NativeAssets.Linux": {
"type": "Transitive",
"resolved": "2.88.0-preview.178",
@ -746,37 +716,6 @@
"resolved": "14.1.45",
"contentHash": "ayHdfTUklD5ci0s9m4uYMccjtkKVjZ9fVPT5q3PN+SnvyD6bjQVRozOfUHwdwh4LAz9ETZjR/tAgrm+IapXKrw=="
},
"Svg.Custom": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "kmjLQf5U5WC7tRGBedUhtrOUCR0NaNL2auzOA2a/oMwEA0Bjrpd6qvMTpJUS3HITxi8vJazGl270K+i0JvdJog==",
"dependencies": {
"Fizzler": "1.2.0",
"System.Memory": "4.5.3",
"System.ObjectModel": "4.3.0",
"System.ValueTuple": "4.5.0"
}
},
"Svg.Model": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "/CPiXIugg4oVyYlQr26fB1X9iQfICALF8AJXbTWnXGoP2WZa1t6aZbAXPk3HoPApA0w5waf3XXkBiYYnWwawaQ==",
"dependencies": {
"ShimSkiaSharp": "0.5.12",
"Svg.Custom": "0.5.12"
}
},
"Svg.Skia": {
"type": "Transitive",
"resolved": "0.5.12",
"contentHash": "KjKpjz0FKge+WpRzjD1bqywAW3vZhXwpR5c7Ej5OuP4xDrQjBwtFeB0iZ+yEJMzwXf/Rs4ImuN8m3bmBDJvMHg==",
"dependencies": {
"SkiaSharp": "2.88.0-preview.178",
"SkiaSharp.HarfBuzz": "2.88.0-preview.178",
"Svg.Custom": "0.5.12",
"Svg.Model": "0.5.12"
}
},
"System.AppContext": {
"type": "Transitive",
"resolved": "4.3.0",
@ -1735,7 +1674,6 @@
"Artemis.Core": "1.0.0",
"Avalonia": "0.10.13",
"Avalonia.ReactiveUI": "0.10.13",
"Avalonia.Svg.Skia": "0.10.12",
"Avalonia.Xaml.Behaviors": "0.10.13.3",
"DynamicData": "7.5.4",
"FluentAvaloniaUI": "1.3.4",