mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-12 21:38:38 +00:00
Found a way better way to update keyboard dynamically. Left old code in for people to laugh at me.
This commit is contained in:
parent
3fdb2093e7
commit
977f88fde9
@ -45,26 +45,35 @@ namespace Artemis.KeyboardProviders.Corsair
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
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*(_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.01f) { Brush = new SolidColorBrush(bitmap.GetPixel(x, y)) };
|
||||
}
|
||||
}
|
||||
_keyboard.Update();
|
||||
for (var x = 0; x < bitmap.Width; x++)
|
||||
{
|
||||
for (var y = 0; y < bitmap.Height; y++)
|
||||
{
|
||||
_keyboard.DetachKeyGroup(ledGroups[x, y]);
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
Bitmap resize = new Bitmap(bitmap, new Size((int)_keyboard.KeyboardRectangle.Width, (int)_keyboard.KeyboardRectangle.Height));
|
||||
foreach (var item in _keyboard.Keys)
|
||||
{
|
||||
item.Led.Color = resize.GetPixel((int)item.KeyRectangle.X, (int)item.KeyRectangle.Y);
|
||||
}
|
||||
_keyboard.Update();
|
||||
}
|
||||
|
||||
/*
|
||||
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*(_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.01f) { Brush = new SolidColorBrush(bitmap.GetPixel(x, y)) };
|
||||
}
|
||||
}
|
||||
_keyboard.Update();
|
||||
for (var x = 0; x < bitmap.Width; x++)
|
||||
{
|
||||
for (var y = 0; y < bitmap.Height; y++)
|
||||
{
|
||||
_keyboard.DetachKeyGroup(ledGroups[x, y]);
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
}
|
||||
@ -32,7 +32,7 @@ namespace Artemis.Utilities.GameState
|
||||
|
||||
_listener.Prefixes.Clear();
|
||||
Port = Settings.General.Default.GamestatePort;
|
||||
_listener.Prefixes.Add($"http://127.0.0.1:{Port}/");
|
||||
_listener.Prefixes.Add($"http://localhost:{Port}/");
|
||||
|
||||
_listener.Start();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user