mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 11:26:27 +00:00
Icons - Dropped SVG support and fixed filling
This commit is contained in:
1 parent
dd40bdd544
commit
0d3890e560
30 files changed
+163
-571
No files matched your search
@@ -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
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in new issue
Block a user