This commit is contained in:
seerge
2023-03-06 13:30:04 +01:00
parent 954861f2b1
commit aa62330c1c
3 changed files with 716 additions and 529 deletions

View File

@@ -25,7 +25,8 @@ namespace GHelper
Fans fans;
Keyboard keyb;
static AnimeMatrixDevice mat = new AnimeMatrixDevice();
static AnimeMatrixDevice mat;
static bool matEnabled = false;
public SettingsForm()
@@ -90,12 +91,6 @@ namespace GHelper
buttonMatrix.Click += ButtonMatrix_Click;
matrixTimer = new System.Timers.Timer();
matrixTimer.Enabled = false;
matrixTimer.Interval = 100;
matrixTimer.Elapsed += MatrixTimer_Elapsed;
SetTimer();
}
@@ -112,12 +107,15 @@ namespace GHelper
private static void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
if (mat is null) return;
mat.PresentNextFrame();
}
void SetMatrixPicture(string fileName)
{
if (mat is null) return;
StopMatrixTimer();
Image image;
@@ -156,7 +154,7 @@ namespace GHelper
StartMatrixTimer();
}
else
{
{
mat.GenerateFrame(image);
mat.Present();
}
@@ -209,6 +207,8 @@ namespace GHelper
public void SetAnimeMatrix()
{
if (mat is null) return;
int brightness = Program.config.getConfig("matrix_brightness");
int running = Program.config.getConfig("matrix_running");
@@ -356,11 +356,36 @@ namespace GHelper
public void InitMatrix()
{
int brightness = Program.config.getConfig("matrix_brightness");
int running = Program.config.getConfig("matrix_running");
comboMatrix.SelectedIndex = (brightness != -1) ? brightness : 0;
comboMatrixRunning.SelectedIndex = (running != -1) ? running : 0;
matrixTimer = new System.Timers.Timer();
matrixTimer.Enabled = false;
matrixTimer.Interval = 100;
try
{
matEnabled = true;
mat = new AnimeMatrixDevice();
matrixTimer.Elapsed += MatrixTimer_Elapsed;
}
catch
{
matEnabled = false;
Debug.WriteLine("Anime Matrix not detected");
}
if (!matEnabled)
{
panelMatrix.Visible = false;
}
else
{
int brightness = Program.config.getConfig("matrix_brightness");
int running = Program.config.getConfig("matrix_running");
comboMatrix.SelectedIndex = (brightness != -1) ? brightness : 0;
comboMatrixRunning.SelectedIndex = (running != -1) ? running : 0;
}
}