Added animatrix Clock

This commit is contained in:
seerge
2023-03-22 14:38:01 +01:00
parent 83b184a061
commit 264631ab77
7 changed files with 74 additions and 27 deletions

View File

@@ -1,7 +1,7 @@
// Source thanks to https://github.com/vddCore/Starlight with some adjustments from me
using Starlight.Communication;
using System.Diagnostics;
using System.Drawing;
using System.Management;
using System.Text;
@@ -90,7 +90,7 @@ namespace Starlight.AnimeMatrix
{
MaxColumns = 33;
FullRows = 6;
FullRows = 7;
FullEvenRows = 6;
MaxRows = 55;
@@ -273,8 +273,41 @@ namespace Starlight.AnimeMatrix
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)));
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)
{

View File

@@ -36,7 +36,7 @@ public static class ControlHelper
foreMain = SystemColors.ControlText;
foreAccent = Color.LightGray;
borderMain = Color.LightGray;
buttonMain = SystemColors.ControlLight;
buttonMain = Color.FromArgb(255, 230, 230, 230);
}
container.BackColor = formBack;

View File

@@ -71,8 +71,8 @@ namespace CustomControls
}
}
}
private Color buttonColor = Color.LightGray;
[DefaultValue(typeof(Color), "LightGray")]
private Color buttonColor = Color.FromArgb(255,230, 230, 230);
[DefaultValue(typeof(Color), "230, 230, 230")]
public Color ButtonColor
{
get { return buttonColor; }

6
app/Fans.Designer.cs generated
View File

@@ -232,7 +232,7 @@ namespace GHelper
//
buttonReset.Activated = false;
buttonReset.Anchor = AnchorStyles.Bottom | AnchorStyles.Left;
buttonReset.BackColor = SystemColors.ControlLight;
buttonReset.BackColor = Color.FromArgb(230, 230, 230);
buttonReset.BorderColor = Color.Transparent;
buttonReset.BorderRadius = 2;
buttonReset.FlatStyle = FlatStyle.Flat;
@@ -249,7 +249,7 @@ namespace GHelper
//
buttonApply.Activated = false;
buttonApply.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
buttonApply.BackColor = SystemColors.ControlLight;
buttonApply.BackColor = Color.FromArgb(230, 230, 230);
buttonApply.BorderColor = Color.Transparent;
buttonApply.BorderRadius = 2;
buttonApply.FlatStyle = FlatStyle.Flat;
@@ -320,7 +320,7 @@ namespace GHelper
//
buttonApplyPower.Activated = false;
buttonApplyPower.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
buttonApplyPower.BackColor = SystemColors.ControlLight;
buttonApplyPower.BackColor = Color.FromArgb(230, 230, 230);
buttonApplyPower.BorderColor = Color.Transparent;
buttonApplyPower.BorderRadius = 2;
buttonApplyPower.FlatStyle = FlatStyle.Flat;

View File

@@ -16,7 +16,7 @@
<PlatformTarget>x64</PlatformTarget>
<ProduceReferenceAssembly>False</ProduceReferenceAssembly>
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
<AssemblyVersion>0.35</AssemblyVersion>
<AssemblyVersion>0.36</AssemblyVersion>
</PropertyGroup>
<ItemGroup>

View File

@@ -179,7 +179,7 @@ namespace GHelper
// buttonMatrix
//
buttonMatrix.Activated = false;
buttonMatrix.BackColor = SystemColors.ControlLight;
buttonMatrix.BackColor = Color.FromArgb(230, 230, 230);
buttonMatrix.BorderColor = Color.Transparent;
buttonMatrix.BorderRadius = 2;
buttonMatrix.Dock = DockStyle.Top;
@@ -202,7 +202,7 @@ namespace GHelper
comboMatrixRunning.Font = new Font("Segoe UI", 9F, FontStyle.Regular, GraphicsUnit.Point);
comboMatrixRunning.FormattingEnabled = true;
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.Margin = new Padding(4, 10, 4, 8);
comboMatrixRunning.Name = "comboMatrixRunning";
@@ -327,7 +327,7 @@ namespace GHelper
//
buttonQuit.Activated = false;
buttonQuit.Anchor = AnchorStyles.Top | AnchorStyles.Right;
buttonQuit.BackColor = SystemColors.ControlLight;
buttonQuit.BackColor = Color.FromArgb(230, 230, 230);
buttonQuit.BorderColor = Color.Transparent;
buttonQuit.BorderRadius = 2;
buttonQuit.FlatStyle = FlatStyle.Flat;
@@ -494,7 +494,7 @@ namespace GHelper
// buttonFans
//
buttonFans.Activated = false;
buttonFans.BackColor = SystemColors.ControlLight;
buttonFans.BackColor = Color.FromArgb(230, 230, 230);
buttonFans.BorderColor = Color.Transparent;
buttonFans.BorderRadius = 5;
buttonFans.Dock = DockStyle.Fill;
@@ -881,7 +881,7 @@ namespace GHelper
// buttonKeyboard
//
buttonKeyboard.Activated = false;
buttonKeyboard.BackColor = SystemColors.ControlLight;
buttonKeyboard.BackColor = Color.FromArgb(230, 230, 230);
buttonKeyboard.BorderColor = Color.Transparent;
buttonKeyboard.BorderRadius = 2;
buttonKeyboard.Dock = DockStyle.Top;

View File

@@ -21,6 +21,7 @@ namespace GHelper
public Keyboard keyb;
static AnimeMatrixDevice mat;
static int matrixMode = 0;
public SettingsForm()
{
@@ -265,14 +266,23 @@ namespace GHelper
private static void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
if (mat is null) return;
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)
{
if (mat is null) return;
StopMatrixTimer();
Image image;
@@ -315,8 +325,6 @@ namespace GHelper
mat.GenerateFrame(image);
mat.Present();
}
}
@@ -397,14 +405,20 @@ namespace GHelper
mat.SetDisplayState(true);
mat.SetBrightness((BrightnessMode)brightness);
if (running == 2)
switch (running)
{
case 2:
string fileName = Program.config.getConfigString("matrix_picture");
SetMatrixPicture(fileName);
}
else
{
break;
case 3:
mat.SetBuiltInAnimation(false);
StartMatrixTimer();
break;
default:
mat.SetBuiltInAnimation(true, animation);
break;
}
}