From ec5c4d82e8c89a6e3a89464f1a89f23815c43a23 Mon Sep 17 00:00:00 2001 From: Logan Saso Date: Fri, 22 Jan 2016 06:56:13 -0800 Subject: [PATCH] Changed keyboard height and width to adjust dynamically --- Artemis/Artemis.sln | 44 +++++------ .../Artemis/KeyboardProviders/Corsair/K95.cs | 74 +++++++++---------- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/Artemis/Artemis.sln b/Artemis/Artemis.sln index 9566a2c74..b2742026e 100644 --- a/Artemis/Artemis.sln +++ b/Artemis/Artemis.sln @@ -1,22 +1,22 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 14 -VisualStudioVersion = 14.0.23107.0 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.Build.0 = Debug|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.ActiveCfg = Release|Any CPU - {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +VisualStudioVersion = 14.0.24720.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Artemis", "Artemis\Artemis.csproj", "{ED9997A2-E54C-4E9F-9350-62BE672C3ABE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {ED9997A2-E54C-4E9F-9350-62BE672C3ABE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/Artemis/Artemis/KeyboardProviders/Corsair/K95.cs b/Artemis/Artemis/KeyboardProviders/Corsair/K95.cs index dbf204822..e8af77206 100644 --- a/Artemis/Artemis/KeyboardProviders/Corsair/K95.cs +++ b/Artemis/Artemis/KeyboardProviders/Corsair/K95.cs @@ -1,60 +1,60 @@ -using System.Drawing; -using CUE.NET; -using CUE.NET.Devices.Generic.Enums; -using CUE.NET.Devices.Keyboard; +using System.Drawing; +using CUE.NET; +using CUE.NET.Devices.Generic.Enums; +using CUE.NET.Devices.Keyboard; using CUE.NET.Brushes; using CUE.NET.Devices.Keyboard.Keys; -namespace Artemis.KeyboardProviders.Corsair -{ - internal class K95 : KeyboardProvider - { - private CorsairKeyboard _keyboard; - - public K95() - { - Name = "Corsair Gaming K95 RGB"; - } - +namespace Artemis.KeyboardProviders.Corsair +{ + internal class K95 : KeyboardProvider + { + private CorsairKeyboard _keyboard; + + public K95() + { + Name = "Corsair Gaming K95 RGB"; + } + /// /// Enables the SDK and sets updatemode to manual as well as the color of the background to black. /// - public override void Enable() - { + public override void Enable() + { try { CueSDK.Initialize(); } catch (CUE.NET.Exceptions.WrapperException){/*CUE is already initialized*/} - _keyboard = CueSDK.KeyboardSDK; - _keyboard.UpdateMode = UpdateMode.Manual; - _keyboard.Brush = new SolidColorBrush(Color.Black); - _keyboard.Update(); - } - - public override void Disable() - { - } - + _keyboard = CueSDK.KeyboardSDK; + _keyboard.UpdateMode = UpdateMode.Manual; + _keyboard.Brush = new SolidColorBrush(Color.Black); + _keyboard.Update(); + } + + public override void Disable() + { + } + /// /// Properly resizes any size bitmap to the keyboard by creating a rectangle whose size is dependent on the bitmap size. /// Does not reset the color each time. Uncomment line 48 for collor reset. /// /// - public override void DrawBitmap(Bitmap bitmap) - { - RectangleF[,] ledRectangles = new RectangleF[bitmap.Width, bitmap.Height]; - RectangleKeyGroup[,] ledGroups = new RectangleKeyGroup[bitmap.Width, bitmap.Height]; - //_keyboard.Brush = new SolidColorBrush(Color.Black); + public override void DrawBitmap(Bitmap bitmap) + { + RectangleF[,] ledRectangles = new RectangleF[bitmap.Width, bitmap.Height]; + RectangleKeyGroup[,] ledGroups = new RectangleKeyGroup[bitmap.Width, bitmap.Height]; + //_keyboard.Brush = new SolidColorBrush(Color.Black); for (var x = 0 ; x < bitmap.Width; x++) { for (var y = 0; y < bitmap.Height; y++) { - ledRectangles[x, y] = new RectangleF(_keyboard.KeyboardRectangle.X * (x*(485F / bitmap.Width / _keyboard.KeyboardRectangle.X)), _keyboard.KeyboardRectangle.Y*(y*(133F / bitmap.Height / _keyboard.KeyboardRectangle.Y)), 485F / bitmap.Width, 133F / bitmap.Height); + ledRectangles[x, y] = new RectangleF(_keyboard.KeyboardRectangle.X * (x*(_keyboard.KeyboardRectangle.Width / bitmap.Width / _keyboard.KeyboardRectangle.X)), _keyboard.KeyboardRectangle.Y*(y*(_keyboard.KeyboardRectangle.Height / bitmap.Height / _keyboard.KeyboardRectangle.Y)), _keyboard.KeyboardRectangle.Width / bitmap.Width, _keyboard.KeyboardRectangle.Height / bitmap.Height); ledGroups[x, y] = new RectangleKeyGroup(_keyboard, ledRectangles[x, y], 0.1f) { Brush = new SolidColorBrush(bitmap.GetPixel(x, y)) }; } - } - _keyboard.Update(true); - } - } + } + _keyboard.Update(true); + } + } } \ No newline at end of file