mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Profile import - Fixed and streamlined functionality
This commit is contained in:
parent
a5455c26d6
commit
8294cc306a
@ -236,7 +236,8 @@ namespace Artemis.Core.Services
|
|||||||
var profileEntity = JsonConvert.DeserializeObject<ProfileEntity>(json, ExportSettings);
|
var profileEntity = JsonConvert.DeserializeObject<ProfileEntity>(json, ExportSettings);
|
||||||
|
|
||||||
// Assign a new GUID to make sure it is unique in case of a previous import of the same content
|
// Assign a new GUID to make sure it is unique in case of a previous import of the same content
|
||||||
profileEntity.Id = Guid.NewGuid();
|
profileEntity.UpdateGuid(Guid.NewGuid());
|
||||||
|
profileEntity.Name = $"{profileEntity.Name} - Imported";
|
||||||
|
|
||||||
_profileRepository.Add(profileEntity);
|
_profileRepository.Add(profileEntity);
|
||||||
return new ProfileDescriptor(profileModule, profileEntity);
|
return new ProfileDescriptor(profileModule, profileEntity);
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace Artemis.Storage.Entities.Profile
|
namespace Artemis.Storage.Entities.Profile
|
||||||
{
|
{
|
||||||
@ -19,5 +20,15 @@ namespace Artemis.Storage.Entities.Profile
|
|||||||
|
|
||||||
public List<FolderEntity> Folders { get; set; }
|
public List<FolderEntity> Folders { get; set; }
|
||||||
public List<LayerEntity> Layers { get; set; }
|
public List<LayerEntity> Layers { get; set; }
|
||||||
|
|
||||||
|
public void UpdateGuid(Guid guid)
|
||||||
|
{
|
||||||
|
var oldGuid = Id;
|
||||||
|
Id = guid;
|
||||||
|
|
||||||
|
var rootFolder = Folders.FirstOrDefault(f => f.ParentId == oldGuid);
|
||||||
|
if (rootFolder != null)
|
||||||
|
rootFolder.ParentId = Id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -32,9 +32,9 @@ namespace Artemis.UI.Screens.ProfileEditor.Dialogs
|
|||||||
|
|
||||||
public void Accept()
|
public void Accept()
|
||||||
{
|
{
|
||||||
_profileService.ImportProfile(Document.Text, ProfileModule);
|
var descriptor = _profileService.ImportProfile(Document.Text, ProfileModule);
|
||||||
_mainMessageQueue.Enqueue("Profile imported.");
|
_mainMessageQueue.Enqueue("Profile imported.");
|
||||||
Session.Close();
|
Session.Close(descriptor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cancel()
|
public void Cancel()
|
||||||
|
|||||||
@ -6,6 +6,7 @@ using System.Windows;
|
|||||||
using Artemis.Core;
|
using Artemis.Core;
|
||||||
using Artemis.Core.Modules;
|
using Artemis.Core.Modules;
|
||||||
using Artemis.Core.Services;
|
using Artemis.Core.Services;
|
||||||
|
using Artemis.UI.Extensions;
|
||||||
using Artemis.UI.Screens.ProfileEditor.Dialogs;
|
using Artemis.UI.Screens.ProfileEditor.Dialogs;
|
||||||
using Artemis.UI.Screens.ProfileEditor.DisplayConditions;
|
using Artemis.UI.Screens.ProfileEditor.DisplayConditions;
|
||||||
using Artemis.UI.Screens.ProfileEditor.LayerProperties;
|
using Artemis.UI.Screens.ProfileEditor.LayerProperties;
|
||||||
@ -58,7 +59,7 @@ namespace Artemis.UI.Screens.ProfileEditor
|
|||||||
DialogService = dialogService;
|
DialogService = dialogService;
|
||||||
|
|
||||||
Profiles = new BindableCollection<ProfileDescriptor>();
|
Profiles = new BindableCollection<ProfileDescriptor>();
|
||||||
|
|
||||||
// Populate the panels
|
// Populate the panels
|
||||||
ProfileViewModel = profileViewModel;
|
ProfileViewModel = profileViewModel;
|
||||||
ProfileTreeViewModel = profileTreeViewModel;
|
ProfileTreeViewModel = profileTreeViewModel;
|
||||||
@ -190,10 +191,16 @@ namespace Artemis.UI.Screens.ProfileEditor
|
|||||||
|
|
||||||
public async Task ImportProfile()
|
public async Task ImportProfile()
|
||||||
{
|
{
|
||||||
await DialogService.ShowDialog<ProfileImportViewModel>(new Dictionary<string, object>
|
var result = await DialogService.ShowDialog<ProfileImportViewModel>(new Dictionary<string, object>
|
||||||
{
|
{
|
||||||
{"profileModule", Module}
|
{"profileModule", Module}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (result != null && result is ProfileDescriptor descriptor)
|
||||||
|
{
|
||||||
|
Profiles.Add(descriptor);
|
||||||
|
Profiles.Sort(p => p.Name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Undo()
|
public void Undo()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user