diff --git a/src/Artemis.Core/Artemis.Core.csproj b/src/Artemis.Core/Artemis.Core.csproj
index d79a29fb2..2d01db23d 100644
--- a/src/Artemis.Core/Artemis.Core.csproj
+++ b/src/Artemis.Core/Artemis.Core.csproj
@@ -218,16 +218,13 @@
-
-
-
+
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
+
-
\ No newline at end of file
diff --git a/src/Artemis.Core/Models/Surface/Device.cs b/src/Artemis.Core/Models/Surface/Device.cs
index d0172c279..be1dae749 100644
--- a/src/Artemis.Core/Models/Surface/Device.cs
+++ b/src/Artemis.Core/Models/Surface/Device.cs
@@ -1,7 +1,5 @@
using System;
using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Diagnostics;
using System.Drawing.Drawing2D;
using System.Linq;
using Artemis.Core.Extensions;
@@ -24,6 +22,7 @@ namespace Artemis.Core.Models.Surface
Leds = rgbDevice.Select(l => new DeviceLed(l, this)).ToList().AsReadOnly();
Rotation = 0;
+ Scale = 1;
ZIndex = 1;
ApplyToEntity();
@@ -42,10 +41,10 @@ namespace Artemis.Core.Models.Surface
public Rectangle RenderRectangle { get; private set; }
public GraphicsPath RenderPath { get; private set; }
- public IRGBDevice RgbDevice { get; private set; }
+ public IRGBDevice RgbDevice { get; }
public Plugin Plugin { get; }
- public Surface Surface { get; private set; }
- public DeviceEntity DeviceEntity { get; private set; }
+ public Surface Surface { get; }
+ public DeviceEntity DeviceEntity { get; }
public ReadOnlyCollection Leds { get; set; }
public double X
@@ -77,7 +76,7 @@ namespace Artemis.Core.Models.Surface
get => DeviceEntity.ZIndex;
set => DeviceEntity.ZIndex = value;
}
-
+
internal void ApplyToEntity()
{
// Other properties are computed
@@ -99,8 +98,8 @@ namespace Artemis.Core.Models.Surface
RenderRectangle = new Rectangle(
(int) Math.Round(RgbDevice.Location.X * Surface.Scale, MidpointRounding.AwayFromZero),
(int) Math.Round(RgbDevice.Location.Y * Surface.Scale, MidpointRounding.AwayFromZero),
- (int) Math.Round(RgbDevice.Size.Width * Surface.Scale, MidpointRounding.AwayFromZero),
- (int) Math.Round(RgbDevice.Size.Height * Surface.Scale, MidpointRounding.AwayFromZero)
+ (int) Math.Round(RgbDevice.DeviceRectangle.Size.Width * Surface.Scale, MidpointRounding.AwayFromZero),
+ (int) Math.Round(RgbDevice.DeviceRectangle.Size.Height * Surface.Scale, MidpointRounding.AwayFromZero)
);
if (!Leds.Any())
@@ -114,13 +113,14 @@ namespace Artemis.Core.Models.Surface
path.FillMode = FillMode.Winding;
RenderPath = path;
}
-
+
public override string ToString()
{
return $"[{RgbDevice.DeviceInfo.DeviceType}] {RgbDevice.DeviceInfo.DeviceName} - {X}.{Y}.{ZIndex}";
}
public event EventHandler DeviceUpdated;
+
protected virtual void OnDeviceUpdated()
{
DeviceUpdated?.Invoke(this, EventArgs.Empty);
diff --git a/src/Artemis.Plugins.Modules.General/GeneralModule.cs b/src/Artemis.Plugins.Modules.General/GeneralModule.cs
index 6651745d7..7f69ac188 100644
--- a/src/Artemis.Plugins.Modules.General/GeneralModule.cs
+++ b/src/Artemis.Plugins.Modules.General/GeneralModule.cs
@@ -6,6 +6,7 @@ using System.Linq;
using Artemis.Core.Models.Surface;
using Artemis.Core.Plugins.Abstract;
using Artemis.Core.Plugins.Models;
+using Artemis.Core.Services.Storage.Interfaces;
using Artemis.Plugins.Modules.General.ViewModels;
using Device = Artemis.Core.Models.Surface.Device;
@@ -16,7 +17,7 @@ namespace Artemis.Plugins.Modules.General
private readonly ColorBlend _rainbowColorBlend;
private readonly PluginSettings _settings;
- public GeneralModule(PluginInfo pluginInfo, PluginSettings settings) : base(pluginInfo)
+ public GeneralModule(PluginInfo pluginInfo, PluginSettings settings, ISurfaceService surfaceService) : base(pluginInfo)
{
_settings = settings;
DisplayName = "General";
@@ -38,6 +39,8 @@ namespace Artemis.Plugins.Modules.General
else
_rainbowColorBlend.Colors[i] = ColorHelpers.ColorFromHSV(0, 1, 1);
}
+
+ surfaceService.SurfaceConfigurationUpdated += (sender, args) => DeviceBrushes.Clear();
}
public int[] Hues { get; set; }
diff --git a/src/Artemis.UI/Artemis.UI.csproj b/src/Artemis.UI/Artemis.UI.csproj
index e2139fef1..5a9c8562e 100644
--- a/src/Artemis.UI/Artemis.UI.csproj
+++ b/src/Artemis.UI/Artemis.UI.csproj
@@ -150,6 +150,7 @@
+
@@ -375,12 +376,12 @@
+
This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.
-
+
-
\ No newline at end of file
diff --git a/src/Artemis.UI/Extensions/RgbRectangleExtensions.cs b/src/Artemis.UI/Extensions/RgbRectangleExtensions.cs
new file mode 100644
index 000000000..a85cefb63
--- /dev/null
+++ b/src/Artemis.UI/Extensions/RgbRectangleExtensions.cs
@@ -0,0 +1,18 @@
+using System.Windows;
+using RGB.NET.Core;
+
+namespace Artemis.UI.Extensions
+{
+ public static class RgbRectangleExtensions
+ {
+ public static Rect ToWindowsRect(this Rectangle rectangle, double scale)
+ {
+ return new Rect(
+ (int) (rectangle.Location.X * scale),
+ (int) (rectangle.Location.Y * scale),
+ (int) (rectangle.Size.Width * scale),
+ (int) (rectangle.Size.Height * scale)
+ );
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs
index 8ec78d52c..64f54d755 100644
--- a/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs
+++ b/src/Artemis.UI/Screens/Module/ProfileEditor/ProfileEditorViewModel.cs
@@ -20,7 +20,6 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
{
private readonly IProfileService _profileService;
private readonly IDialogService _dialogService;
- private Profile _selectedProfile;
public ProfileEditorViewModel(ProfileModule module, ICollection viewModels, IProfileService profileService, IDialogService dialogService)
{
@@ -39,7 +38,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
Items.AddRange(viewModels);
- module.ActiveProfileChanged += ModuleOnActiveProfileChanged;
+ module.ActiveProfileChanged += ModuleOnActiveProfileChanged;
}
public ProfileModule Module { get; }
@@ -50,28 +49,24 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
public ProfileViewModel ProfileViewModel { get; }
public BindableCollection Profiles { get; set; }
-
public Profile SelectedProfile
{
- get => _selectedProfile;
- set
- {
- if (_selectedProfile == value)
- return;
-
- var old = _selectedProfile;
- _selectedProfile = value;
- ChangeActiveProfile(old);
- }
+ get => Module.ActiveProfile;
+ set => ChangeSelectedProfile(value);
}
- private void ChangeActiveProfile(Profile oldProfile)
+ private void ChangeSelectedProfile(Profile profile)
{
- Module.ChangeActiveProfile(_selectedProfile);
- if (_selectedProfile != null)
- _profileService.UpdateProfile(_selectedProfile, false);
+ if (profile == Module.ActiveProfile)
+ return;
+
+ var oldProfile = Module.ActiveProfile;
+ Module.ChangeActiveProfile(profile);
+
if (oldProfile != null)
_profileService.UpdateProfile(oldProfile, false);
+ if (profile != null)
+ _profileService.UpdateProfile(profile, false);
}
public bool CanDeleteActiveProfile => SelectedProfile != null && Profiles.Count > 1;
@@ -107,7 +102,7 @@ namespace Artemis.UI.Screens.Module.ProfileEditor
var newActiveProfile = index - 1 > -1 ? Profiles[index - 1] : Profiles[index + 1];
// Activate the new active profile
- Module.ChangeActiveProfile(newActiveProfile);
+ SelectedProfile = newActiveProfile;
// Remove the old one
Profiles.Remove(profile);
diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileDeviceView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileDeviceView.xaml
index 74fabaf5a..af09e06c0 100644
--- a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileDeviceView.xaml
+++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileDeviceView.xaml
@@ -13,16 +13,21 @@
-
+
+
+
+
+
+
-
+
+ Visibility="{Binding Device.RgbDevice.DeviceInfo.Image, ConverterParameter=Inverted, Converter={StaticResource NullToVisibilityConverter}}" />
-
+
diff --git a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedView.xaml b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedView.xaml
index 668515d7c..33dc4a283 100644
--- a/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedView.xaml
+++ b/src/Artemis.UI/Screens/Module/ProfileEditor/Visualization/ProfileLedView.xaml
@@ -12,7 +12,7 @@
-