diff --git a/src/Artemis.Core/Models/Profile/LayerProperties/BaseLayerProperty.cs b/src/Artemis.Core/Models/Profile/LayerProperties/BaseLayerProperty.cs index 9dbed60a3..bed89fd32 100644 --- a/src/Artemis.Core/Models/Profile/LayerProperties/BaseLayerProperty.cs +++ b/src/Artemis.Core/Models/Profile/LayerProperties/BaseLayerProperty.cs @@ -10,6 +10,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties public abstract class BaseLayerProperty { private bool _keyframesEnabled; + private bool _isHidden; internal BaseLayerProperty() { @@ -48,7 +49,15 @@ namespace Artemis.Core.Models.Profile.LayerProperties /// /// Gets or sets whether the property is hidden in the UI /// - public bool IsHidden { get; set; } + public bool IsHidden + { + get => _isHidden; + set + { + _isHidden = value; + OnVisibilityChanged(); + } + } /// /// Indicates whether the BaseValue was loaded from storage, useful to check whether a default value must be applied @@ -100,6 +109,11 @@ namespace Artemis.Core.Models.Profile.LayerProperties /// public event EventHandler BaseValueChanged; + /// + /// Occurs when the value of the layer property was updated + /// + public event EventHandler VisibilityChanged; + /// /// Occurs when keyframes are enabled/disabled /// @@ -125,6 +139,11 @@ namespace Artemis.Core.Models.Profile.LayerProperties BaseValueChanged?.Invoke(this, EventArgs.Empty); } + protected virtual void OnVisibilityChanged() + { + VisibilityChanged?.Invoke(this, EventArgs.Empty); + } + protected virtual void OnKeyframesToggled() { KeyframesToggled?.Invoke(this, EventArgs.Empty); @@ -143,5 +162,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties #endregion public abstract void ApplyDefaultValue(); + + } } \ No newline at end of file diff --git a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs index 03184f426..edf61b8d5 100644 --- a/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs +++ b/src/Artemis.Core/Models/Profile/LayerProperties/LayerProperty.cs @@ -284,6 +284,7 @@ namespace Artemis.Core.Models.Profile.LayerProperties public override void ApplyDefaultValue() { + BaseValue = DefaultValue; CurrentValue = DefaultValue; } } diff --git a/src/Artemis.Core/Models/Profile/LayerProperties/Types/ColorGradientLayerProperty.cs b/src/Artemis.Core/Models/Profile/LayerProperties/Types/ColorGradientLayerProperty.cs index 7b6c36d5f..11cf760d3 100644 --- a/src/Artemis.Core/Models/Profile/LayerProperties/Types/ColorGradientLayerProperty.cs +++ b/src/Artemis.Core/Models/Profile/LayerProperties/Types/ColorGradientLayerProperty.cs @@ -4,7 +4,7 @@ using Artemis.Storage.Entities.Profile; namespace Artemis.Core.Models.Profile.LayerProperties.Types { - /// + /// public class ColorGradientLayerProperty : LayerProperty { internal ColorGradientLayerProperty() @@ -12,21 +12,17 @@ namespace Artemis.Core.Models.Profile.LayerProperties.Types KeyframesSupported = false; } - internal override void ApplyToLayerProperty(PropertyEntity entity, LayerPropertyGroup layerPropertyGroup, bool fromStorage) - { - base.ApplyToLayerProperty(entity, layerPropertyGroup, fromStorage); - - // Don't allow color gradients to be null - if (BaseValue == null) - { - BaseValue = DefaultValue ?? new ColorGradient(); - } - - } - protected override void UpdateCurrentValue(float keyframeProgress, float keyframeProgressEased) { throw new ArtemisCoreException("Color Gradients do not support keyframes."); } + + internal override void ApplyToLayerProperty(PropertyEntity entity, LayerPropertyGroup layerPropertyGroup, bool fromStorage) + { + base.ApplyToLayerProperty(entity, layerPropertyGroup, fromStorage); + + // Don't allow color gradients to be null + BaseValue ??= DefaultValue ?? new ColorGradient(); + } } } \ No newline at end of file diff --git a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs index c804705de..5b0dc8a60 100644 --- a/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs +++ b/src/Artemis.Core/Models/Profile/LayerPropertyGroup.cs @@ -18,6 +18,7 @@ namespace Artemis.Core.Models.Profile private readonly List _layerProperties; private readonly List _layerPropertyGroups; private ReadOnlyCollection _allLayerProperties; + private bool _isHidden; protected LayerPropertyGroup() { @@ -53,7 +54,15 @@ namespace Artemis.Core.Models.Profile /// /// Gets or sets whether the property is hidden in the UI /// - public bool IsHidden { get; set; } + public bool IsHidden + { + get => _isHidden; + set + { + _isHidden = value; + OnVisibilityChanged(); + } + } /// /// A list of all layer properties in this group @@ -211,6 +220,11 @@ namespace Artemis.Core.Models.Profile internal event EventHandler PropertyGroupOverriding; public event EventHandler PropertyGroupInitialized; + /// + /// Occurs when the value of the layer property was updated + /// + public event EventHandler VisibilityChanged; + internal virtual void OnPropertyGroupUpdating(PropertyGroupUpdatingEventArgs e) { PropertyGroupUpdating?.Invoke(this, e); @@ -221,6 +235,11 @@ namespace Artemis.Core.Models.Profile PropertyGroupOverriding?.Invoke(this, e); } + protected virtual void OnVisibilityChanged() + { + VisibilityChanged?.Invoke(this, EventArgs.Empty); + } + #endregion } } \ No newline at end of file diff --git a/src/Artemis.Core/Services/Storage/Interfaces/IProfileService.cs b/src/Artemis.Core/Services/Storage/Interfaces/IProfileService.cs index 30b2b12bf..9fe885d6b 100644 --- a/src/Artemis.Core/Services/Storage/Interfaces/IProfileService.cs +++ b/src/Artemis.Core/Services/Storage/Interfaces/IProfileService.cs @@ -26,13 +26,13 @@ namespace Artemis.Core.Services.Storage.Interfaces /// /// /// - void UndoUpdateProfile(Profile selectedProfile, ProfileModule module); + bool UndoUpdateProfile(Profile selectedProfile, ProfileModule module); /// /// Attempts to restore the profile to the state it had before the last call. /// /// /// - void RedoUpdateProfile(Profile selectedProfile, ProfileModule module); + bool RedoUpdateProfile(Profile selectedProfile, ProfileModule module); } } \ No newline at end of file diff --git a/src/Artemis.Core/Services/Storage/ProfileService.cs b/src/Artemis.Core/Services/Storage/ProfileService.cs index a415ba49c..733201487 100644 --- a/src/Artemis.Core/Services/Storage/ProfileService.cs +++ b/src/Artemis.Core/Services/Storage/ProfileService.cs @@ -123,12 +123,12 @@ namespace Artemis.Core.Services.Storage _profileRepository.Save(profile.ProfileEntity); } - public void UndoUpdateProfile(Profile profile, ProfileModule module) + public bool UndoUpdateProfile(Profile profile, ProfileModule module) { if (!profile.UndoStack.Any()) { _logger.Debug("Undo profile update - Failed, undo stack empty"); - return; + return false; } ActivateProfile(module, null); @@ -140,14 +140,15 @@ namespace Artemis.Core.Services.Storage ActivateProfile(module, profile); _logger.Debug("Undo profile update - Success"); + return true; } - public void RedoUpdateProfile(Profile profile, ProfileModule module) + public bool RedoUpdateProfile(Profile profile, ProfileModule module) { if (!profile.RedoStack.Any()) { _logger.Debug("Redo profile update - Failed, redo empty"); - return; + return false; } ActivateProfile(module, null); @@ -159,6 +160,7 @@ namespace Artemis.Core.Services.Storage ActivateProfile(module, profile); _logger.Debug("Redo profile update - Success"); + return true; } private void InitializeLayerProperties(Profile profile) @@ -169,7 +171,9 @@ namespace Artemis.Core.Services.Storage layer.General.InitializeProperties(_layerService, layer, "General."); if (!layer.Transform.PropertiesInitialized) layer.Transform.InitializeProperties(_layerService, layer, "Transform."); - }; + } + + ; } private void InstantiateLayerBrushes(Profile profile) @@ -178,7 +182,7 @@ namespace Artemis.Core.Services.Storage foreach (var layer in profile.GetAllLayers().Where(l => l.LayerBrush == null)) _layerService.InstantiateLayerBrush(layer); } - + private void ActiveProfilesPopulateLeds(ArtemisSurface surface) { var profileModules = _pluginService.GetPluginsOfType(); @@ -192,7 +196,7 @@ namespace Artemis.Core.Services.Storage foreach (var profileModule in profileModules.Where(p => p.ActiveProfile != null).ToList()) InstantiateLayerBrushes(profileModule.ActiveProfile); } - + #region Event handlers private void OnActiveSurfaceConfigurationSelected(object sender, SurfaceConfigurationEventArgs e) diff --git a/src/Artemis.Storage/Entities/Profile/LayerEntity.cs b/src/Artemis.Storage/Entities/Profile/LayerEntity.cs index 0792079ca..d3ab661bd 100644 --- a/src/Artemis.Storage/Entities/Profile/LayerEntity.cs +++ b/src/Artemis.Storage/Entities/Profile/LayerEntity.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Text.Json.Serialization; using LiteDB; namespace Artemis.Storage.Entities.Profile diff --git a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml index 4d6db87f3..faba740fa 100644 --- a/src/Artemis.UI.Shared/Controls/ColorPicker.xaml +++ b/src/Artemis.UI.Shared/Controls/ColorPicker.xaml @@ -9,10 +9,6 @@ d:DesignHeight="101.848" d:DesignWidth="242.956"> - - - - @@ -62,14 +58,14 @@ Grid.Row="1" OpacityMask="{x:Null}"> - + - + + Template="{DynamicResource MaterialDesignColorSliderThumb}"> @@ -124,7 +120,7 @@ diff --git a/src/Artemis.UI.Shared/Controls/GradientPicker.xaml b/src/Artemis.UI.Shared/Controls/GradientPicker.xaml index 544726848..43bdc3b20 100644 --- a/src/Artemis.UI.Shared/Controls/GradientPicker.xaml +++ b/src/Artemis.UI.Shared/Controls/GradientPicker.xaml @@ -8,10 +8,6 @@ d:DesignHeight="450" d:DesignWidth="800"> - - - - diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml index 5a952bbfc..84427a570 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesView.xaml @@ -61,7 +61,7 @@ - + @@ -196,16 +196,15 @@ HorizontalAlignment="Stretch" ZIndex="2" Background="{DynamicResource MaterialDesignCardBackground}"> + - - - + \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs index 746746904..a26b72885 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertiesViewModel.cs @@ -92,6 +92,13 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties #region View model managament + public List GetAllLayerPropertyGroupViewModels() + { + var groups = LayerPropertyGroups.ToList(); + groups.AddRange(groups.SelectMany(g => g.Children).Where(g => g is LayerPropertyGroupViewModel).Cast()); + return groups; + } + private void PopulateProperties(ProfileElement profileElement) { if (SelectedLayer != null) diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs index e87e2409a..831e18d62 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyGroupViewModel.cs @@ -23,8 +23,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties TimelinePropertyGroupViewModel = new TimelinePropertyGroupViewModel(this); PopulateChildren(); + LayerPropertyGroup.VisibilityChanged += LayerPropertyGroupOnVisibilityChanged; } + public override bool IsExpanded { get => LayerPropertyGroup.Layer.IsPropertyGroupExpanded(LayerPropertyGroup); @@ -68,7 +70,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties public override List GetKeyframes(bool visibleOnly) { var result = new List(); - if (!IsExpanded) + if (visibleOnly && !IsExpanded) return result; foreach (var layerPropertyBaseViewModel in Children) @@ -81,6 +83,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties { foreach (var layerPropertyBaseViewModel in Children) layerPropertyBaseViewModel.Dispose(); + + LayerPropertyGroup.VisibilityChanged -= LayerPropertyGroupOnVisibilityChanged; + TimelinePropertyGroupViewModel.Dispose(); } public List GetAllChildren() @@ -95,5 +100,10 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties return result; } + + private void LayerPropertyGroupOnVisibilityChanged(object? sender, EventArgs e) + { + NotifyOfPropertyChange(nameof(IsVisible)); + } } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyViewModel.cs index 0c193a3d1..31980c093 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/LayerPropertyViewModel.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; using Artemis.Core.Models.Profile.LayerProperties; using Artemis.Core.Models.Profile.LayerProperties.Attributes; @@ -33,6 +34,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties else PropertyDescription.Name = $"Unknown {typeof(T).Name} property"; } + + LayerProperty.VisibilityChanged += LayerPropertyOnVisibilityChanged; } public override bool IsVisible => !LayerProperty.IsHidden; @@ -51,6 +54,8 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties { TreePropertyViewModel.Dispose(); TimelinePropertyViewModel.Dispose(); + + LayerProperty.VisibilityChanged -= LayerPropertyOnVisibilityChanged; } public void SetCurrentValue(T value, bool saveChanges) @@ -61,6 +66,11 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties else ProfileEditorService.UpdateProfilePreview(); } + + private void LayerPropertyOnVisibilityChanged(object? sender, EventArgs e) + { + NotifyOfPropertyChange(nameof(IsVisible)); + } } public abstract class LayerPropertyViewModel : LayerPropertyBaseViewModel diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupView.xaml index 9a54c20ec..f9458962b 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupView.xaml +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupView.xaml @@ -30,42 +30,17 @@ - - - - + Margin="-5,6,0,0"> diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupViewModel.cs index 69994652f..6ddd85e30 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelinePropertyGroupViewModel.cs @@ -1,4 +1,8 @@ -using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract; +using System; +using System.ComponentModel; +using System.Linq; +using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract; +using Stylet; namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline { @@ -7,8 +11,40 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline public TimelinePropertyGroupViewModel(LayerPropertyBaseViewModel layerPropertyBaseViewModel) { LayerPropertyGroupViewModel = (LayerPropertyGroupViewModel) layerPropertyBaseViewModel; + TimelineKeyframeViewModels = new BindableCollection(); + + LayerPropertyGroupViewModel.ProfileEditorService.PixelsPerSecondChanged += ProfileEditorServiceOnPixelsPerSecondChanged; + LayerPropertyGroupViewModel.PropertyChanged += LayerPropertyGroupViewModelOnPropertyChanged; + UpdateKeyframes(); } public LayerPropertyGroupViewModel LayerPropertyGroupViewModel { get; } + public BindableCollection TimelineKeyframeViewModels { get; set; } + public TimelineViewModel TimelineViewModel { get; set; } + + public void UpdateKeyframes() + { + TimelineKeyframeViewModels.Clear(); + TimelineKeyframeViewModels.AddRange(LayerPropertyGroupViewModel.GetKeyframes(false) + .Select(k => LayerPropertyGroupViewModel.ProfileEditorService.PixelsPerSecond * k.Position.TotalSeconds)); + } + + + public void Dispose() + { + LayerPropertyGroupViewModel.ProfileEditorService.PixelsPerSecondChanged -= ProfileEditorServiceOnPixelsPerSecondChanged; + LayerPropertyGroupViewModel.PropertyChanged -= LayerPropertyGroupViewModelOnPropertyChanged; + } + + private void LayerPropertyGroupViewModelOnPropertyChanged(object sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == nameof(LayerPropertyGroupViewModel.IsExpanded)) + UpdateKeyframes(); + } + + private void ProfileEditorServiceOnPixelsPerSecondChanged(object? sender, EventArgs e) + { + UpdateKeyframes(); + } } } \ No newline at end of file diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelineViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelineViewModel.cs index a1b710930..05c9a466d 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelineViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/Timeline/TimelineViewModel.cs @@ -32,6 +32,9 @@ namespace Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Timeline { foreach (var layerPropertyGroupViewModel in LayerPropertyGroups) { + layerPropertyGroupViewModel.TimelinePropertyGroupViewModel.TimelineViewModel = this; + layerPropertyGroupViewModel.TimelinePropertyGroupViewModel.UpdateKeyframes(); + foreach (var layerPropertyBaseViewModel in layerPropertyGroupViewModel.GetAllChildren()) { if (layerPropertyBaseViewModel is LayerPropertyViewModel layerPropertyViewModel) diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs index bc1ba03db..dcb3cfdff 100644 --- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs +++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs @@ -11,6 +11,7 @@ using Artemis.Core.Services.Storage.Interfaces; using Artemis.UI.Screens.Module.ProfileEditor.Dialogs; using Artemis.UI.Screens.Module.ProfileEditor.DisplayConditions; using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties; +using Artemis.UI.Screens.Module.ProfileEditor.LayerProperties.Abstract; using Artemis.UI.Screens.Module.ProfileEditor.ProfileTree; using Artemis.UI.Screens.Module.ProfileEditor.Visualization; using Artemis.UI.Services.Interfaces; @@ -110,12 +111,28 @@ namespace Artemis.UI.Screens.Module.ProfileEditor public void Undo() { + // Expanded status is also undone because undoing works a bit crude, that's annoying + var beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels(); + var expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList(); + _profileEditorService.UndoUpdateProfile(Module); + + // Restore the expanded status + foreach (var allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels()) + allLayerPropertyGroupViewModel.IsExpanded = expandedPaths.Contains(allLayerPropertyGroupViewModel.LayerPropertyGroup.Path); } public void Redo() { + // Expanded status is also undone because undoing works a bit crude, that's annoying + var beforeGroups = LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels(); + var expandedPaths = beforeGroups.Where(g => g.IsExpanded).Select(g => g.LayerPropertyGroup.Path).ToList(); + _profileEditorService.RedoUpdateProfile(Module); + + // Restore the expanded status + foreach (var allLayerPropertyGroupViewModel in LayerPropertiesViewModel.GetAllLayerPropertyGroupViewModels()) + allLayerPropertyGroupViewModel.IsExpanded = expandedPaths.Contains(allLayerPropertyGroupViewModel.LayerPropertyGroup.Path); } protected override void OnInitialActivate() diff --git a/src/Artemis.UI/Services/ProfileEditorService.cs b/src/Artemis.UI/Services/ProfileEditorService.cs index a2a226976..2f3fd1bb1 100644 --- a/src/Artemis.UI/Services/ProfileEditorService.cs +++ b/src/Artemis.UI/Services/ProfileEditorService.cs @@ -157,7 +157,10 @@ namespace Artemis.UI.Services public void UndoUpdateProfile(ProfileModule module) { - _profileService.UndoUpdateProfile(SelectedProfile, module); + var undid = _profileService.UndoUpdateProfile(SelectedProfile, module); + if (!undid) + return; + OnSelectedProfileChanged(new ProfileElementEventArgs(SelectedProfile, SelectedProfile)); if (SelectedProfileElement != null) @@ -173,7 +176,10 @@ namespace Artemis.UI.Services public void RedoUpdateProfile(ProfileModule module) { - _profileService.RedoUpdateProfile(SelectedProfile, module); + var redid = _profileService.RedoUpdateProfile(SelectedProfile, module); + if (!redid) + return; + OnSelectedProfileChanged(new ProfileElementEventArgs(SelectedProfile, SelectedProfile)); if (SelectedProfileElement != null) diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrushProperties.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrushProperties.cs index 435000945..bb9b05181 100644 --- a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrushProperties.cs +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrushProperties.cs @@ -28,10 +28,11 @@ namespace Artemis.Plugins.LayerBrushes.Color protected override void OnPropertiesInitialized() { - GradientType.BaseValueChanged += GradientTypeOnBaseValueChanged; + GradientType.BaseValueChanged += (sender, args) => UpdateVisibility(); + UpdateVisibility(); } - private void GradientTypeOnBaseValueChanged(object sender, EventArgs e) + private void UpdateVisibility() { Color.IsHidden = GradientType.BaseValue != LayerBrushes.Color.GradientType.Solid; Gradient.IsHidden = GradientType.BaseValue == LayerBrushes.Color.GradientType.Solid; diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrushProperties.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrushProperties.cs index f2fda9f33..61b39c038 100644 --- a/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrushProperties.cs +++ b/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrushProperties.cs @@ -46,10 +46,11 @@ namespace Artemis.Plugins.LayerBrushes.Noise protected override void OnPropertiesInitialized() { - ColorType.BaseValueChanged += ColorTypeOnBaseValueChanged; + ColorType.BaseValueChanged += (sender, args) => UpdateVisibility(); + UpdateVisibility(); } - private void ColorTypeOnBaseValueChanged(object sender, EventArgs e) + private void UpdateVisibility() { GradientColor.IsHidden = ColorType.BaseValue != ColorMappingType.Gradient; MainColor.IsHidden = ColorType.BaseValue != ColorMappingType.Simple;