diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj
index 0562dc31d..0ae5dbd13 100644
--- a/src/Artemis.Core/Artemis.Core.csproj
+++ b/src/Artemis.Core/Artemis.Core.csproj
@@ -22,13 +22,13 @@
-
-
+
+
-
+
diff --git a/src/Artemis.Core/FodyWeavers.xsd b/src/Artemis.Core/FodyWeavers.xsd
index 2f1b8aae7..221aeb8a5 100644
--- a/src/Artemis.Core/FodyWeavers.xsd
+++ b/src/Artemis.Core/FodyWeavers.xsd
@@ -31,6 +31,16 @@
Used to control if equality checks should use the static Equals method resolved from the base class.
+
+
+ Used to turn off build warnings from this weaver.
+
+
+
+
+ Used to turn off build warnings about mismatched On_PropertyName_Changed methods.
+
+
diff --git a/src/Artemis.Core/Models/Profile/ColorGradient.cs b/src/Artemis.Core/Models/Profile/ColorGradient.cs
index 36b48c397..6f5e0ec41 100644
--- a/src/Artemis.Core/Models/Profile/ColorGradient.cs
+++ b/src/Artemis.Core/Models/Profile/ColorGradient.cs
@@ -47,7 +47,10 @@ namespace Artemis.Core.Models.Profile
public SKColor GetColor(float position)
{
- var point = Stops.SingleOrDefault(f => f.Position == position);
+ if (!Stops.Any())
+ return SKColor.Empty;
+
+ var point = Stops.FirstOrDefault(f => f.Position == position);
if (point != null) return point.Color;
var before = Stops.First(w => w.Position == Stops.Min(m => m.Position));
diff --git a/src/Artemis.Storage/Artemis.Storage.csproj b/src/Artemis.Storage/Artemis.Storage.csproj
index 0247c7075..5efccadd8 100644
--- a/src/Artemis.Storage/Artemis.Storage.csproj
+++ b/src/Artemis.Storage/Artemis.Storage.csproj
@@ -5,6 +5,6 @@
7
-
+
\ No newline at end of file
diff --git a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj
index a958d4de9..d09cfde49 100644
--- a/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj
+++ b/src/Artemis.UI.Shared/Artemis.UI.Shared.csproj
@@ -22,7 +22,7 @@
-
+
diff --git a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs
index c106546d1..1d1123483 100644
--- a/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs
+++ b/src/Artemis.UI.Shared/Controls/DeviceVisualizer.cs
@@ -21,14 +21,28 @@ namespace Artemis.UI.Shared.Controls
private readonly DrawingGroup _backingStore;
private readonly List _deviceVisualizerLeds;
private BitmapImage _deviceImage;
+ private bool _subscribed;
public DeviceVisualizer()
{
_backingStore = new DrawingGroup();
_deviceVisualizerLeds = new List();
- RGBSurface.Instance.Updated += RgbSurfaceOnUpdated;
- Unloaded += (sender, args) => Dispose();
+ Loaded += (sender, args) => SubscribeToUpdate(true);
+ Unloaded += (sender, args) => SubscribeToUpdate(false);
+ }
+
+ private void SubscribeToUpdate(bool subscribe)
+ {
+ if (_subscribed == subscribe)
+ return;
+
+ if (subscribe)
+ RGBSurface.Instance.Updated += RgbSurfaceOnUpdated;
+ else
+ RGBSurface.Instance.Updated -= RgbSurfaceOnUpdated;
+
+ _subscribed = subscribe;
}
public ArtemisDevice Device
@@ -131,7 +145,7 @@ namespace Artemis.UI.Shared.Controls
bitmapBrush.Freeze();
_backingStore.OpacityMask = bitmapBrush;
}
-
+
private void RgbSurfaceOnUpdated(UpdatedEventArgs e)
{
Dispatcher.Invoke(() =>
diff --git a/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs b/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs
index 8e740ebac..3a3a59c97 100644
--- a/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs
+++ b/src/Artemis.UI.Shared/Controls/GradientPicker.xaml.cs
@@ -46,6 +46,15 @@ namespace Artemis.UI.Shared.Controls
set => SetValue(ColorGradientProperty, value);
}
+ ///
+ /// Gets or sets the currently selected color gradient
+ ///
+ public string DialogHost
+ {
+ get => (string) GetValue(DialogHostProperty);
+ set => SetValue(DialogHostProperty, value);
+ }
+
public event PropertyChangedEventHandler PropertyChanged;
[NotifyPropertyChangedInvocator]
@@ -67,7 +76,7 @@ namespace Artemis.UI.Shared.Controls
private void UIElement_OnMouseUp(object sender, MouseButtonEventArgs e)
{
- GradientPickerService.ShowGradientPicker(ColorGradient);
+ GradientPickerService.ShowGradientPicker(ColorGradient, DialogHost);
}
#region Static WPF fields
@@ -75,6 +84,9 @@ namespace Artemis.UI.Shared.Controls
public static readonly DependencyProperty ColorGradientProperty = DependencyProperty.Register(nameof(ColorGradient), typeof(ColorGradient), typeof(GradientPicker),
new FrameworkPropertyMetadata(default(ColorGradient), FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, ColorGradientPropertyChangedCallback));
+ public static readonly DependencyProperty DialogHostProperty = DependencyProperty.Register(nameof(DialogHost), typeof(string), typeof(GradientPicker),
+ new FrameworkPropertyMetadata(default(string)));
+
public static readonly RoutedEvent ColorGradientChangedEvent =
EventManager.RegisterRoutedEvent(nameof(ColorGradient), RoutingStrategy.Bubble, typeof(RoutedPropertyChangedEventHandler), typeof(GradientPicker));
diff --git a/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopView.xaml b/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopView.xaml
index be290ccf5..8a7972d8f 100644
--- a/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopView.xaml
+++ b/src/Artemis.UI.Shared/Screens/GradientEditor/ColorStopView.xaml
@@ -42,7 +42,7 @@
-
+
@@ -53,7 +53,7 @@
-
+
+
-
-
+
+
-
-
+
+
+
-
+
-
+
Gradient saving not implemented yet
-
+
Soon you'll be able to store different gradients for usage throughout your profiles and quickly select them
@@ -50,14 +49,16 @@
-
+
-
+
-
+
@@ -85,31 +86,39 @@
-
+ IsEnabled="{Binding HasSelectedColorStopViewModel}" />
-
+
-
-
+
+
+
+
+
+
-
\ No newline at end of file
+
\ No newline at end of file
diff --git a/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs b/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs
index c930dc833..94a01c435 100644
--- a/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs
+++ b/src/Artemis.UI.Shared/Screens/GradientEditor/GradientEditorViewModel.cs
@@ -1,23 +1,29 @@
-using System.ComponentModel;
+using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using Artemis.Core.Models.Profile;
+using Artemis.UI.Shared.Services.Dialog;
using Artemis.UI.Shared.Utilities;
+using SkiaSharp;
using Stylet;
namespace Artemis.UI.Shared.Screens.GradientEditor
{
- public class GradientEditorViewModel : Screen
+ public class GradientEditorViewModel : DialogViewModelBase
{
private ColorStopViewModel _selectedColorStopViewModel;
+ private readonly List _originalStops;
public GradientEditorViewModel(ColorGradient colorGradient)
{
ColorGradient = colorGradient;
ColorStopViewModels = new BindableCollection();
+ _originalStops = ColorGradient.Stops.Select(s => new ColorGradientStop(s.Color, s.Position)).ToList();
+
foreach (var colorStop in ColorGradient.Stops.OrderBy(s => s.Position))
ColorStopViewModels.Add(new ColorStopViewModel(this, colorStop));
}
@@ -37,7 +43,8 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
public bool HasSelectedColorStopViewModel => SelectedColorStopViewModel != null;
public ColorGradient ColorGradient { get; }
- public double PreviewWidth => 437.5;
+ // TODO: Find the width out from view
+ public double PreviewWidth => 408;
public void AddColorStop(object sender, MouseEventArgs e)
{
@@ -75,5 +82,22 @@ namespace Artemis.UI.Shared.Screens.GradientEditor
foreach (var stopViewModel in ColorStopViewModels)
stopViewModel.IsSelected = stopViewModel == SelectedColorStopViewModel;
}
+
+ public void Confirm()
+ {
+ if (!Session.IsEnded)
+ Session.Close(true);
+ }
+
+ public void Cancel()
+ {
+ // Restore the saved state
+ ColorGradient.Stops.Clear();
+ ColorGradient.Stops.AddRange(_originalStops);
+ ColorGradient.OnColorValuesUpdated();
+
+ if (!Session.IsEnded)
+ Session.Close(false);
+ }
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI.Shared/Services/GradientPickerService.cs b/src/Artemis.UI.Shared/Services/GradientPickerService.cs
index 1c6e22e0c..a0b3eb5d8 100644
--- a/src/Artemis.UI.Shared/Services/GradientPickerService.cs
+++ b/src/Artemis.UI.Shared/Services/GradientPickerService.cs
@@ -1,7 +1,9 @@
-using Artemis.Core.Models.Profile;
+using System.Collections.Generic;
+using Artemis.Core.Models.Profile;
using Artemis.UI.Shared.Ninject.Factories;
using Artemis.UI.Shared.Screens.GradientEditor;
using Artemis.UI.Shared.Services.Interfaces;
+using LiteDB.Engine;
using Ninject;
using Stylet;
@@ -10,17 +12,21 @@ namespace Artemis.UI.Shared.Services
public class GradientPickerService : IGradientPickerService
{
private readonly IGradientEditorVmFactory _gradientEditorVmFactory;
+ private readonly IDialogService _dialogService;
private readonly IWindowManager _windowManager;
- public GradientPickerService(IGradientEditorVmFactory gradientEditorVmFactory, IWindowManager windowManager)
+ public GradientPickerService(IGradientEditorVmFactory gradientEditorVmFactory, IDialogService dialogService)
{
_gradientEditorVmFactory = gradientEditorVmFactory;
- _windowManager = windowManager;
+ _dialogService = dialogService;
}
- public void ShowGradientPicker(ColorGradient colorGradient)
+ public void ShowGradientPicker(ColorGradient colorGradient, string dialogHost)
{
- _windowManager.ShowDialog(_gradientEditorVmFactory.Create(colorGradient));
+ if (!string.IsNullOrWhiteSpace(dialogHost))
+ _dialogService.ShowDialogAt(dialogHost, new Dictionary {{"colorGradient", colorGradient}});
+ else
+ _dialogService.ShowDialog(new Dictionary {{"colorGradient", colorGradient}});
}
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI.Shared/Services/Interfaces/IGradientPickerService.cs b/src/Artemis.UI.Shared/Services/Interfaces/IGradientPickerService.cs
index cd750dce4..d01d54495 100644
--- a/src/Artemis.UI.Shared/Services/Interfaces/IGradientPickerService.cs
+++ b/src/Artemis.UI.Shared/Services/Interfaces/IGradientPickerService.cs
@@ -4,6 +4,6 @@ namespace Artemis.UI.Shared.Services.Interfaces
{
public interface IGradientPickerService : IArtemisSharedUIService
{
- void ShowGradientPicker(ColorGradient colorGradient);
+ void ShowGradientPicker(ColorGradient colorGradient, string dialogHost);
}
}
\ No newline at end of file
diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj
index 9282b68be..95bf6f818 100644
--- a/src/Artemis.UI/Artemis.UI.csproj
+++ b/src/Artemis.UI/Artemis.UI.csproj
@@ -116,17 +116,17 @@
-
+
-
+
-
+
diff --git a/src/Artemis.UI/FodyWeavers.xsd b/src/Artemis.UI/FodyWeavers.xsd
index 2f1b8aae7..221aeb8a5 100644
--- a/src/Artemis.UI/FodyWeavers.xsd
+++ b/src/Artemis.UI/FodyWeavers.xsd
@@ -31,6 +31,16 @@
Used to control if equality checks should use the static Equals method resolved from the base class.
+
+
+ Used to turn off build warnings from this weaver.
+
+
+
+
+ Used to turn off build warnings about mismatched On_PropertyName_Changed methods.
+
+
diff --git a/src/Artemis.UI/Screens/Home/HomeView.xaml b/src/Artemis.UI/Screens/Home/HomeView.xaml
index 41c6e0fd9..71cd26300 100644
--- a/src/Artemis.UI/Screens/Home/HomeView.xaml
+++ b/src/Artemis.UI/Screens/Home/HomeView.xaml
@@ -88,7 +88,7 @@
x:Name="GitHubButton" Command="{s:Action OpenUrl}"
CommandParameter="https://github.com/SpoinkyNL/Artemis">
-
+
GitHub
@@ -134,7 +134,7 @@
-
Open Source
@@ -178,7 +178,7 @@
-->
-
-
+
-
-
-
-
-
+
+
+
+
+
+
+
@@ -131,7 +142,8 @@
-
+
-
+
diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/PropertyTree/PropertyInput/ColorGradientPropertyInputView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/PropertyTree/PropertyInput/ColorGradientPropertyInputView.xaml
index d50535da3..c871a6cbe 100644
--- a/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/PropertyTree/PropertyInput/ColorGradientPropertyInputView.xaml
+++ b/src/Artemis.UI/Screens/Module/ProfileEditor/LayerProperties/PropertyTree/PropertyInput/ColorGradientPropertyInputView.xaml
@@ -15,7 +15,8 @@
+ ColorGradient="{Binding ColorGradientInputValue}"
+ DialogHost="PropertyTreeDialogHost"/>
\ No newline at end of file
diff --git a/src/Plugins/Artemis.Plugins.Devices.DMX/Artemis.Plugins.Devices.DMX.csproj b/src/Plugins/Artemis.Plugins.Devices.DMX/Artemis.Plugins.Devices.DMX.csproj
index 1fa3b1b68..a8943908b 100644
--- a/src/Plugins/Artemis.Plugins.Devices.DMX/Artemis.Plugins.Devices.DMX.csproj
+++ b/src/Plugins/Artemis.Plugins.Devices.DMX/Artemis.Plugins.Devices.DMX.csproj
@@ -24,7 +24,7 @@
-
+
diff --git a/src/Plugins/Artemis.Plugins.Devices.WS281X/Artemis.Plugins.Devices.WS281X.csproj b/src/Plugins/Artemis.Plugins.Devices.WS281X/Artemis.Plugins.Devices.WS281X.csproj
index 41b49f390..c8d3b4d15 100644
--- a/src/Plugins/Artemis.Plugins.Devices.WS281X/Artemis.Plugins.Devices.WS281X.csproj
+++ b/src/Plugins/Artemis.Plugins.Devices.WS281X/Artemis.Plugins.Devices.WS281X.csproj
@@ -24,7 +24,7 @@
-
+
diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs
index 405b5acf6..5b7b2d46c 100644
--- a/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs
+++ b/src/Plugins/Artemis.Plugins.LayerBrushes.Color/ColorBrush.cs
@@ -28,9 +28,9 @@ namespace Artemis.Plugins.LayerBrushes.Color
private void UpdateColorProperties()
{
- Layer.Properties.RemoveLayerProperty(ColorProperty);
+ UnRegisterLayerProperty(ColorProperty);
ColorProperty = null;
- Layer.Properties.RemoveLayerProperty(GradientProperty);
+ UnRegisterLayerProperty(GradientProperty);
GradientProperty = null;
if (GradientTypeProperty.Value == GradientType.Solid)
diff --git a/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs b/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs
index 5f6e66c14..dccd0c453 100644
--- a/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs
+++ b/src/Plugins/Artemis.Plugins.LayerBrushes.Noise/NoiseBrush.cs
@@ -180,9 +180,11 @@ namespace Artemis.Plugins.LayerBrushes.Noise
private void CreateColorMap(object sender, EventArgs e)
{
- _colorMap = new SKColor[101];
+ var colorMap = new SKColor[101];
for (var i = 0; i < 101; i++)
- _colorMap[i] = GradientColorProperty.Value.GetColor(i / 100f);
+ colorMap[i] = GradientColorProperty.Value.GetColor(i / 100f);
+
+ _colorMap = colorMap;
}
}