Skip to content

Commit

Permalink
implement keysaver colouring
Browse files Browse the repository at this point in the history
  • Loading branch information
jwrpalmer99 committed Jun 1, 2015
1 parent 861121a commit cb9c867
Show file tree
Hide file tree
Showing 23 changed files with 191 additions and 66 deletions.
Binary file modified WhoIsSpeaking/WhoIsSpeaking.v12.suo
Binary file not shown.
2 changes: 1 addition & 1 deletion WhoIsSpeaking/WhoIsSpeaking/Form1.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Form1()
if (myPrincipal.IsInRole(WindowsBuiltInRole .Administrator) == false )
{
//show messagebox - displaying a messange to the user that rights are missing
MessageBox .Show("You need to run the application using the 'run as administrator' option" , "administrator right required" , MessageBoxButtons .OK, MessageBoxIcon .Exclamation);
//MessageBox .Show("You need to run the application using the 'run as administrator' option" , "administrator right required" , MessageBoxButtons .OK, MessageBoxIcon .Exclamation);
}

//read settings
Expand Down
118 changes: 115 additions & 3 deletions WhoIsSpeaking/WhoIsSpeaking/KeyboardHook.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,18 +72,130 @@ void timerKeySaver_Tick(object sender, EventArgs e)
timerKeySaver.Stop();
}

public struct keysavePoint
{
public Point point;
public int counter;
}
void bw_Keysave_DoWork(object sender, DoWorkEventArgs e)
{
LogitechGSDK.LogiLedSetLighting(0, 0, 0);
DateTime inittime = DateTime.Now;
int counter = 0;
List<keysavePoint> points = new List<keysavePoint> { };
Random rnd = new Random();
while (true)
{
if (bw_Keysave.CancellationPending) return;
TimeSpan elapsed = DateTime.Now - inittime;
if (elapsed.TotalMilliseconds > 500)
if (elapsed.TotalMilliseconds > 500) //change this namber to change speed new stars appear
{
Console.Write(".");
//for (int c = 0; c < 2; c++)
//{
int newx = rnd.Next(0,20);
int newy = rnd.Next(0, 5);
keysavePoint kp = new keysavePoint();
kp.point = new Point(newx, newy);
kp.counter = 0;
points.Add(kp);
//}
//Console.Write(".");
inittime = DateTime.Now;
}
if (counter > 4) //change this number to change speed stars change
{
counter = 0;

System.Drawing.Color c1 = Form1.m_startColour;
System.Drawing.Color c2 = Form1.m_endColour;

int fadespeed = Form1.m_fadespeed;
int gradientspeed = Form1.m_gradientspeed;

ColorManagment.ColorConverter Converter = new ColorManagment.ColorConverter(); //create a new instance of a ColorConverter
ColorRGB rgb1 = new ColorRGB(RGBSpaceName.sRGB, c1.R, c1.G, c1.B); //create an RGB color
ColorLab lab1 = Converter.ToLab(rgb1);
ColorRGB rgb2 = new ColorRGB(RGBSpaceName.sRGB, c2.R, c2.G, c2.B); //create an RGB color
ColorLab lab2 = Converter.ToLab(rgb2);

bmp = new Bitmap(21, 6);
LockBitmap lockBitmap = new LockBitmap(bmp);
lockBitmap.LockBits();



for (int x = 0; x < 21; x++)
for (int y = 0; y < 6; y++)
{
distances[x, y] = double.MaxValue;
times[x, y] = int.MaxValue;
}

for (int i = 0; i < points.Count; i++)
{
keysavePoint c = points[i];

for (int x = 0; x < 21; x++)
for (int y = 0; y < 6; y++)
{
double distance = Math.Sqrt(((x - c.point.X) * (x - c.point.X) + (y - c.point.Y) * (y - c.point.Y)));
distance = Math.Abs(distance) / (Form1.m_distanceFalloff / 2);
if (Form1.m_Wave)
{
distance -= c.counter;
distance = Math.Abs(distance);
}
if (distance < Math.Abs(distances[x, y]))
{
distances[x, y] = distance;
}
if (c.counter < times[x, y])
times[x, y] = c.counter;
}
c.counter++;
points[i] = c;
}

for (int x = 0; x < 21; x++)
for (int y = 0; y < 6; y++)
{
double distance = distances[x, y];
System.Drawing.Color colour = System.Drawing.Color.White;
if (Form1.m_Wave == true)
colour = getColour(lab1, lab2, distance + times[x, y] + Math.Pow(distance, Form1.m_WaveSpeed), gradientspeed, fadespeed);
else
colour = getColour(lab1, lab2, distance + times[x, y], gradientspeed, fadespeed);
lockBitmap.SetPixel(x, y, colour);
}


//for (int ki = 0; ki < points.Count - 1; ki++)
//{
// double distance = points[ki].counter;
// keysavePoint kchanged = new keysavePoint();
// kchanged.point = points[ki].point;
// kchanged.counter = (int)(distance + 1);
// points[ki] = kchanged;
// int x = points[ki].point.X;
// int y = points[ki].point.Y;
// System.Drawing.Color colour = System.Drawing.Color.White;

// colour = getColour(lab1, lab2, distance, gradientspeed, fadespeed);
// lockBitmap.SetPixel(x, y, colour);
//}

for (int k = points.Count - 1; k >= 0; k--)
{
if (points[k].counter > 20) points.RemoveAt(k);
}
lockBitmap.UnlockBits();

byte[] b = Form1.getLEDGridFromBitmap(bmp);
//((Form1)Application.OpenForms[0]).pic1.Image = bmp;
//bmp.Save(@"C:\temp\heatmap.png");
LogitechGSDK.LogiLedSetLightingFromBitmap(b);
}
counter++;
System.Threading.Thread.Sleep(10);
}
}
Expand Down Expand Up @@ -234,7 +346,7 @@ private static void DoAnimation()
{
//LogitechGSDK.LogiLedSetLighting(0, 0, 0);
//WaveTimer.Enabled = true;
if (((Form1)(Application.OpenForms[0])).spellText == "" && ((Form1)(Application.OpenForms[0])).useLogitechColours) LogitechGSDK.LogiLedRestoreLighting();
if (((Form1)(Application.OpenForms[0])).spellText == "" && ((Form1)(Application.OpenForms[0])).useLogitechColours && !bw_Keysave.IsBusy) LogitechGSDK.LogiLedRestoreLighting();
return;
}
else
Expand Down
6 changes: 3 additions & 3 deletions WhoIsSpeaking/WhoIsSpeaking/WhoIsSpeaking.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
<PropertyGroup>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>app.manifest</ApplicationManifest>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup />
<PropertyGroup />
<ItemGroup>
<Reference Include="ColorManagment">
<HintPath>.\ColorManagment.dll</HintPath>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,58 +1,58 @@
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel node will disable file and registry virtualization.
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of all Windows versions that this application is designed to work with.
Windows will automatically select the most compatible environment.-->

