Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom fan curves in tray icon menu #3032

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/Fans.cs
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,7 @@ private void FillModes()
comboModes.DataSource = new BindingSource(Modes.GetDictonary(), null);
comboModes.DisplayMember = "Value";
comboModes.ValueMember = "Key";
Program.settingsForm.SetContextMenu();
}

private void ButtonAdd_Click(object? sender, EventArgs e)
Expand Down
12 changes: 12 additions & 0 deletions app/Mode/Modes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,18 @@ public static Dictionary<int, string> GetDictonary()

return modes;
}

public static Dictionary<int, string> GetDictionaryCustom()
{
Dictionary<int, string> modes = new Dictionary<int, string>();

for (int i = 3; i < maxModes; i++)
{
if (Exists(i)) modes.Add(i, GetName(i));
}

return modes;
}

public static List<int> GetList()
{
Expand Down
22 changes: 22 additions & 0 deletions app/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public partial class SettingsForm : RForm
{
ContextMenuStrip contextMenuStrip = new CustomContextMenu();
ToolStripMenuItem menuSilent, menuBalanced, menuTurbo, menuEco, menuStandard, menuUltimate, menuOptimized;
Dictionary<int, ToolStripMenuItem> menuModesCustom = new ();


public GPUModeControl gpuControl;
public AllyControl allyControl;
Expand Down Expand Up @@ -732,6 +734,20 @@ public void SetContextMenu()
menuTurbo.Checked = (mode == AsusACPI.PerformanceTurbo);
contextMenuStrip.Items.Add(menuTurbo);

if (Modes.GetDictionaryCustom().Count > 0)
contextMenuStrip.Items.Add("-");

menuModesCustom.Clear();
foreach (var (modeIdx, name) in Modes.GetDictionaryCustom())
{
var menuCustom = new ToolStripMenuItem(name);
menuCustom.Click += (sender, args) => { Program.modeControl.SetPerformanceMode(modeIdx); };
menuCustom.Margin = padding;
menuCustom.Checked = (modeIdx == Modes.GetCurrent());
menuModesCustom.Add(modeIdx, menuCustom);
contextMenuStrip.Items.Add(menuCustom);
}

contextMenuStrip.Items.Add("-");

if (isGpuSection)
Expand Down Expand Up @@ -1474,6 +1490,10 @@ protected void VisualiseMode(int mode)
menuSilent.Checked = false;
menuBalanced.Checked = false;
menuTurbo.Checked = false;
foreach (var (key, value) in menuModesCustom)
{
value.Checked = false;
}

switch (mode)
{
Expand All @@ -1490,6 +1510,8 @@ protected void VisualiseMode(int mode)
menuBalanced.Checked = true;
break;
default:
if (menuModesCustom.TryGetValue(mode, out var value))
value.Checked = true;
buttonFans.Activated = true;
buttonFans.BorderColor = Modes.GetBase(mode) switch
{
Expand Down