mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Added animatrix Clock
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
|
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
|
||||||
|
|
||||||
using Starlight.Communication;
|
using Starlight.Communication;
|
||||||
using System.Diagnostics;
|
using System.Drawing;
|
||||||
using System.Management;
|
using System.Management;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ namespace Starlight.AnimeMatrix
|
|||||||
{
|
{
|
||||||
MaxColumns = 33;
|
MaxColumns = 33;
|
||||||
|
|
||||||
FullRows = 6;
|
FullRows = 7;
|
||||||
FullEvenRows = 6;
|
FullEvenRows = 6;
|
||||||
|
|
||||||
MaxRows = 55;
|
MaxRows = 55;
|
||||||
@@ -152,7 +152,7 @@ namespace Starlight.AnimeMatrix
|
|||||||
|
|
||||||
public int XEnd(int row)
|
public int XEnd(int row)
|
||||||
{
|
{
|
||||||
if (row <= FullEvenRows && row % 2 == 0) return MaxColumns-1;
|
if (row <= FullEvenRows && row % 2 == 0) return MaxColumns - 1;
|
||||||
return MaxColumns;
|
return MaxColumns;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,8 +273,41 @@ namespace Starlight.AnimeMatrix
|
|||||||
static int GetColor(Bitmap bmp, int x, int y)
|
static int GetColor(Bitmap bmp, int x, int y)
|
||||||
{
|
{
|
||||||
var pixel = bmp.GetPixel(Math.Max(0, Math.Min(bmp.Width - 1, x)), Math.Max(0, Math.Min(bmp.Height - 1, y)));
|
var pixel = bmp.GetPixel(Math.Max(0, Math.Min(bmp.Width - 1, x)), Math.Max(0, Math.Min(bmp.Height - 1, y)));
|
||||||
return (Math.Max((pixel.R + pixel.G + pixel.B) / 3, 0));
|
return (Math.Min((pixel.R + pixel.G + pixel.B) / 3, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void PresentText(string text, int fontSize = 8)
|
||||||
|
{
|
||||||
|
int width = MaxColumns * 3;
|
||||||
|
int height = MaxRows;
|
||||||
|
|
||||||
|
Bitmap bmp = new Bitmap(width, height);
|
||||||
|
|
||||||
|
using (Graphics g = Graphics.FromImage(bmp))
|
||||||
|
{
|
||||||
|
using (Font font = new Font("Arial", fontSize))
|
||||||
|
{
|
||||||
|
|
||||||
|
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
|
||||||
|
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||||
|
SizeF textSize = g.MeasureString(text, font);
|
||||||
|
|
||||||
|
/*
|
||||||
|
g.TranslateTransform(bmp.Width / 2, bmp.Height / 2);
|
||||||
|
g.RotateTransform(33);
|
||||||
|
g.DrawString(text, font, Brushes.White, -textSize.Width/2, -textSize.Height / 2);
|
||||||
|
*/
|
||||||
|
|
||||||
|
g.DrawString(text, font, Brushes.White, bmp.Width - textSize.Width + 5, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
GenerateFrame(bmp);
|
||||||
|
Present();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void GenerateFrame(Image image)
|
public void GenerateFrame(Image image)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public static class ControlHelper
|
|||||||
foreMain = SystemColors.ControlText;
|
foreMain = SystemColors.ControlText;
|
||||||
foreAccent = Color.LightGray;
|
foreAccent = Color.LightGray;
|
||||||
borderMain = Color.LightGray;
|
borderMain = Color.LightGray;
|
||||||
buttonMain = SystemColors.ControlLight;
|
buttonMain = Color.FromArgb(255, 230, 230, 230);
|
||||||
}
|
}
|
||||||
|
|
||||||
container.BackColor = formBack;
|
container.BackColor = formBack;
|
||||||
|
|||||||
@@ -71,8 +71,8 @@ namespace CustomControls
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private Color buttonColor = Color.LightGray;
|
private Color buttonColor = Color.FromArgb(255,230, 230, 230);
|
||||||
[DefaultValue(typeof(Color), "LightGray")]
|
[DefaultValue(typeof(Color), "230, 230, 230")]
|
||||||
public Color ButtonColor
|
public Color ButtonColor
|
||||||
{
|
{
|
||||||
get { return buttonColor; }
|
get { return buttonColor; }
|
||||||
|
|||||||
6
app/Fans.Designer.cs
generated
6
app/Fans.Designer.cs
generated
@@ -232,7 +232,7 @@ namespace GHelper
|
|||||||
//
|
//
|
||||||
buttonReset.Activated = false;
|
buttonReset.Activated = false;
|
||||||
buttonReset.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
buttonReset.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
|
||||||
buttonReset.BackColor = SystemColors.ControlLight;
|
buttonReset.BackColor = Color.FromArgb(230, 230, 230);
|
||||||
buttonReset.BorderColor = Color.Transparent;
|
buttonReset.BorderColor = Color.Transparent;
|
||||||
buttonReset.BorderRadius = 2;
|
buttonReset.BorderRadius = 2;
|
||||||
buttonReset.FlatStyle = FlatStyle.Flat;
|
buttonReset.FlatStyle = FlatStyle.Flat;
|
||||||
@@ -249,7 +249,7 @@ namespace GHelper
|
|||||||
//
|
//
|
||||||
buttonApply.Activated = false;
|
buttonApply.Activated = false;
|
||||||
buttonApply.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
buttonApply.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
|
||||||
buttonApply.BackColor = SystemColors.ControlLight;
|
buttonApply.BackColor = Color.FromArgb(230, 230, 230);
|
||||||
buttonApply.BorderColor = Color.Transparent;
|
buttonApply.BorderColor = Color.Transparent;
|
||||||
buttonApply.BorderRadius = 2;
|
buttonApply.BorderRadius = 2;
|
||||||
buttonApply.FlatStyle = FlatStyle.Flat;
|
buttonApply.FlatStyle = FlatStyle.Flat;
|
||||||
@@ -320,7 +320,7 @@ namespace GHelper
|
|||||||
//
|
//
|
||||||
buttonApplyPower.Activated = false;
|
buttonApplyPower.Activated = false;
|
||||||
buttonApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
buttonApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
buttonApplyPower.BackColor = SystemColors.ControlLight;
|
buttonApplyPower.BackColor = Color.FromArgb(230, 230, 230);
|
||||||
buttonApplyPower.BorderColor = Color.Transparent;
|
buttonApplyPower.BorderColor = Color.Transparent;
|
||||||
buttonApplyPower.BorderRadius = 2;
|
buttonApplyPower.BorderRadius = 2;
|
||||||
buttonApplyPower.FlatStyle = FlatStyle.Flat;
|
buttonApplyPower.FlatStyle = FlatStyle.Flat;
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
|
||||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||||
<AssemblyVersion>0.35</AssemblyVersion>
|
<AssemblyVersion>0.36</AssemblyVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
10
app/Settings.Designer.cs
generated
10
app/Settings.Designer.cs
generated
@@ -179,7 +179,7 @@ namespace GHelper
|
|||||||
// buttonMatrix
|
// buttonMatrix
|
||||||
//
|
//
|
||||||
buttonMatrix.Activated = false;
|
buttonMatrix.Activated = false;
|
||||||
buttonMatrix.BackColor = SystemColors.ControlLight;
|
buttonMatrix.BackColor = Color.FromArgb(230, 230, 230);
|
||||||
buttonMatrix.BorderColor = Color.Transparent;
|
buttonMatrix.BorderColor = Color.Transparent;
|
||||||
buttonMatrix.BorderRadius = 2;
|
buttonMatrix.BorderRadius = 2;
|
||||||
buttonMatrix.Dock = DockStyle.Top;
|
buttonMatrix.Dock = DockStyle.Top;
|
||||||
@@ -202,7 +202,7 @@ namespace GHelper
|
|||||||
comboMatrixRunning.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
comboMatrixRunning.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
|
||||||
comboMatrixRunning.FormattingEnabled = true;
|
comboMatrixRunning.FormattingEnabled = true;
|
||||||
comboMatrixRunning.ItemHeight = 32;
|
comboMatrixRunning.ItemHeight = 32;
|
||||||
comboMatrixRunning.Items.AddRange(new object[] { "Binary Banner", "Rog Logo", "Picture" });
|
comboMatrixRunning.Items.AddRange(new object[] { "Binary Banner", "Rog Logo", "Picture", "Clock" });
|
||||||
comboMatrixRunning.Location = new Point(197, 10);
|
comboMatrixRunning.Location = new Point(197, 10);
|
||||||
comboMatrixRunning.Margin = new Padding(4, 10, 4, 8);
|
comboMatrixRunning.Margin = new Padding(4, 10, 4, 8);
|
||||||
comboMatrixRunning.Name = "comboMatrixRunning";
|
comboMatrixRunning.Name = "comboMatrixRunning";
|
||||||
@@ -327,7 +327,7 @@ namespace GHelper
|
|||||||
//
|
//
|
||||||
buttonQuit.Activated = false;
|
buttonQuit.Activated = false;
|
||||||
buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
buttonQuit.BackColor = SystemColors.ControlLight;
|
buttonQuit.BackColor = Color.FromArgb(230, 230, 230);
|
||||||
buttonQuit.BorderColor = Color.Transparent;
|
buttonQuit.BorderColor = Color.Transparent;
|
||||||
buttonQuit.BorderRadius = 2;
|
buttonQuit.BorderRadius = 2;
|
||||||
buttonQuit.FlatStyle = FlatStyle.Flat;
|
buttonQuit.FlatStyle = FlatStyle.Flat;
|
||||||
@@ -494,7 +494,7 @@ namespace GHelper
|
|||||||
// buttonFans
|
// buttonFans
|
||||||
//
|
//
|
||||||
buttonFans.Activated = false;
|
buttonFans.Activated = false;
|
||||||
buttonFans.BackColor = SystemColors.ControlLight;
|
buttonFans.BackColor = Color.FromArgb(230, 230, 230);
|
||||||
buttonFans.BorderColor = Color.Transparent;
|
buttonFans.BorderColor = Color.Transparent;
|
||||||
buttonFans.BorderRadius = 5;
|
buttonFans.BorderRadius = 5;
|
||||||
buttonFans.Dock = DockStyle.Fill;
|
buttonFans.Dock = DockStyle.Fill;
|
||||||
@@ -881,7 +881,7 @@ namespace GHelper
|
|||||||
// buttonKeyboard
|
// buttonKeyboard
|
||||||
//
|
//
|
||||||
buttonKeyboard.Activated = false;
|
buttonKeyboard.Activated = false;
|
||||||
buttonKeyboard.BackColor = SystemColors.ControlLight;
|
buttonKeyboard.BackColor = Color.FromArgb(230, 230, 230);
|
||||||
buttonKeyboard.BorderColor = Color.Transparent;
|
buttonKeyboard.BorderColor = Color.Transparent;
|
||||||
buttonKeyboard.BorderRadius = 2;
|
buttonKeyboard.BorderRadius = 2;
|
||||||
buttonKeyboard.Dock = DockStyle.Top;
|
buttonKeyboard.Dock = DockStyle.Top;
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ namespace GHelper
|
|||||||
public Keyboard keyb;
|
public Keyboard keyb;
|
||||||
|
|
||||||
static AnimeMatrixDevice mat;
|
static AnimeMatrixDevice mat;
|
||||||
|
static int matrixMode = 0;
|
||||||
|
|
||||||
public SettingsForm()
|
public SettingsForm()
|
||||||
{
|
{
|
||||||
@@ -265,14 +266,23 @@ namespace GHelper
|
|||||||
private static void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
|
private static void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
if (mat is null) return;
|
if (mat is null) return;
|
||||||
mat.PresentNextFrame();
|
|
||||||
|
switch (Program.config.getConfig("matrix_running"))
|
||||||
|
{
|
||||||
|
case 2:
|
||||||
|
mat.PresentNextFrame();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
mat.PresentText(DateTime.Now.ToString("H:mm:ss"));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetMatrixPicture(string fileName)
|
void SetMatrixPicture(string fileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (mat is null) return;
|
if (mat is null) return;
|
||||||
|
|
||||||
StopMatrixTimer();
|
StopMatrixTimer();
|
||||||
|
|
||||||
Image image;
|
Image image;
|
||||||
@@ -315,8 +325,6 @@ namespace GHelper
|
|||||||
mat.GenerateFrame(image);
|
mat.GenerateFrame(image);
|
||||||
mat.Present();
|
mat.Present();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -397,14 +405,20 @@ namespace GHelper
|
|||||||
mat.SetDisplayState(true);
|
mat.SetDisplayState(true);
|
||||||
mat.SetBrightness((BrightnessMode)brightness);
|
mat.SetBrightness((BrightnessMode)brightness);
|
||||||
|
|
||||||
if (running == 2)
|
switch (running)
|
||||||
{
|
{
|
||||||
string fileName = Program.config.getConfigString("matrix_picture");
|
case 2:
|
||||||
SetMatrixPicture(fileName);
|
string fileName = Program.config.getConfigString("matrix_picture");
|
||||||
}
|
SetMatrixPicture(fileName);
|
||||||
else
|
break;
|
||||||
{
|
case 3:
|
||||||
mat.SetBuiltInAnimation(true, animation);
|
mat.SetBuiltInAnimation(false);
|
||||||
|
StartMatrixTimer();
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
mat.SetBuiltInAnimation(true, animation);
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user