mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-11 19:36:28 +00:00
Profile editor - Added profile duplicate
This commit is contained in:
1 parent
e61a031485
commit
15759c9289
4 files changed
+26
-19
No files matched your search
@@ -9,12 +9,13 @@ namespace Artemis.Core
|
||||
/// </summary>
|
||||
public class ProfileDescriptor : CorePropertyChanged
|
||||
{
|
||||
private readonly ProfileEntity _profileEntity;
|
||||
|
||||
internal ProfileDescriptor(ProfileModule profileModule, ProfileEntity profileEntity)
|
||||
{
|
||||
_profileEntity = profileEntity;
|
||||
ProfileModule = profileModule;
|
||||
|
||||
Id = profileEntity.Id;
|
||||
Name = profileEntity.Name;
|
||||
IsLastActiveProfile = profileEntity.IsActive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -25,26 +26,17 @@ namespace Artemis.Core
|
||||
/// <summary>
|
||||
/// Gets the unique ID of the profile by which it can be loaded from storage
|
||||
/// </summary>
|
||||
public Guid Id => _profileEntity.Id;
|
||||
public Guid Id { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the name of the profile
|
||||
/// </summary>
|
||||
public string Name => _profileEntity.Name;
|
||||
public string Name { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets a boolean indicating whether this was the last active profile
|
||||
/// </summary>
|
||||
public bool IsLastActiveProfile => _profileEntity.IsActive;
|
||||
public bool IsLastActiveProfile { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Triggers a property change for all properties linked to the backing profile entity ¯\_(ツ)_/¯
|
||||
/// </summary>
|
||||
public void Update()
|
||||
{
|
||||
OnPropertyChanged(nameof(Id));
|
||||
OnPropertyChanged(nameof(Name));
|
||||
OnPropertyChanged(nameof(IsLastActiveProfile));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -118,7 +118,8 @@ namespace Artemis.Core.Services
|
||||
/// </summary>
|
||||
/// <param name="json">The content of the profile as JSON</param>
|
||||
/// <param name="profileModule">The module to import the profile in to</param>
|
||||
/// <param name="nameAffix">Text to add after the name of the profile (separated by a dash)</param>
|
||||
/// <returns></returns>
|
||||
ProfileDescriptor ImportProfile(string json, ProfileModule profileModule);
|
||||
ProfileDescriptor ImportProfile(string json, ProfileModule profileModule, string nameAffix = "imported");
|
||||
}
|
||||
}
|
||||
@@ -280,7 +280,7 @@ namespace Artemis.Core.Services
|
||||
return JsonConvert.SerializeObject(profileEntity, ExportSettings);
|
||||
}
|
||||
|
||||
public ProfileDescriptor ImportProfile(string json, ProfileModule profileModule)
|
||||
public ProfileDescriptor ImportProfile(string json, ProfileModule profileModule, string nameAffix)
|
||||
{
|
||||
ProfileEntity? profileEntity = JsonConvert.DeserializeObject<ProfileEntity>(json, ExportSettings);
|
||||
if (profileEntity == null)
|
||||
@@ -288,7 +288,7 @@ namespace Artemis.Core.Services
|
||||
|
||||
// Assign a new GUID to make sure it is unique in case of a previous import of the same content
|
||||
profileEntity.UpdateGuid(Guid.NewGuid());
|
||||
profileEntity.Name = $"{profileEntity.Name} - Imported";
|
||||
profileEntity.Name = $"{profileEntity.Name} - {nameAffix}";
|
||||
|
||||
_profileRepository.Add(profileEntity);
|
||||
return new ProfileDescriptor(profileModule, profileEntity);
|
||||
|
||||
Reference in new issue
Block a user