mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 20:06:33 +00:00
Profile elements - Simplified class hierarchy
Profile editor - Seperated event types and avoid a lot of type checking Profile editor - Avoid changing profiles/layers if the new equals the old Color picker - Fixed binding error Profile tree - Select first element by default Profile editor - Adjusted initialization order
This commit is contained in:
1 parent
70aaa645fb
commit
7b27d076b3
25 files changed
+303
-195
No files matched your search
@@ -12,7 +12,7 @@ namespace Artemis.UI.Shared.Services.Interfaces
|
||||
public interface IProfileEditorService : IArtemisSharedUIService
|
||||
{
|
||||
Profile SelectedProfile { get; }
|
||||
ProfileElement SelectedProfileElement { get; }
|
||||
RenderProfileElement SelectedProfileElement { get; }
|
||||
TimeSpan CurrentTime { get; set; }
|
||||
int PixelsPerSecond { get; set; }
|
||||
IReadOnlyList<PropertyInputRegistration> RegisteredPropertyEditors { get; }
|
||||
@@ -20,7 +20,7 @@ namespace Artemis.UI.Shared.Services.Interfaces
|
||||
|
||||
void ChangeSelectedProfile(Profile profile);
|
||||
void UpdateSelectedProfile();
|
||||
void ChangeSelectedProfileElement(ProfileElement profileElement);
|
||||
void ChangeSelectedProfileElement(RenderProfileElement profileElement);
|
||||
void UpdateSelectedProfileElement();
|
||||
void UpdateProfilePreview();
|
||||
void UndoUpdateProfile(ProfileModule module);
|
||||
@@ -32,22 +32,22 @@ namespace Artemis.UI.Shared.Services.Interfaces
|
||||
/// <summary>
|
||||
/// Occurs when a new profile is selected
|
||||
/// </summary>
|
||||
event EventHandler<ProfileElementEventArgs> ProfileSelected;
|
||||
event EventHandler<ProfileEventArgs> ProfileSelected;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs then the currently selected profile is updated
|
||||
/// </summary>
|
||||
event EventHandler<ProfileElementEventArgs> SelectedProfileUpdated;
|
||||
event EventHandler<ProfileEventArgs> SelectedProfileUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when a new profile element is selected
|
||||
/// </summary>
|
||||
event EventHandler<ProfileElementEventArgs> ProfileElementSelected;
|
||||
event EventHandler<RenderProfileElementEventArgs> ProfileElementSelected;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the currently selected profile element is updated
|
||||
/// </summary>
|
||||
event EventHandler<ProfileElementEventArgs> SelectedProfileElementUpdated;
|
||||
event EventHandler<RenderProfileElementEventArgs> SelectedProfileElementUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the current editor time is changed
|
||||
|
||||
@@ -11,6 +11,7 @@ using Artemis.UI.Shared.Events;
|
||||
using Artemis.UI.Shared.PropertyInput;
|
||||
using Artemis.UI.Shared.Services.Interfaces;
|
||||
using Ninject;
|
||||
using Serilog;
|
||||
|
||||
namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
@@ -18,15 +19,17 @@ namespace Artemis.UI.Shared.Services
|
||||
{
|
||||
private readonly ICoreService _coreService;
|
||||
private readonly IProfileService _profileService;
|
||||
private readonly ILogger _logger;
|
||||
private readonly List<PropertyInputRegistration> _registeredPropertyEditors;
|
||||
private TimeSpan _currentTime;
|
||||
private TimeSpan _lastUpdateTime;
|
||||
private int _pixelsPerSecond;
|
||||
|
||||
public ProfileEditorService(ICoreService coreService, IProfileService profileService, IKernel kernel)
|
||||
public ProfileEditorService(ICoreService coreService, IProfileService profileService, IKernel kernel, ILogger logger)
|
||||
{
|
||||
_coreService = coreService;
|
||||
_profileService = profileService;
|
||||
_logger = logger;
|
||||
_registeredPropertyEditors = new List<PropertyInputRegistration>();
|
||||
|
||||
Kernel = kernel;
|
||||
@@ -36,7 +39,7 @@ namespace Artemis.UI.Shared.Services
|
||||
public IKernel Kernel { get; }
|
||||
public IReadOnlyList<PropertyInputRegistration> RegisteredPropertyEditors => _registeredPropertyEditors.AsReadOnly();
|
||||
public Profile SelectedProfile { get; private set; }
|
||||
public ProfileElement SelectedProfileElement { get; private set; }
|
||||
public RenderProfileElement SelectedProfileElement { get; private set; }
|
||||
|
||||
public TimeSpan CurrentTime
|
||||
{
|
||||
@@ -63,9 +66,13 @@ namespace Artemis.UI.Shared.Services
|
||||
|
||||
public void ChangeSelectedProfile(Profile profile)
|
||||
{
|
||||
if (SelectedProfile == profile)
|
||||
return;
|
||||
|
||||
_logger.Verbose("ChangeSelectedProfile {profile}", profile);
|
||||
ChangeSelectedProfileElement(null);
|
||||
|
||||
var profileElementEvent = new ProfileElementEventArgs(profile, SelectedProfile);
|
||||
var profileElementEvent = new ProfileEventArgs(profile, SelectedProfile);
|
||||
SelectedProfile = profile;
|
||||
UpdateProfilePreview();
|
||||
OnSelectedProfileChanged(profileElementEvent);
|
||||
@@ -73,23 +80,29 @@ namespace Artemis.UI.Shared.Services
|
||||
|
||||
public void UpdateSelectedProfile()
|
||||
{
|
||||
_logger.Verbose("UpdateSelectedProfile {profile}", SelectedProfile);
|
||||
_profileService.UpdateProfile(SelectedProfile, true);
|
||||
UpdateProfilePreview();
|
||||
OnSelectedProfileElementUpdated(new ProfileElementEventArgs(SelectedProfile));
|
||||
OnSelectedProfileChanged(new ProfileEventArgs(SelectedProfile));
|
||||
}
|
||||
|
||||
public void ChangeSelectedProfileElement(ProfileElement profileElement)
|
||||
public void ChangeSelectedProfileElement(RenderProfileElement profileElement)
|
||||
{
|
||||
var profileElementEvent = new ProfileElementEventArgs(profileElement, SelectedProfileElement);
|
||||
if (SelectedProfileElement == profileElement)
|
||||
return;
|
||||
|
||||
_logger.Verbose("ChangeSelectedProfileElement {profile}", profileElement);
|
||||
var profileElementEvent = new RenderProfileElementEventArgs(profileElement, SelectedProfileElement);
|
||||
SelectedProfileElement = profileElement;
|
||||
OnSelectedProfileElementChanged(profileElementEvent);
|
||||
}
|
||||
|
||||
public void UpdateSelectedProfileElement()
|
||||
{
|
||||
_logger.Verbose("UpdateSelectedProfileElement {profile}", SelectedProfileElement);
|
||||
_profileService.UpdateProfile(SelectedProfile, true);
|
||||
UpdateProfilePreview();
|
||||
OnSelectedProfileElementUpdated(new ProfileElementEventArgs(SelectedProfileElement));
|
||||
OnSelectedProfileElementUpdated(new RenderProfileElementEventArgs(SelectedProfileElement));
|
||||
}
|
||||
|
||||
public void UpdateProfilePreview()
|
||||
@@ -122,11 +135,11 @@ namespace Artemis.UI.Shared.Services
|
||||
if (!undid)
|
||||
return;
|
||||
|
||||
OnSelectedProfileChanged(new ProfileElementEventArgs(SelectedProfile, SelectedProfile));
|
||||
OnSelectedProfileChanged(new ProfileEventArgs(SelectedProfile, SelectedProfile));
|
||||
|
||||
if (SelectedProfileElement != null)
|
||||
{
|
||||
var elements = SelectedProfile.GetAllLayers().Cast<ProfileElement>().ToList();
|
||||
var elements = SelectedProfile.GetAllLayers().Cast<RenderProfileElement>().ToList();
|
||||
elements.AddRange(SelectedProfile.GetAllFolders());
|
||||
var element = elements.FirstOrDefault(l => l.EntityId == SelectedProfileElement.EntityId);
|
||||
ChangeSelectedProfileElement(element);
|
||||
@@ -141,11 +154,11 @@ namespace Artemis.UI.Shared.Services
|
||||
if (!redid)
|
||||
return;
|
||||
|
||||
OnSelectedProfileChanged(new ProfileElementEventArgs(SelectedProfile, SelectedProfile));
|
||||
OnSelectedProfileChanged(new ProfileEventArgs(SelectedProfile, SelectedProfile));
|
||||
|
||||
if (SelectedProfileElement != null)
|
||||
{
|
||||
var elements = SelectedProfile.GetAllLayers().Cast<ProfileElement>().ToList();
|
||||
var elements = SelectedProfile.GetAllLayers().Cast<RenderProfileElement>().ToList();
|
||||
elements.AddRange(SelectedProfile.GetAllFolders());
|
||||
var element = elements.FirstOrDefault(l => l.EntityId == SelectedProfileElement.EntityId);
|
||||
ChangeSelectedProfileElement(element);
|
||||
@@ -194,10 +207,10 @@ namespace Artemis.UI.Shared.Services
|
||||
return (Module) SelectedProfile?.PluginInfo.Instance;
|
||||
}
|
||||
|
||||
public event EventHandler<ProfileElementEventArgs> ProfileSelected;
|
||||
public event EventHandler<ProfileElementEventArgs> SelectedProfileUpdated;
|
||||
public event EventHandler<ProfileElementEventArgs> ProfileElementSelected;
|
||||
public event EventHandler<ProfileElementEventArgs> SelectedProfileElementUpdated;
|
||||
public event EventHandler<ProfileEventArgs> ProfileSelected;
|
||||
public event EventHandler<ProfileEventArgs> SelectedProfileUpdated;
|
||||
public event EventHandler<RenderProfileElementEventArgs> ProfileElementSelected;
|
||||
public event EventHandler<RenderProfileElementEventArgs> SelectedProfileElementUpdated;
|
||||
public event EventHandler CurrentTimeChanged;
|
||||
public event EventHandler PixelsPerSecondChanged;
|
||||
public event EventHandler ProfilePreviewUpdated;
|
||||
@@ -212,22 +225,22 @@ namespace Artemis.UI.Shared.Services
|
||||
_coreService.PluginUpdatingDisabled = false;
|
||||
}
|
||||
|
||||
protected virtual void OnSelectedProfileChanged(ProfileElementEventArgs e)
|
||||
protected virtual void OnSelectedProfileChanged(ProfileEventArgs e)
|
||||
{
|
||||
ProfileSelected?.Invoke(this, e);
|
||||
}
|
||||
|
||||
protected virtual void OnSelectedProfileUpdated(ProfileElementEventArgs e)
|
||||
protected virtual void OnSelectedProfileUpdated(ProfileEventArgs e)
|
||||
{
|
||||
SelectedProfileUpdated?.Invoke(this, e);
|
||||
}
|
||||
|
||||
protected virtual void OnSelectedProfileElementChanged(ProfileElementEventArgs e)
|
||||
protected virtual void OnSelectedProfileElementChanged(RenderProfileElementEventArgs e)
|
||||
{
|
||||
ProfileElementSelected?.Invoke(this, e);
|
||||
}
|
||||
|
||||
protected virtual void OnSelectedProfileElementUpdated(ProfileElementEventArgs e)
|
||||
protected virtual void OnSelectedProfileElementUpdated(RenderProfileElementEventArgs e)
|
||||
{
|
||||
SelectedProfileElementUpdated?.Invoke(this, e);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user