PowerControl: Apply profile changes in bulk

This commit is contained in:
Kamil Trzciński 2023-01-21 13:25:06 +01:00
parent b7d7ad677e
commit 4bcefc703e
4 changed files with 64 additions and 37 deletions

View file

@ -49,7 +49,7 @@ namespace PowerControl.Menu
if (resetOption == null || resetOption == ActiveOption)
return;
Set(resetOption, 0);
Set(resetOption, true, false);
}
public override void Update()
@ -81,7 +81,7 @@ namespace PowerControl.Menu
ActiveOption = Options.First();
}
public void Set(String value, int overrideDelay = -1, bool refresh = true)
public void Set(String value, bool immediate, bool refresh)
{
if (delayTimer != null)
delayTimer.Stop();
@ -89,13 +89,13 @@ namespace PowerControl.Menu
SelectedOption = value;
runAfterApply = refresh;
if (ApplyDelay == 0 || overrideDelay == 0)
if (ApplyDelay == 0 || immediate)
{
FinalizeSet();
return;
}
delayTimer.Interval = overrideDelay > 0 ? overrideDelay : ApplyDelay > 0 ? ApplyDelay : 1;
delayTimer.Interval = ApplyDelay > 0 ? ApplyDelay : 1;
delayTimer.Enabled = true;
}
@ -141,7 +141,7 @@ namespace PowerControl.Menu
{
var item = new ToolStripMenuItem(option);
item.Checked = option == (SelectedOption ?? ActiveOption);
item.Click += delegate { Set(option, 0); };
item.Click += delegate { Set(option, true, true); };
toolStripItem.DropDownItems.Add(item);
}
@ -154,7 +154,7 @@ namespace PowerControl.Menu
if (Options.Count == 0)
return;
Set(Options[Math.Clamp(index, 0, Options.Count - 1)]);
Set(Options[Math.Clamp(index, 0, Options.Count - 1)], false, true);
}
public override void SelectNext(int change)