Skip to content

Commit

Permalink
Minior tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
seerge committed Aug 24, 2023
1 parent a97bfc2 commit 47f86d2
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 13 deletions.
8 changes: 7 additions & 1 deletion app/AnimeMatrix/AniMatrixControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,13 @@ public void SetMatrix(bool wakeUp = false)
StopMatrixTimer();
StopMatrixAudio();

mat.SetProvider();
try
{
mat.SetProvider();
} catch (Exception ex) {
Logger.WriteLine(ex.Message);
return;
}

if (wakeUp && AppConfig.ContainsModel("401")) mat.WakeUp();

Expand Down
50 changes: 43 additions & 7 deletions app/Fans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public partial class Fans : RForm
static int MinRPM, MaxRPM;

static bool gpuVisible = true;
static bool fanRpm = true;

const int fansMax = 100;

Expand Down Expand Up @@ -87,6 +88,11 @@ public Fans()
chartXGM.MouseMove += (sender, e) => ChartCPU_MouseMove(sender, e, AsusFan.XGM);
chartXGM.MouseUp += ChartCPU_MouseUp;

chartCPU.MouseClick += ChartCPU_MouseClick;
chartGPU.MouseClick += ChartCPU_MouseClick;
chartMid.MouseClick += ChartCPU_MouseClick;
chartXGM.MouseClick += ChartCPU_MouseClick;

buttonReset.Click += ButtonReset_Click;

trackA0.Maximum = AsusACPI.MaxTotal;
Expand Down Expand Up @@ -195,6 +201,24 @@ public Fans()

}

private void ChartCPU_MouseClick(object? sender, MouseEventArgs e)
{
if (sender is null) return;
Chart chart = (Chart)sender;

HitTestResult result = chart.HitTest(e.X, e.Y);

if ((result.ChartElementType == ChartElementType.AxisLabels || result.ChartElementType == ChartElementType.Axis) && result.Axis == chart.ChartAreas[0].AxisY)
{
fanRpm = !fanRpm;
SetAxis(chartCPU, AsusFan.CPU);
SetAxis(chartGPU, AsusFan.GPU);
if (chartMid.Visible) SetAxis(chartMid, AsusFan.Mid);
if (chartXGM.Visible) SetAxis(chartXGM, AsusFan.XGM);
}

}

private void Fans_FormClosed(object? sender, FormClosedEventArgs e)
{
//Because windows charts seem to eat a lot of memory :(
Expand Down Expand Up @@ -548,7 +572,24 @@ static string ChartPercToRPM(int percentage, AsusFan device, string unit = "")
int Max = MaxRPM;
if (device == AsusFan.XGM) Max = 72;

return (200 * Math.Round((float)(MinRPM * 100 + (Max - MinRPM) * percentage) / 200)).ToString() + unit;
if (fanRpm)
return (200 * Math.Round((float)(MinRPM * 100 + (Max - MinRPM) * percentage) / 200)).ToString() + unit;
else
return percentage + "%";
}

void SetAxis(Chart chart, AsusFan device)
{

chart.ChartAreas[0].AxisY.CustomLabels.Clear();

for (int i = 0; i <= fansMax - 10; i += 10)
{
chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i, device));
}

chart.ChartAreas[0].AxisY.CustomLabels.Add(fansMax - 2, fansMax + 2, Properties.Strings.RPM);
chart.ChartAreas[0].AxisY.Interval = 10;
}

void SetChart(Chart chart, AsusFan device)
Expand Down Expand Up @@ -588,12 +629,7 @@ void SetChart(Chart chart, AsusFan device)
chart.ChartAreas[0].AxisX.LineColor = chartGrid;
chart.ChartAreas[0].AxisY.LineColor = chartGrid;

for (int i = 0; i <= fansMax - 10; i += 10)
chart.ChartAreas[0].AxisY.CustomLabels.Add(i - 2, i + 2, ChartPercToRPM(i, device));

chart.ChartAreas[0].AxisY.CustomLabels.Add(fansMax - 2, fansMax + 2, Properties.Strings.RPM);

chart.ChartAreas[0].AxisY.Interval = 10;
SetAxis(chart, device);

if (chart.Legends.Count > 0)
chart.Legends[0].Enabled = false;
Expand Down
16 changes: 13 additions & 3 deletions app/Input/InputDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,12 @@ public void RegisterKeys()
string actionM1 = AppConfig.GetString("m1");
string actionM2 = AppConfig.GetString("m2");

if (keyProfile != Keys.None) hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control, keyProfile);
if (keyProfile != Keys.None)
{
hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control, keyProfile);
hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control | ModifierKeys.Alt, keyProfile);
}

if (keyApp != Keys.None) hook.RegisterHotKey(ModifierKeys.Shift | ModifierKeys.Control, keyApp);

if (!AppConfig.Is("skip_hotkeys"))
Expand Down Expand Up @@ -280,6 +285,11 @@ public void KeyPressed(object sender, KeyPressedEventArgs e)
if (e.Key == Keys.F20) KeyProcess("m3");
}

if (e.Modifier == (ModifierKeys.Control | ModifierKeys.Shift | ModifierKeys.Alt))
{
if (e.Key == keyProfile) modeControl.CyclePerformanceMode(true);
}

if (e.Modifier == (ModifierKeys.Control))
{
switch (e.Key)
Expand Down Expand Up @@ -354,7 +364,7 @@ public static void KeyProcess(string name = "m3")
Program.settingsForm.BeginInvoke(Program.settingsForm.CycleAuraMode);
break;
case "performance":
modeControl.CyclePerformanceMode();
modeControl.CyclePerformanceMode(Control.ModifierKeys == Keys.Shift);
break;
case "ghelper":
Program.settingsForm.BeginInvoke(delegate
Expand Down Expand Up @@ -470,7 +480,7 @@ static void HandleEvent(int EventID)
KeyProcess("fne");
return;
case 174: // FN+F5
modeControl.CyclePerformanceMode();
modeControl.CyclePerformanceMode(Control.ModifierKeys == Keys.Shift);
return;
case 179: // FN+F4
case 178: // FN+F4
Expand Down
4 changes: 2 additions & 2 deletions app/Mode/ModeControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ public void SetPerformanceMode(int mode = -1, bool notify = false)
}


public void CyclePerformanceMode()
public void CyclePerformanceMode(bool back = false)
{
SetPerformanceMode(Modes.GetNext(Control.ModifierKeys == Keys.Shift), true);
SetPerformanceMode(Modes.GetNext(back), true);
}

public void AutoFans(bool force = false)
Expand Down

0 comments on commit 47f86d2

Please sign in to comment.