This commit is contained in:
Serge
2023-10-03 00:31:07 +02:00
parent 72b1842520
commit 46bfda3ad5
3 changed files with 67 additions and 53 deletions

View File

@@ -337,7 +337,7 @@ namespace GHelper.Input
if (e.Modifier == (ModifierKeys.Control | ModifierKeys.Shift)) if (e.Modifier == (ModifierKeys.Control | ModifierKeys.Shift))
{ {
if (e.Key == keyProfile) modeControl.CyclePerformanceMode(); if (e.Key == keyProfile) modeControl.CyclePerformanceMode();
if (e.Key == keyApp) Program.SettingsToggle("", true); if (e.Key == keyApp) Program.SettingsToggle();
if (e.Key == Keys.F20) KeyProcess("m3"); if (e.Key == Keys.F20) KeyProcess("m3");
} }
@@ -427,7 +427,7 @@ namespace GHelper.Input
{ {
Program.settingsForm.BeginInvoke(delegate Program.settingsForm.BeginInvoke(delegate
{ {
Program.SettingsToggle("", true); Program.SettingsToggle();
}); });
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -119,7 +119,7 @@ namespace GHelper
if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\') || action.Length > 0) if (Environment.CurrentDirectory.Trim('\\') == Application.StartupPath.Trim('\\') || action.Length > 0)
{ {
SettingsToggle(action); SettingsToggle(action, false);
} }
Application.Run(); Application.Run();
@@ -156,17 +156,17 @@ namespace GHelper
lastTheme = DateTimeOffset.Now.ToUnixTimeMilliseconds(); lastTheme = DateTimeOffset.Now.ToUnixTimeMilliseconds();
} }
if (settingsForm.fans is not null && settingsForm.fans.Text != "") if (settingsForm.fansForm is not null && settingsForm.fansForm.Text != "")
settingsForm.fans.InitTheme(); settingsForm.fansForm.InitTheme();
if (settingsForm.keyb is not null && settingsForm.keyb.Text != "") if (settingsForm.extraForm is not null && settingsForm.extraForm.Text != "")
settingsForm.keyb.InitTheme(); settingsForm.extraForm.InitTheme();
if (settingsForm.updates is not null && settingsForm.updates.Text != "") if (settingsForm.updatesForm is not null && settingsForm.updatesForm.Text != "")
settingsForm.updates.InitTheme(); settingsForm.updatesForm.InitTheme();
if (settingsForm.matrix is not null && settingsForm.matrix.Text != "") if (settingsForm.matrixForm is not null && settingsForm.matrixForm.Text != "")
settingsForm.matrix.InitTheme(); settingsForm.matrixForm.InitTheme();
break; break;
} }
} }
@@ -213,7 +213,7 @@ namespace GHelper
SetAutoModes(true); SetAutoModes(true);
} }
public static void SettingsToggle(string action = "", bool checkForFocus = false) public static void SettingsToggle(string action = "", bool checkForFocus = true)
{ {
if (settingsForm.Visible) if (settingsForm.Visible)
{ {
@@ -256,9 +256,9 @@ namespace GHelper
gpuControl.RestartGPU(false); gpuControl.RestartGPU(false);
break; break;
case "services": case "services":
settingsForm.keyb = new Extra(); settingsForm.extraForm = new Extra();
settingsForm.keyb.Show(); settingsForm.extraForm.Show();
settingsForm.keyb.ServiesToggle(); settingsForm.extraForm.ServiesToggle();
break; break;
case "uv": case "uv":
Startup.ReScheduleAdmin(); Startup.ReScheduleAdmin();

View File

@@ -32,10 +32,10 @@ namespace GHelper
public static System.Timers.Timer sensorTimer = default!; public static System.Timers.Timer sensorTimer = default!;
public Matrix? matrix; public Matrix? matrixForm;
public Fans? fans; public Fans? fansForm;
public Extra? keyb; public Extra? extraForm;
public Updates? updates; public Updates? updatesForm;
static long lastRefresh; static long lastRefresh;
static long lastBatteryRefresh; static long lastBatteryRefresh;
@@ -282,21 +282,26 @@ namespace GHelper
private void ButtonUpdates_Click(object? sender, EventArgs e) private void ButtonUpdates_Click(object? sender, EventArgs e)
{ {
if (updates == null || updates.Text == "") if (updatesForm == null || updatesForm.Text == "")
{ {
updates = new Updates(); updatesForm = new Updates();
updates.Show(); AddOwnedForm(updatesForm);
}
if (updatesForm.Visible)
{
updatesForm.Close();
} }
else else
{ {
updates.Close(); updatesForm.Show();
} }
} }
public void VisualiseMatrix(string image) public void VisualiseMatrix(string image)
{ {
if (matrix == null || matrix.Text == "") return; if (matrixForm == null || matrixForm.Text == "") return;
matrix.VisualiseMatrix(image); matrixForm.VisualiseMatrix(image);
} }
protected override void WndProc(ref Message m) protected override void WndProc(ref Message m)
@@ -544,20 +549,20 @@ namespace GHelper
private void ButtonMatrix_Click(object? sender, EventArgs e) private void ButtonMatrix_Click(object? sender, EventArgs e)
{ {
if (matrix == null || matrix.Text == "") if (matrixForm == null || matrixForm.Text == "")
{ {
matrix = new Matrix(); matrixForm = new Matrix();
AddOwnedForm(matrix); AddOwnedForm(matrixForm);
} }
if (matrix.Visible) if (matrixForm.Visible)
{ {
matrix.Close(); matrixForm.Close();
} }
else else
{ {
matrix.FormPosition(); matrixForm.FormPosition();
matrix.Show(); matrixForm.Show();
} }
} }
@@ -612,15 +617,19 @@ namespace GHelper
private void ButtonKeyboard_Click(object? sender, EventArgs e) private void ButtonKeyboard_Click(object? sender, EventArgs e)
{ {
if (keyb == null || keyb.Text == "") if (extraForm == null || extraForm.Text == "")
{ {
keyb = new Extra(); extraForm = new Extra();
keyb.Show(); AddOwnedForm(extraForm);
AddOwnedForm(keyb); }
if (extraForm.Visible)
{
extraForm.Close();
} }
else else
{ {
keyb.Close(); extraForm.Show();
} }
} }
@@ -628,7 +637,7 @@ namespace GHelper
{ {
Invoke(delegate Invoke(delegate
{ {
if (fans != null && fans.Text != "") fans.InitAll(); if (fansForm != null && fansForm.Text != "") fansForm.InitAll();
}); });
} }
@@ -636,27 +645,27 @@ namespace GHelper
{ {
Invoke(delegate Invoke(delegate
{ {
if (fans != null && fans.Text != "") fans.InitGPU(); if (fansForm != null && fansForm.Text != "") fansForm.InitGPU();
}); });
} }
public void FansToggle(int index = 0) public void FansToggle(int index = 0)
{ {
if (fans == null || fans.Text == "") if (fansForm == null || fansForm.Text == "")
{ {
fans = new Fans(); fansForm = new Fans();
AddOwnedForm(fans); AddOwnedForm(fansForm);
} }
if (fans.Visible) if (fansForm.Visible)
{ {
fans.Close(); fansForm.Close();
} }
else else
{ {
fans.FormPosition(); fansForm.FormPosition();
fans.Show(); fansForm.Show();
fans.ToggleNavigation(index); fansForm.ToggleNavigation(index);
} }
} }
@@ -848,9 +857,10 @@ namespace GHelper
public void HideAll() public void HideAll()
{ {
this.Hide(); this.Hide();
if (fans != null && fans.Text != "") fans.Close(); if (fansForm != null && fansForm.Text != "") fansForm.Close();
if (keyb != null && keyb.Text != "") keyb.Close(); if (extraForm != null && extraForm.Text != "") extraForm.Close();
if (updates != null && updates.Text != "") updates.Close(); if (updatesForm != null && updatesForm.Text != "") updatesForm.Close();
if (matrixForm != null && matrixForm.Text != "") matrixForm.Close();
} }
/// <summary> /// <summary>
@@ -867,7 +877,11 @@ namespace GHelper
/// <returns>Focus state</returns> /// <returns>Focus state</returns>
public bool HasAnyFocus() public bool HasAnyFocus()
{ {
return (fans != null && fans.ContainsFocus) || (keyb != null && keyb.ContainsFocus) || (updates != null && updates.ContainsFocus) || this.ContainsFocus; return (fansForm != null && fansForm.ContainsFocus) ||
(extraForm != null && extraForm.ContainsFocus) ||
(updatesForm != null && updatesForm.ContainsFocus) ||
(matrixForm != null && matrixForm.ContainsFocus) ||
this.ContainsFocus;
} }
private void SettingsForm_FormClosing(object? sender, FormClosingEventArgs e) private void SettingsForm_FormClosing(object? sender, FormClosingEventArgs e)
@@ -962,8 +976,8 @@ namespace GHelper
public void LabelFansResult(string text) public void LabelFansResult(string text)
{ {
if (fans != null && fans.Text != "") if (fansForm != null && fansForm.Text != "")
fans.LabelFansResult(text); fansForm.LabelFansResult(text);
} }
public void ShowMode(int mode) public void ShowMode(int mode)