mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Timers fix
This commit is contained in:
52
Settings.cs
52
Settings.cs
@@ -18,14 +18,15 @@ 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();
|
static System.Timers.Timer matrixTimer = default!;
|
||||||
|
|
||||||
public string perfName = "Balanced";
|
public string perfName = "Balanced";
|
||||||
|
|
||||||
Fans fans;
|
Fans fans;
|
||||||
Keyboard keyb;
|
Keyboard keyb;
|
||||||
|
|
||||||
AnimeMatrixDevice mat = new AnimeMatrixDevice();
|
static AnimeMatrixDevice mat = new AnimeMatrixDevice();
|
||||||
|
|
||||||
|
|
||||||
public SettingsForm()
|
public SettingsForm()
|
||||||
{
|
{
|
||||||
@@ -83,20 +84,33 @@ namespace GHelper
|
|||||||
|
|
||||||
comboMatrix.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboMatrix.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboMatrixRunning.DropDownStyle = ComboBoxStyle.DropDownList;
|
comboMatrixRunning.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||||
comboMatrix.SelectedValueChanged += ComboMatrix_SelectedValueChanged;
|
|
||||||
comboMatrixRunning.SelectedValueChanged += ComboMatrixRunning_SelectedValueChanged;
|
comboMatrix.DropDownClosed += ComboMatrix_SelectedValueChanged;
|
||||||
|
comboMatrixRunning.DropDownClosed += ComboMatrixRunning_SelectedValueChanged;
|
||||||
|
|
||||||
buttonMatrix.Click += ButtonMatrix_Click;
|
buttonMatrix.Click += ButtonMatrix_Click;
|
||||||
|
|
||||||
|
matrixTimer = new System.Timers.Timer();
|
||||||
matrixTimer.Enabled = false;
|
matrixTimer.Enabled = false;
|
||||||
matrixTimer.Interval = 100;
|
matrixTimer.Interval = 100;
|
||||||
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
matrixTimer.Elapsed += MatrixTimer_Elapsed;
|
||||||
|
|
||||||
|
|
||||||
SetTimer();
|
SetTimer();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
|
private static void StartMatrixTimer()
|
||||||
|
{
|
||||||
|
matrixTimer.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void StopMatrixTimer()
|
||||||
|
{
|
||||||
|
matrixTimer.Enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void MatrixTimer_Elapsed(object? sender, ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
mat.PresentNextFrame();
|
mat.PresentNextFrame();
|
||||||
}
|
}
|
||||||
@@ -104,6 +118,8 @@ namespace GHelper
|
|||||||
void SetMatrixPicture(string fileName)
|
void SetMatrixPicture(string fileName)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
StopMatrixTimer();
|
||||||
|
|
||||||
Image image;
|
Image image;
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -136,12 +152,11 @@ namespace GHelper
|
|||||||
mat.GenerateFrame(image);
|
mat.GenerateFrame(image);
|
||||||
mat.AddFrame();
|
mat.AddFrame();
|
||||||
}
|
}
|
||||||
matrixTimer.Enabled = true;
|
|
||||||
|
StartMatrixTimer();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
matrixTimer.Enabled = false;
|
|
||||||
|
|
||||||
mat.GenerateFrame(image);
|
mat.GenerateFrame(image);
|
||||||
mat.Present();
|
mat.Present();
|
||||||
}
|
}
|
||||||
@@ -152,18 +167,15 @@ namespace GHelper
|
|||||||
|
|
||||||
private void ButtonMatrix_Click(object? sender, EventArgs e)
|
private void ButtonMatrix_Click(object? sender, EventArgs e)
|
||||||
{
|
{
|
||||||
|
string fileName = "";
|
||||||
|
|
||||||
Thread t = new Thread((ThreadStart)(() =>
|
Thread t = new Thread((ThreadStart)(() =>
|
||||||
{
|
{
|
||||||
OpenFileDialog of = new OpenFileDialog();
|
OpenFileDialog of = new OpenFileDialog();
|
||||||
of.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png,*.gif)|*.BMP;*.JPG;*.JPEG;*.PNG;*.GIF";
|
of.Filter = "Image Files (*.bmp;*.jpg;*.jpeg,*.png,*.gif)|*.BMP;*.JPG;*.JPEG;*.PNG;*.GIF";
|
||||||
if (of.ShowDialog() == DialogResult.OK)
|
if (of.ShowDialog() == DialogResult.OK)
|
||||||
{
|
{
|
||||||
Program.config.setConfig("matrix_picture", of.FileName);
|
fileName = of.FileName;
|
||||||
SetMatrixPicture(of.FileName);
|
|
||||||
BeginInvoke(delegate
|
|
||||||
{
|
|
||||||
comboMatrixRunning.SelectedIndex = 2;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}));
|
}));
|
||||||
@@ -171,6 +183,14 @@ namespace GHelper
|
|||||||
t.SetApartmentState(ApartmentState.STA);
|
t.SetApartmentState(ApartmentState.STA);
|
||||||
t.Start();
|
t.Start();
|
||||||
t.Join();
|
t.Join();
|
||||||
|
|
||||||
|
Program.config.setConfig("matrix_picture", fileName);
|
||||||
|
SetMatrixPicture(fileName);
|
||||||
|
BeginInvoke(delegate
|
||||||
|
{
|
||||||
|
comboMatrixRunning.SelectedIndex = 2;
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e)
|
private void ComboMatrixRunning_SelectedValueChanged(object? sender, EventArgs e)
|
||||||
@@ -202,7 +222,7 @@ namespace GHelper
|
|||||||
BuiltInAnimation.Startup.StaticEmergence
|
BuiltInAnimation.Startup.StaticEmergence
|
||||||
);
|
);
|
||||||
|
|
||||||
matrixTimer.Enabled = false;
|
StopMatrixTimer();
|
||||||
|
|
||||||
if (brightness == 0)
|
if (brightness == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user