This commit is contained in:
seerge
2023-03-05 23:26:39 +01:00
parent 321bc2623d
commit 24014dd20f

View File

@@ -1,12 +1,8 @@
using Starlight.AnimeMatrix; using Starlight.AnimeMatrix;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing.Imaging;
using System.Reflection; using System.Reflection;
using System.Timers; using System.Timers;
using System.Drawing.Imaging;
using System.CodeDom.Compiler;
using System.Drawing;
using System;
using System.Globalization;
namespace GHelper namespace GHelper
{ {
@@ -22,8 +18,7 @@ namespace GHelper
static int buttonActive = 5; static int buttonActive = 5;
static System.Timers.Timer aTimer = default!; static System.Timers.Timer aTimer = default!;
static System.Timers.Timer matrixTimer = new System.Timers.Timer(100);
static System.Timers.Timer matrixTimer = default!;
public string perfName = "Balanced"; public string perfName = "Balanced";
@@ -96,11 +91,18 @@ namespace GHelper
buttonMatrix.Click += ButtonMatrix_Click; buttonMatrix.Click += ButtonMatrix_Click;
matrixTimer.Enabled = false;
matrixTimer.Elapsed += MatrixTimer_Elapsed;
SetTimer(); SetTimer();
} }
private void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
{
mat.PresentNextFrame();
}
void SetMatrixPicture(string fileName) void SetMatrixPicture(string fileName)
{ {
@@ -115,7 +117,8 @@ namespace GHelper
ms.Position = 0; ms.Position = 0;
image = Image.FromStream(ms); image = Image.FromStream(ms);
} }
} catch }
catch
{ {
Debug.WriteLine("Error loading picture"); Debug.WriteLine("Error loading picture");
return; return;
@@ -125,7 +128,7 @@ namespace GHelper
mat.ClearFrames(); mat.ClearFrames();
FrameDimension dimension = new FrameDimension(image.FrameDimensionsList[0]); FrameDimension dimension = new FrameDimension(image.FrameDimensionsList[0]);
int frameCount = image.GetFrameCount(dimension); int frameCount = image.GetFrameCount(dimension);
if (frameCount > 1) if (frameCount > 1)
{ {
@@ -135,20 +138,11 @@ namespace GHelper
mat.GenerateFrame(image); mat.GenerateFrame(image);
mat.AddFrame(); mat.AddFrame();
} }
matrixTimer = new System.Timers.Timer(50);
matrixTimer.Enabled = true; matrixTimer.Enabled = true;
matrixTimer.Elapsed += delegate }
{ else
mat.PresentNextFrame();
};
} else
{ {
if (matrixTimer is not null) matrixTimer.Enabled = false;
{
matrixTimer.Enabled = false;
matrixTimer.Dispose();
}
mat.GenerateFrame(image); mat.GenerateFrame(image);
mat.Present(); mat.Present();