Merged and somewhat rewrote KeyboardRectangle (http://i.imgur.com/mrnmMKR.png)

This commit is contained in:
SpoinkyNL committed 2016-01-29 21:38:02 +01:00
commit b2de20c593
18 files changed
+224 -210

No files matched your search

+1 -1
View File
@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
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
+17 -36
View File
@@ -2,41 +2,18 @@
<configuration>
<configSections>
<sectionGroup name="userSettings"
type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Artemis.Settings.Offsets"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.Witcher3.Witcher3"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.CounterStrike.CounterStrike"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.CounterStrike"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.VolumeDisplay"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.AudioVisualization"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.RocketLeague"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Properties.Settings"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.TypeWave"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.General"
type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Artemis.Settings.Offsets" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.Witcher3.Witcher3" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Effects.AudioVisualizer.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Modules.Games.CounterStrike.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.CounterStrike" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.VolumeDisplay" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.AudioVisualization" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.RocketLeague" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.TypeWave" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="Artemis.Settings.General" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<connectionStrings />
@@ -204,7 +181,7 @@
<value>TypeWave</value>
</setting>
<setting name="LastKeyboard" serializeAs="String">
<value>Razer BlackWidow Chroma</value>
<value>Corsair Gaming K95 RGB</value>
</setting>
<setting name="EnablePointersUpdate" serializeAs="String">
<value>True</value>
@@ -217,6 +194,10 @@
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.15.0" newVersion="1.2.15.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
+25 -21
View File
@@ -78,11 +78,15 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Caliburn.Micro, Version=2.0.2.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.Core.2.0.2\lib\net45\Caliburn.Micro.dll</HintPath>
<HintPath>..\packages\Caliburn.Micro.Core.3.0.0-beta2\lib\net45\Caliburn.Micro.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Caliburn.Micro.Platform, Version=2.0.2.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.2.0.2\lib\net45\Caliburn.Micro.Platform.dll</HintPath>
<HintPath>..\packages\Caliburn.Micro.3.0.0-beta2\lib\net45\Caliburn.Micro.Platform.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Caliburn.Micro.Platform.Core, Version=2.0.2.0, Culture=neutral, PublicKeyToken=8e5891231f2ed21f, processorArchitecture=MSIL">
<HintPath>..\packages\Caliburn.Micro.3.0.0-beta2\lib\net45\Caliburn.Micro.Platform.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Corale.Colore, Version=3.0.2.0, Culture=neutral, processorArchitecture=MSIL">
@@ -93,12 +97,12 @@
<HintPath>..\packages\CUE.NET.1.0.0\lib\net45\CUE.NET.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="log4net, Version=1.2.14.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.4\lib\net45-full\log4net.dll</HintPath>
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>..\packages\log4net.2.0.5\lib\net45-full\log4net.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MahApps.Metro, Version=1.1.2.0, Culture=neutral, PublicKeyToken=f4fb5a3c4d1e5b4f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.1.2.0\lib\net45\MahApps.Metro.dll</HintPath>
<Reference Include="MahApps.Metro, Version=1.3.0.17, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.3.0-ALPHA017\lib\net45\MahApps.Metro.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.QualityTools.Testing.Fakes, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
@@ -113,8 +117,8 @@
<HintPath>..\packages\NAudio.1.7.3\lib\net35\NAudio.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=7.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.7.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\packages\Newtonsoft.Json.8.0.2\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Open.WinKeyboardHook, Version=1.0.10.0, Culture=neutral, processorArchitecture=MSIL">
@@ -128,7 +132,7 @@
<Reference Include="System.Web" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.1.1.2.0\lib\net45\System.Windows.Interactivity.dll</HintPath>
<HintPath>..\packages\MahApps.Metro.1.3.0-ALPHA017\lib\net45\System.Windows.Interactivity.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System.Xml" />
@@ -147,28 +151,28 @@
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="Xceed.Wpf.AvalonDock, Version=2.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.5\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
<Reference Include="Xceed.Wpf.AvalonDock, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=2.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.5\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Aero, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.Aero.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=2.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.5\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.Metro, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.Metro.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=2.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.5\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
<Reference Include="Xceed.Wpf.AvalonDock.Themes.VS2010, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.AvalonDock.Themes.VS2010.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xceed.Wpf.DataGrid, Version=2.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.5\lib\net40\Xceed.Wpf.DataGrid.dll</HintPath>
<Reference Include="Xceed.Wpf.DataGrid, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.DataGrid.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Xceed.Wpf.Toolkit, Version=2.5.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.5\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
<Reference Include="Xceed.Wpf.Toolkit, Version=2.6.0.0, Culture=neutral, PublicKeyToken=3e4669d2f30244f4, processorArchitecture=MSIL">
<HintPath>..\packages\Extended.Wpf.Toolkit.2.6\lib\net40\Xceed.Wpf.Toolkit.dll</HintPath>
<Private>True</Private>
</Reference>
</ItemGroup>
@@ -1,7 +1,10 @@
using System.Drawing;
using CUE.NET;
using CUE.NET.Brushes;
using CUE.NET.Devices.Generic.Enums;
using CUE.NET.Devices.Keyboard;
using CUE.NET.Devices.Keyboard.Keys;
using CUE.NET.Exceptions;
namespace Artemis.KeyboardProviders.Corsair
{
@@ -14,27 +17,61 @@ namespace Artemis.KeyboardProviders.Corsair
Name = "Corsair Gaming K95 RGB";
}
/// <summary>
/// Enables the SDK and sets updatemode to manual as well as the color of the background to black.
/// </summary>
public override void Enable()
{
try
{
CueSDK.Initialize();
}
catch (WrapperException)
{
/*CUE is already initialized*/
}
_keyboard = CueSDK.KeyboardSDK;
Height = (int) _keyboard.KeyboardRectangle.Height;
Width = (int) _keyboard.KeyboardRectangle.Width;
_keyboard.UpdateMode = UpdateMode.Manual;
_keyboard.Brush = new SolidColorBrush(Color.Black);
_keyboard.Update();
}
public override void Disable()
{
}
/// <summary>
/// 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.
/// </summary>
/// <param name="bitmap"></param>
public override void DrawBitmap(Bitmap bitmap)
{
// TODO: Resize bitmap to keyboard's size
//if (bitmap.Width > width || bitmap.Height > height)
// bitmap = ResizeImage(bitmap, width, height);
// One way of doing this, not sure at all if it's any good
for (var y = 0; y < bitmap.Height - 1; y++)
for (var x = 0; x < bitmap.Width - 1; x++)
_keyboard[new PointF(x, y)].Led.Color = bitmap.GetPixel(x, y);
var ledRectangles = new RectangleF[bitmap.Width, bitmap.Height];
var 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*(_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);
}
}
@@ -16,12 +16,12 @@ namespace Artemis.KeyboardProviders
/// Returns a bitmap matching the keyboard's dimensions
/// </summary>
/// <returns></returns>
public Bitmap KeyboardBitmap() => new Bitmap(Height, Width);
public Bitmap KeyboardBitmap() => new Bitmap(Width, Height);
/// <summary>
/// Returns a bitmap matching the keyboard's dimensions using the provided scale
/// </summary>
/// <returns></returns>
public Bitmap KeyboardBitmap(int scale) => new Bitmap(Height*scale, Width*scale);
public Bitmap KeyboardBitmap(int scale) => new Bitmap(Width*scale, Height*scale);
}
}
@@ -10,13 +10,13 @@ namespace Artemis.KeyboardProviders.Razer
public BlackWidow()
{
Name = "Razer BlackWidow Chroma";
Height = (int) Constants.MaxRows;
Width = (int) Constants.MaxColumns;
}
public override void Enable()
{
Chroma.Instance.Initialize();
Height = (int)Constants.MaxRows;
Width = (int)Constants.MaxColumns;
}
public override void Disable()
@@ -4,7 +4,6 @@ using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using Artemis.Models;
using Artemis.Utilities;
using Artemis.Utilities.Audio;
using Artemis.Utilities.Keyboard;
using NAudio.CoreAudioApi;
@@ -17,7 +16,6 @@ namespace Artemis.Modules.Effects.AudioVisualizer
private const int FftLength = 2048;
private readonly SampleAggregator _sampleAggregator = new SampleAggregator(FftLength);
private bool _generating;
private bool _previousFromBottom;
private IWaveIn _waveIn;
public AudioVisualizerModel(MainModel mainModel, AudioVisualizerSettings settings) : base(mainModel)
@@ -26,19 +24,7 @@ namespace Artemis.Modules.Effects.AudioVisualizer
Name = "Audiovisualizer";
DeviceIds = new List<string>();
SpectrumData = new List<byte>();
SoundRectangles = new List<KeyboardRectangle>();
Scale = 4;
// Fill list with device IDs
// Would rather just store a MMDevice object, but seems NAudio won't let me.
var deviceEnum = new MMDeviceEnumerator();
var devices = deviceEnum.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active).ToList();
foreach (var mmDevice in devices)
{
DeviceIds.Add(mmDevice.ID);
}
SelectedDeviceId = DeviceIds.FirstOrDefault();
}
public int Lines { get; set; }
@@ -64,7 +50,29 @@ namespace Artemis.Modules.Effects.AudioVisualizer
public override void Enable()
{
Lines = MainModel.ActiveKeyboard.Width * Scale;
Lines = MainModel.ActiveKeyboard.Width;
// TODO: Device selection
SelectedDeviceId = new MMDeviceEnumerator()
.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active)
.FirstOrDefault()?.ID;
SoundRectangles = new List<KeyboardRectangle>();
for (var i = 0; i < Lines; i++)
{
SoundRectangles.Add(new KeyboardRectangle(
MainModel.ActiveKeyboard,
0, 0, new List<Color>
{
//ColorHelpers.MediaColorToDrawingColor(Settings.MainColor),
//ColorHelpers.MediaColorToDrawingColor(Settings.SecondaryColor)
Color.Red,
Color.Yellow,
Color.Green,
},
LinearGradientMode.Vertical) {ContainedBrush = false});
}
_sampleAggregator.FftCalculated += FftCalculated;
_sampleAggregator.PerformFFT = true;
@@ -79,72 +87,50 @@ namespace Artemis.Modules.Effects.AudioVisualizer
if (SelectedDeviceId == null)
return;
var deviceEnum = new MMDeviceEnumerator();
var devices = deviceEnum.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active).ToList();
var device = devices.FirstOrDefault(d => d.ID == SelectedDeviceId);
var device = new MMDeviceEnumerator()
.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active)
.FirstOrDefault(d => d.ID == SelectedDeviceId);
if (device == null)
if (device == null || SpectrumData == null)
return;
// Start filling the model
_generating = true;
if (SpectrumData == null)
{
_generating = false;
return;
}
// Clear the rectangle cache on Bars settings change
if (SoundRectangles.Count != Settings.Bars)
SoundRectangles.Clear();
if (Settings.FromBottom != _previousFromBottom)
SoundRectangles.Clear();
_previousFromBottom = Settings.FromBottom;
// Parse spectrum data
for (var i = 0; i < Settings.Bars; i++)
for (var i = 0; i < Lines; i++)
{
int height;
if (SpectrumData.Count - 1 < i || SpectrumData[i] == 0)
height = 0;
else
height = (int) (Math.Round(SpectrumData[i]/2.55));
if (SoundRectangles.Count <= i)
SoundRectangles.Add(new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>
{
ColorHelpers.MediaColorToDrawingColor(Settings.MainColor),
ColorHelpers.MediaColorToDrawingColor(Settings.SecondaryColor)
}, LinearGradientMode.Vertical));
height = (int) Math.Round(SpectrumData[i]/2.55);
// Apply Sensitivity setting
height = height*Settings.Sensitivity;
if (height > SoundRectangles[i].Height)
SoundRectangles[i].Height = height;
var keyboardHeight = (int) Math.Round(((MainModel.ActiveKeyboard.Height/100.00)*height)*Scale);
if (keyboardHeight > SoundRectangles[i].Height)
SoundRectangles[i].Height = keyboardHeight;
else
SoundRectangles[i].Height = SoundRectangles[i].Height - Settings.FadeSpeed;
// Apply Bars setting
SoundRectangles[i].X = (int) Math.Ceiling((double) Lines/Settings.Bars)*i;
SoundRectangles[i].Width = (int) Math.Ceiling((double) Lines/Settings.Bars);
SoundRectangles[i].X = i*Scale;
SoundRectangles[i].Width = Scale;
if (Settings.FromBottom)
SoundRectangles[i].Y = (Scale*MainModel.ActiveKeyboard.Height) - SoundRectangles[i].Height;
SoundRectangles[i].Y = (MainModel.ActiveKeyboard.Height*Scale) - SoundRectangles[i].Height;
}
_generating = false;
}
public override Bitmap GenerateBitmap()
{
if (SpectrumData == null)
return null;
// Lock the _spectrumData array while busy with it
_generating = true;
if (SpectrumData == null)
{
_generating = false;
return null;
}
var bitmap = MainModel.ActiveKeyboard.KeyboardBitmap(Scale);
using (var g = Graphics.FromImage(bitmap))
{
@@ -69,22 +69,6 @@
SmallChange="1"
IsSnapToTickEnabled="True" />
</StackPanel>
<!-- Bars slider -->
<StackPanel Grid.Row="2"
Grid.Column="1"
HorizontalAlignment="Left">
<Label FontSize="16" Content="Bars" Style="{DynamicResource DescriptionHeaderStyle}"
Foreground="#535353" FontFamily="Segoe UI Semibold" />
<Slider x:Name="Bars"
VerticalAlignment="top"
HorizontalAlignment="Left"
Width="132"
TickPlacement="BottomRight"
TickFrequency="7"
Value="{Binding Path=AudioVisualizerSettings.Bars, Mode=TwoWay}" Minimum="7" Maximum="21"
SmallChange="7"
IsSnapToTickEnabled="True" />
</StackPanel>
<StackPanel Grid.Row="3"
Grid.Column="0"
HorizontalAlignment="Left">
@@ -27,7 +27,7 @@ namespace Artemis.Modules.Effects.Debug
public override void Enable()
{
KeyboardRectangle = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>
KeyboardRectangle = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color>
{
Color.Red,
Color.OrangeRed,
@@ -43,7 +43,7 @@ namespace Artemis.Modules.Effects.Debug
{
KeyboardRectangle.Height = Settings.Height;
KeyboardRectangle.Width = Settings.Width;
//KeyboardRectangle.GradientMode = Settings.Type;
KeyboardRectangle.GradientMode = Settings.Type;
KeyboardRectangle.Rotate = Settings.Rotate;
}
@@ -42,9 +42,9 @@ namespace Artemis.Modules.Games.CounterStrike
public override void Enable()
{
// TODO: Size stuff
AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>(), LinearGradientMode.Horizontal);
TeamRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 1 * Scale, new List<Color>(), LinearGradientMode.Horizontal);
EventRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 1 * Scale, new List<Color>(), LinearGradientMode.Horizontal);
AmmoRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color>(), LinearGradientMode.Horizontal);
TeamRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 1 * Scale, new List<Color>(), LinearGradientMode.Horizontal);
EventRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 1 * Scale, new List<Color>(), LinearGradientMode.Horizontal);
MainModel.GameStateWebServer.GameDataReceived += HandleGameData;
}
@@ -43,7 +43,7 @@ namespace Artemis.Modules.Games.RocketLeague
public override void Enable()
{
_boostRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>
_boostRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color>
{
ColorHelpers.MediaColorToDrawingColor(_settings.MainColor),
ColorHelpers.MediaColorToDrawingColor(_settings.SecondaryColor)
@@ -38,7 +38,7 @@ namespace Artemis.Modules.Games.Witcher3
public override void Enable()
{
_signRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0, new List<Color>(), LinearGradientMode.Horizontal)
_signRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color>(), LinearGradientMode.Horizontal)
{
Rotate = true,
LoopSpeed = 0.5
@@ -31,12 +31,12 @@ namespace Artemis.Modules.Overlays.VolumeDisplay
public void Draw(Graphics g)
{
var volumeRect = new KeyboardRectangle(MainModel.ActiveKeyboard, Scale, 0, 0,
new List<Color>
var volumeRect = new KeyboardRectangle(MainModel.ActiveKeyboard, 0, 0, new List<Color>
{
ColorHelpers.MediaColorToDrawingColor(Settings.MainColor),
ColorHelpers.MediaColorToDrawingColor(Settings.SecondaryColor)
}, LinearGradientMode.Horizontal);
},
LinearGradientMode.Horizontal);
volumeRect.Draw(g);
}
}
+1 -1
View File
@@ -37,7 +37,7 @@ namespace Artemis.Settings {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("Razer BlackWidow Chroma")]
[global::System.Configuration.DefaultSettingValueAttribute("Corsair Gaming K95 RGB")]
public string LastKeyboard {
get {
return ((string)(this["LastKeyboard"]));
+2 -4
View File
@@ -1,14 +1,12 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="General">
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="General">
<Profiles />
<Settings>
<Setting Name="LastEffect" Type="System.String" Scope="User">
<Value Profile="(Default)">TypeWave</Value>
</Setting>
<Setting Name="LastKeyboard" Type="System.String" Scope="User">
<Value Profile="(Default)">Razer BlackWidow Chroma</Value>
<Value Profile="(Default)">Corsair Gaming K95 RGB</Value>
</Setting>
<Setting Name="EnablePointersUpdate" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
@@ -14,7 +14,6 @@ namespace Artemis.Utilities.Keyboard
private readonly BackgroundWorker _blinkWorker = new BackgroundWorker {WorkerSupportsCancellation = true};
private readonly KeyboardProvider _keyboard;
private int _blinkDelay;
private List<Color> _colors;
private double _rotationProgress;
/// <summary>
@@ -22,57 +21,68 @@ namespace Artemis.Utilities.Keyboard
/// By default, a rectangle is the entire keyboard's size.
/// </summary>
/// <param name="keyboard">The keyboard this rectangle will be used for</param>
/// <param name="scale">The scale on which the rect should be rendered (Higher means smoother rotation)</param>
/// <param name="x"></param>
/// <param name="y"></param>
/// <param name="colors">An array of colors the ColorBlend will use</param>
/// <param name="gradientMode"></param>
public KeyboardRectangle(KeyboardProvider keyboard, int scale, int x, int y, List<Color> colors,
public KeyboardRectangle(KeyboardProvider keyboard, int x, int y, List<Color> colors,
LinearGradientMode gradientMode)
{
_keyboard = keyboard;
Scale = scale;
X = x;
Y = y;
Width = keyboard.Width*Scale;
Height = keyboard.Height*Scale;
Colors = colors;
GradientMode = gradientMode;
Opacity = 255;
Rotate = false;
LoopSpeed = 1;
Visible = true;
ContainedBrush = false;
_rotationProgress = 0;
_blinkWorker.DoWork += BlinkWorker_DoWork;
X = x;
Y = y;
Width = keyboard.Width;
Height = keyboard.Height;
Visible = true;
Opacity = 255;
ContainedBrush = true;
Scale = 4;
GradientMode = gradientMode;
Rotate = false;
LoopSpeed = 1;
Colors = colors;
}
public bool ContainedBrush { get; set; }
public int Scale { get; set; }
public byte Opacity { get; set; }
public int X { get; set; }
public int Y { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public LinearGradientMode GradientMode { get; set; }
public bool Rotate { get; set; }
public double LoopSpeed { get; set; }
public bool Visible { get; set; }
public byte Opacity { get; set; } // TODO: Remove
public List<Color> Colors
{
get { return _colors; }
set
{
_colors = value;
/// <summary>
/// Sets wether or not the colors should be contained within the rectangle, or span the entire keyboard.
/// </summary>
public bool ContainedBrush { get; set; }
// Make the list tilable so that we can loop it
_colors.AddRange(value);
_colors.Add(value.FirstOrDefault());
}
}
/// <summary>
/// Used when ContainedBrush is set to false to make sure the colors span the entire keyboard on a higher scale.
/// </summary>
public int Scale { get; set; }
/// <summary>
/// Determines what grientmode to use in the LinearGradientBrush.
/// </summary>
public LinearGradientMode GradientMode { get; set; }
/// <summary>
/// Wether or not to rotate the colors over the brush.
/// </summary>
public bool Rotate { get; set; }
/// <summary>
/// What speed to ratate the colors on.
/// </summary>
public double LoopSpeed { get; set; }
/// <summary>
/// Colors used on the brush.
/// </summary>
public List<Color> Colors { get; set; }
public void StartBlink(int delay)
{
@@ -130,24 +140,28 @@ namespace Artemis.Utilities.Keyboard
private LinearGradientBrush CreateBrush()
{
var colorBlend = CreateColorBlend();
var rect = ContainedBrush
? new Rectangle((int) _rotationProgress, Y, Width, Height)
: new Rectangle((int) _rotationProgress, 0, _keyboard.Width*Scale, _keyboard.Height*Scale);
RectangleF rect;
if (Rotate)
rect = ContainedBrush
? new Rectangle((int) _rotationProgress, Y, Width*2, Height*2)
: new Rectangle((int) _rotationProgress, 0, (_keyboard.Width*Scale)*2, (_keyboard.Height*Scale)*2);
else
rect = ContainedBrush
? new Rectangle(X, Y, Width, Height)
: new Rectangle(0, 0, (_keyboard.Width*Scale), (_keyboard.Height*Scale));
if (Colors.Count > 5)
return new LinearGradientBrush(rect, Colors[0], Colors[1], GradientMode)
{
InterpolationColors = colorBlend
};
return Colors.Count > 1
? new LinearGradientBrush(rect, Colors[0], Colors[1], GradientMode)
: new LinearGradientBrush(rect, Colors[0], Colors[0], GradientMode);
return new LinearGradientBrush(rect, Color.Transparent, Color.Transparent, GradientMode)
{
InterpolationColors = colorBlend
};
}
private ColorBlend CreateColorBlend()
{
var colorBlend = new ColorBlend {Colors = Colors.ToArray()};
var colorBlend = Rotate
? new ColorBlend {Colors = CreateTilebleColors(Colors).ToArray()}
: new ColorBlend {Colors = Colors.ToArray()};
// If needed, apply opacity to the colors in the blend
if (Opacity < 255)
@@ -155,9 +169,9 @@ namespace Artemis.Utilities.Keyboard
colorBlend.Colors[i] = Color.FromArgb(Opacity, colorBlend.Colors[i]);
// Devide the colors over the colorblend
var devider = (float) Colors.Count - 1;
var devider = (float) colorBlend.Colors.Length - 1;
var positions = new List<float>();
for (var i = 0; i < Colors.Count; i++)
for (var i = 0; i < colorBlend.Colors.Length; i++)
positions.Add(i/devider);
// Apply the devided positions
@@ -165,5 +179,16 @@ namespace Artemis.Utilities.Keyboard
return colorBlend;
}
private List<Color> CreateTilebleColors(List<Color> sourceColors)
{
// Create a list using the original colors
var tilebleColors = new List<Color>(sourceColors);
// Add the original colors again
tilebleColors.AddRange(sourceColors);
// Add the first color, smoothing the transition
tilebleColors.Add(sourceColors.FirstOrDefault());
return tilebleColors;
}
}
}
+6 -7
View File
@@ -1,16 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Caliburn.Micro" version="2.0.2" targetFramework="net452" />
<package id="Caliburn.Micro.Core" version="2.0.2" targetFramework="net452" />
<package id="Caliburn.Micro" version="3.0.0-beta2" targetFramework="net452" />
<package id="Caliburn.Micro.Core" version="3.0.0-beta2" targetFramework="net452" />
<package id="Colore" version="3.0.2" targetFramework="net452" />
<package id="CUE.NET" version="1.0.0" targetFramework="net452" />
<package id="Extended.Wpf.Toolkit" version="2.5" targetFramework="net452" />
<package id="log4net" version="2.0.4" targetFramework="net452" />
<package id="MahApps.Metro" version="1.1.2.0" targetFramework="net452" />
<package id="Extended.Wpf.Toolkit" version="2.6" targetFramework="net452" />
<package id="log4net" version="2.0.5" targetFramework="net452" />
<package id="MahApps.Metro" version="1.3.0-ALPHA017" targetFramework="net452" />
<package id="MahApps.Metro.Resources" version="0.4.0.0" targetFramework="net452" />
<package id="NAudio" version="1.7.3" targetFramework="net452" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net452" />
<package id="Newtonsoft.Json" version="8.0.2" targetFramework="net452" />
<package id="Open.WinKeyboardHook" version="1.0.10.0" targetFramework="net452" />
<package id="WpfExceptionViewer" version="1.0.0.0" targetFramework="net452" />
</packages>