mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Core - Removed OriginalFileName from icon since it's irrelevant
This commit is contained in:
parent
e1f0ccbcc1
commit
3a6171726c
@ -15,7 +15,6 @@ public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
|
|||||||
private string? _iconName;
|
private string? _iconName;
|
||||||
private Stream? _iconStream;
|
private Stream? _iconStream;
|
||||||
private ProfileConfigurationIconType _iconType;
|
private ProfileConfigurationIconType _iconType;
|
||||||
private string? _originalFileName;
|
|
||||||
|
|
||||||
internal ProfileConfigurationIcon(ProfileConfigurationEntity entity)
|
internal ProfileConfigurationIcon(ProfileConfigurationEntity entity)
|
||||||
{
|
{
|
||||||
@ -40,15 +39,6 @@ public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
|
|||||||
private set => SetAndNotify(ref _iconName, value);
|
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>
|
/// <summary>
|
||||||
/// Gets or sets a boolean indicating whether or not this icon should be filled.
|
/// Gets or sets a boolean indicating whether or not this icon should be filled.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -69,7 +59,6 @@ public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
|
|||||||
|
|
||||||
_iconStream?.Dispose();
|
_iconStream?.Dispose();
|
||||||
IconName = iconName;
|
IconName = iconName;
|
||||||
OriginalFileName = null;
|
|
||||||
IconType = ProfileConfigurationIconType.MaterialIcon;
|
IconType = ProfileConfigurationIconType.MaterialIcon;
|
||||||
|
|
||||||
OnIconUpdated();
|
OnIconUpdated();
|
||||||
@ -78,11 +67,9 @@ public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Updates the stream returned by <see cref="GetIconStream" /> to the provided stream
|
/// Updates the stream returned by <see cref="GetIconStream" /> to the provided stream
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="originalFileName">The original file name backing the stream, should include the extension</param>
|
|
||||||
/// <param name="stream">The stream to copy</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));
|
if (stream == null) throw new ArgumentNullException(nameof(stream));
|
||||||
|
|
||||||
_iconStream?.Dispose();
|
_iconStream?.Dispose();
|
||||||
@ -92,7 +79,6 @@ public class ProfileConfigurationIcon : CorePropertyChanged, IStorageModel
|
|||||||
_iconStream.Seek(0, SeekOrigin.Begin);
|
_iconStream.Seek(0, SeekOrigin.Begin);
|
||||||
|
|
||||||
IconName = null;
|
IconName = null;
|
||||||
OriginalFileName = originalFileName;
|
|
||||||
IconType = ProfileConfigurationIconType.BitmapImage;
|
IconType = ProfileConfigurationIconType.BitmapImage;
|
||||||
OnIconUpdated();
|
OnIconUpdated();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -187,7 +187,7 @@ internal class ProfileService : IProfileService
|
|||||||
|
|
||||||
using Stream? stream = _profileCategoryRepository.GetProfileIconStream(profileConfiguration.Entity.FileIconId);
|
using Stream? stream = _profileCategoryRepository.GetProfileIconStream(profileConfiguration.Entity.FileIconId);
|
||||||
if (stream != null)
|
if (stream != null)
|
||||||
profileConfiguration.Icon.SetIconByStream(profileConfiguration.Entity.IconOriginalFileName, stream);
|
profileConfiguration.Icon.SetIconByStream(stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -197,11 +197,8 @@ internal class ProfileService : IProfileService
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
using Stream? stream = profileConfiguration.Icon.GetIconStream();
|
using Stream? stream = profileConfiguration.Icon.GetIconStream();
|
||||||
if (stream != null && profileConfiguration.Icon.OriginalFileName != null)
|
if (stream != null)
|
||||||
{
|
|
||||||
profileConfiguration.Entity.IconOriginalFileName = profileConfiguration.Icon.OriginalFileName;
|
|
||||||
_profileCategoryRepository.SaveProfileIconStream(profileConfiguration.Entity, stream);
|
_profileCategoryRepository.SaveProfileIconStream(profileConfiguration.Entity, stream);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
@ -441,8 +438,11 @@ internal class ProfileService : IProfileService
|
|||||||
profileConfiguration = new ProfileConfiguration(category, profileEntity.Name, "Import");
|
profileConfiguration = new ProfileConfiguration(category, profileEntity.Name, "Import");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exportModel.ProfileImage != null && exportModel.ProfileConfigurationEntity?.IconOriginalFileName != null)
|
if (exportModel.ProfileImage != null)
|
||||||
profileConfiguration.Icon.SetIconByStream(exportModel.ProfileConfigurationEntity.IconOriginalFileName, exportModel.ProfileImage);
|
{
|
||||||
|
profileConfiguration.Icon.SetIconByStream(exportModel.ProfileImage);
|
||||||
|
SaveProfileConfigurationIcon(profileConfiguration);
|
||||||
|
}
|
||||||
|
|
||||||
profileConfiguration.Entity.ProfileId = profileEntity.Id;
|
profileConfiguration.Entity.ProfileId = profileEntity.Id;
|
||||||
category.AddProfileConfiguration(profileConfiguration, 0);
|
category.AddProfileConfiguration(profileConfiguration, 0);
|
||||||
@ -450,7 +450,7 @@ internal class ProfileService : IProfileService
|
|||||||
List<Module> modules = _pluginManagementService.GetFeaturesOfType<Module>();
|
List<Module> modules = _pluginManagementService.GetFeaturesOfType<Module>();
|
||||||
profileConfiguration.LoadModules(modules);
|
profileConfiguration.LoadModules(modules);
|
||||||
SaveProfileCategory(category);
|
SaveProfileCategory(category);
|
||||||
|
|
||||||
return profileConfiguration;
|
return profileConfiguration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,6 @@ public class ProfileConfigurationEntity
|
|||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string MaterialIcon { get; set; }
|
public string MaterialIcon { get; set; }
|
||||||
public string IconOriginalFileName { get; set; }
|
|
||||||
public Guid FileIconId { get; set; }
|
public Guid FileIconId { get; set; }
|
||||||
public int IconType { get; set; }
|
public int IconType { get; set; }
|
||||||
public bool IconFill { get; set; }
|
public bool IconFill { get; set; }
|
||||||
|
|||||||
@ -70,6 +70,6 @@ internal class ProfileCategoryRepository : IProfileCategoryRepository
|
|||||||
if (stream == null && _profileIcons.Exists(profileConfigurationEntity.FileIconId))
|
if (stream == null && _profileIcons.Exists(profileConfigurationEntity.FileIconId))
|
||||||
_profileIcons.Delete(profileConfigurationEntity.FileIconId);
|
_profileIcons.Delete(profileConfigurationEntity.FileIconId);
|
||||||
|
|
||||||
_profileIcons.Upload(profileConfigurationEntity.FileIconId, profileConfigurationEntity.IconOriginalFileName, stream);
|
_profileIcons.Upload(profileConfigurationEntity.FileIconId, profileConfigurationEntity.FileIconId + ".png", stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user