From 8b09e180c65188dd8758850e516af6f4590fad12 Mon Sep 17 00:00:00 2001 From: SpoinkyNL Date: Wed, 6 Jul 2016 20:57:01 +0200 Subject: [PATCH] Mouse animation fixes --- .../Artemis/DeviceProviders/Corsair/CorsairHeadsets.cs | 10 +++++----- Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs | 10 +++++----- Artemis/Artemis/Models/EffectModel.cs | 4 ++++ .../Effects/WindowsProfile/WindowsProfileDataModel.cs | 3 ++- .../Profiles/Layers/MousePropertiesViewModel.cs | 2 +- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Artemis/Artemis/DeviceProviders/Corsair/CorsairHeadsets.cs b/Artemis/Artemis/DeviceProviders/Corsair/CorsairHeadsets.cs index db45cd5ab..45152ab2c 100644 --- a/Artemis/Artemis/DeviceProviders/Corsair/CorsairHeadsets.cs +++ b/Artemis/Artemis/DeviceProviders/Corsair/CorsairHeadsets.cs @@ -49,11 +49,11 @@ namespace Artemis.DeviceProviders.Corsair // Color each LED according to one of the pixels foreach (var corsairLed in CueSDK.HeadsetSDK.Leds) { - if (ledIndex == 0) - corsairLed.Color = bitmap.GetPixel(0, 0); - else - corsairLed.Color = bitmap.GetPixel((int) ((ledIndex + 1)*step - 1), - (int) ((ledIndex + 1)*step - 1)); + var col = ledIndex == 0 + ? bitmap.GetPixel(0, 0) + : bitmap.GetPixel((int)((ledIndex + 1) * step - 1), (int)((ledIndex + 1) * step - 1)); + + corsairLed.Color = col; ledIndex++; } } diff --git a/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs b/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs index 4fc70ce84..8d3d1efc8 100644 --- a/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs +++ b/Artemis/Artemis/DeviceProviders/Corsair/CorsairMice.cs @@ -49,11 +49,11 @@ namespace Artemis.DeviceProviders.Corsair // Color each LED according to one of the pixels foreach (var corsairLed in CueSDK.MouseSDK.Leds) { - if (ledIndex == 0) - corsairLed.Color = bitmap.GetPixel(0, 0); - else - corsairLed.Color = bitmap.GetPixel((int) ((ledIndex + 1)*step - 1), - (int) ((ledIndex + 1)*step - 1)); + var col = ledIndex == 0 + ? bitmap.GetPixel(0, 0) + : bitmap.GetPixel((int) ((ledIndex + 1)*step - 1), (int) ((ledIndex + 1)*step - 1)); + + corsairLed.Color = col; ledIndex++; } } diff --git a/Artemis/Artemis/Models/EffectModel.cs b/Artemis/Artemis/Models/EffectModel.cs index 67423ef6d..18712d07f 100644 --- a/Artemis/Artemis/Models/EffectModel.cs +++ b/Artemis/Artemis/Models/EffectModel.cs @@ -69,6 +69,8 @@ namespace Artemis.Models mouse = new Bitmap(40, 40); using (var g = Graphics.FromImage(mouse)) { + // Not all SDK's handle transparency + g.Clear(Color.Black); Profile.DrawLayers(g, renderLayers.Where(rl => rl.LayerType is MouseType), DataModel, smallRect, false, true); } @@ -77,6 +79,8 @@ namespace Artemis.Models headset = new Bitmap(40, 40); using (var g = Graphics.FromImage(headset)) { + // Not all SDK's handle transparency + g.Clear(Color.Black); Profile.DrawLayers(g, renderLayers.Where(rl => rl.LayerType is HeadsetType), DataModel, smallRect, false, true); } diff --git a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileDataModel.cs b/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileDataModel.cs index ca28bc496..1e12eeddf 100644 --- a/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileDataModel.cs +++ b/Artemis/Artemis/Modules/Effects/WindowsProfile/WindowsProfileDataModel.cs @@ -9,6 +9,7 @@ namespace Artemis.Modules.Effects.WindowsProfile Spotify = new Spotify(); Cpu = new CpuDataModel(); Performance = new PerformanceDataModel(); + CurrentTime = new CurrentTime(); } public CpuDataModel Cpu { get; set; } @@ -17,7 +18,7 @@ namespace Artemis.Modules.Effects.WindowsProfile public CurrentTime CurrentTime { get; set; } } - class CurrentTime + public class CurrentTime { public int Hours24 { get; set; } public int Hours12 { get; set; } diff --git a/Artemis/Artemis/ViewModels/Profiles/Layers/MousePropertiesViewModel.cs b/Artemis/Artemis/ViewModels/Profiles/Layers/MousePropertiesViewModel.cs index 0bfbc0eaa..32ec88cce 100644 --- a/Artemis/Artemis/ViewModels/Profiles/Layers/MousePropertiesViewModel.cs +++ b/Artemis/Artemis/ViewModels/Profiles/Layers/MousePropertiesViewModel.cs @@ -20,7 +20,7 @@ namespace Artemis.ViewModels.Profiles.Layers new BindableCollection(GeneralHelpers.GenerateTypeMap(dataModel)), layerModel.Properties); - SelectedLayerAnimation = LayerAnimations.FirstOrDefault(l => l.Name == layerModel.LayerAnimation.Name) ?? + SelectedLayerAnimation = LayerAnimations.FirstOrDefault(l => l.Name == layerModel.LayerAnimation?.Name) ?? LayerAnimations.First(l => l.Name == "None"); }