1
0
mirror of https://github.com/Artemis-RGB/Artemis synced 2025-12-12 13:28:33 +00:00

Core - Removed OriginalFileName from icon since it's irrelevant

This commit is contained in:
Robert 2023-08-13 10:41:12 +02:00
parent e1f0ccbcc1
commit 3a6171726c
4 changed files with 10 additions and 25 deletions

View File

@ -15,7 +15,6 @@ public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
private string? _iconName;
private Stream? _iconStream;
private ProfileConfigurationIconType _iconType;
private string? _originalFileName;
internal ProfileConfigurationIcon(ProfileConfigurationEntity entity)
{
@ -40,15 +39,6 @@ public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
private set => SetAndNotify(ref _iconName, value);
}
/// <summary>
/// Gets the original file name of the icon (if applicable)
/// </summary>
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>
@ -69,7 +59,6 @@ public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
_iconStream?.Dispose();
IconName = iconName;
OriginalFileName = null;
IconType = ProfileConfigurationIconType.MaterialIcon;
OnIconUpdated();
@ -78,11 +67,9 @@ public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
/// <summary>
/// Updates the stream returned by <see cref="GetIconStream" /> to the provided stream
/// </summary>
/// <param name="originalFileName">The original file name backing the stream, should include the extension</param>
/// <param name="stream">The stream to copy</param>
public void SetIconByStream(string originalFileName, Stream stream)
public void SetIconByStream(Stream stream)
{
if (originalFileName == null) throw new ArgumentNullException(nameof(originalFileName));
if (stream == null) throw new ArgumentNullException(nameof(stream));
_iconStream?.Dispose();
@ -92,7 +79,6 @@ public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
_iconStream.Seek(0, SeekOrigin.Begin);
IconName = null;
OriginalFileName = originalFileName;
IconType = ProfileConfigurationIconType.BitmapImage;
OnIconUpdated();
}

View File

@ -187,7 +187,7 @@ internal class ProfileService : IProfileService
using Stream? stream = _profileCategoryRepository.GetProfileIconStream(profileConfiguration.Entity.FileIconId);
if (stream != null)
profileConfiguration.Icon.SetIconByStream(profileConfiguration.Entity.IconOriginalFileName, stream);
profileConfiguration.Icon.SetIconByStream(stream);
}
/// <inheritdoc />
@ -197,11 +197,8 @@ internal class ProfileService : IProfileService
return;
using Stream? stream = profileConfiguration.Icon.GetIconStream();
if (stream != null && profileConfiguration.Icon.OriginalFileName != null)
{
profileConfiguration.Entity.IconOriginalFileName = profileConfiguration.Icon.OriginalFileName;
if (stream != null)
_profileCategoryRepository.SaveProfileIconStream(profileConfiguration.Entity, stream);
}
}
/// <inheritdoc />
@ -441,8 +438,11 @@ internal class ProfileService : IProfileService
profileConfiguration = new ProfileConfiguration(category, profileEntity.Name, "Import");
}
if (exportModel.ProfileImage != null && exportModel.ProfileConfigurationEntity?.IconOriginalFileName != null)
profileConfiguration.Icon.SetIconByStream(exportModel.ProfileConfigurationEntity.IconOriginalFileName, exportModel.ProfileImage);
if (exportModel.ProfileImage != null)
{
profileConfiguration.Icon.SetIconByStream(exportModel.ProfileImage);
SaveProfileConfigurationIcon(profileConfiguration);
}
profileConfiguration.Entity.ProfileId = profileEntity.Id;
category.AddProfileConfiguration(profileConfiguration, 0);
@ -450,7 +450,7 @@ internal class ProfileService : IProfileService
List<Module> modules = _pluginManagementService.GetFeaturesOfType<Module>();
profileConfiguration.LoadModules(modules);
SaveProfileCategory(category);
return profileConfiguration;
}

View File

@ -7,7 +7,6 @@ public class ProfileConfigurationEntity
{
public string Name { get; set; }
public string MaterialIcon { get; set; }
public string IconOriginalFileName { get; set; }
public Guid FileIconId { get; set; }
public int IconType { get; set; }
public bool IconFill { get; set; }

View File

@ -70,6 +70,6 @@ internal class ProfileCategoryRepository : IProfileCategoryRepository
if (stream == null && _profileIcons.Exists(profileConfigurationEntity.FileIconId))
_profileIcons.Delete(profileConfigurationEntity.FileIconId);
_profileIcons.Upload(profileConfigurationEntity.FileIconId, profileConfigurationEntity.IconOriginalFileName, stream);
_profileIcons.Upload(profileConfigurationEntity.FileIconId, profileConfigurationEntity.FileIconId + ".png", stream);
}
}