<!-- If your application is designed to work with Windows Vista, uncomment the following supportedOS node-->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>-->

<!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->

<!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->

<!-- If your application is designed to work with Windows 8.1, uncomment the following supportedOS node-->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>-->

</application>
</compatibility>

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!-- <dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->

</asmv1:assembly>
<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel node will disable file and registry virtualization.
If you want to utilize File and Registry Virtualization for backward
compatibility then delete the requestedExecutionLevel node.
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>

<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of all Windows versions that this application is designed to work with.
Windows will automatically select the most compatible environment.-->

<!-- If your application is designed to work with Windows Vista, uncomment the following supportedOS node-->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"></supportedOS>-->

<!-- If your application is designed to work with Windows 7, uncomment the following supportedOS node-->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>-->

<!-- If your application is designed to work with Windows 8, uncomment the following supportedOS node-->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"></supportedOS>-->

<!-- If your application is designed to work with Windows 8.1, uncomment the following supportedOS node-->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>-->

</application>
</compatibility>

<!-- Enable themes for Windows common controls and dialogs (Windows XP and later) -->
<!-- <dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>-->

</asmv1:assembly>
Binary file modified WhoIsSpeaking/WhoIsSpeaking/bin/Debug/WhoIsSpeaking.exe
Binary file not shown.
Binary file modified WhoIsSpeaking/WhoIsSpeaking/bin/Debug/WhoIsSpeaking.pdb
Binary file not shown.
Binary file modified WhoIsSpeaking/WhoIsSpeaking/bin/Debug/WhoIsSpeaking.vshost.exe
Binary file not shown.
Binary file modified WhoIsSpeaking/WhoIsSpeaking/bin/Release/WhoIsSpeaking.exe
Binary file not shown.
Binary file modified WhoIsSpeaking/WhoIsSpeaking/bin/Release/WhoIsSpeaking.pdb
Binary file not shown.
Binary file modified WhoIsSpeaking/WhoIsSpeaking/bin/Release/WhoIsSpeaking.vshost.exe
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,17 @@ C:\Users\jerepalm\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaki
C:\Users\jerepalm\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Debug\WhoIsSpeaking.Form1.resources
C:\Users\jerepalm\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Debug\WhoIsSpeaking.Properties.Resources.resources
C:\Users\jerepalm\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Debug\WhoIsSpeaking.csproj.GenerateResource.Cache
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\bin\Debug\WhoIsSpeaking.exe.config
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Debug\WhoIsSpeaking.exe
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Debug\WhoIsSpeaking.pdb
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Debug\WhoIsSpeaking.Form1.resources
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Debug\WhoIsSpeaking.Properties.Resources.resources
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Debug\WhoIsSpeaking.csproj.GenerateResource.Cache
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\bin\Debug\WhoIsSpeaking.exe
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\bin\Debug\WhoIsSpeaking.pdb
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\bin\Debug\ColorManagment.dll
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\bin\Debug\Ini.Net.dll
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\bin\Debug\InputBox.dll
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\bin\Debug\ICCReader.dll
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\bin\Debug\InputBox.pdb
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Debug\WhoIsSpeaking.csprojResolveAssemblyReference.cache
Binary file not shown.
Binary file not shown.
Binary file modified WhoIsSpeaking/WhoIsSpeaking/obj/Debug/WhoIsSpeaking.exe
Binary file not shown.
Binary file modified WhoIsSpeaking/WhoIsSpeaking/obj/Debug/WhoIsSpeaking.pdb
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\bin\Release\InputBox.dll
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\bin\Release\ICCReader.dll
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\bin\Release\InputBox.pdb
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Release\WhoIsSpeaking.csprojResolveAssemblyReference.cache
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Release\WhoIsSpeaking.Form1.resources
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Release\WhoIsSpeaking.Properties.Resources.resources
C:\Users\Jeremy\Documents\GitHub\LogitechVentMonitor\WhoIsSpeaking\WhoIsSpeaking\obj\Release\WhoIsSpeaking.csproj.GenerateResource.Cache
Expand Down
Binary file not shown.
Binary file not shown.
Binary file modified WhoIsSpeaking/WhoIsSpeaking/obj/Release/WhoIsSpeaking.exe
Binary file not shown.
Binary file modified WhoIsSpeaking/WhoIsSpeaking/obj/Release/WhoIsSpeaking.pdb
Binary file not shown.

0 comments on commit cb9c867

Please sign in to comment.