PowerControl: Decompose MenuStack.cs into Options/

This commit is contained in:
Kamil Trzciński 2022-12-19 22:47:10 +01:00
parent ebe1cdba87
commit f207c12935
18 changed files with 660 additions and 528 deletions

View file

@ -0,0 +1,32 @@
using CommonHelpers;
namespace PowerControl.Options
{
public static class FanControl
{
public static Menu.MenuItemWithOptions Instance = new Menu.MenuItemWithOptions()
{
Name = "FAN",
ApplyDelay = 500,
OptionsValues = delegate ()
{
return Enum.GetValues<FanMode>().Select(item => (object)item).ToArray();
},
CurrentValue = delegate ()
{
if (SharedData<FanModeSetting>.GetExistingValue(out var value))
return value.Current;
return null;
},
ApplyValue = delegate (object selected)
{
if (!SharedData<FanModeSetting>.GetExistingValue(out var value))
return null;
value.Desired = (FanMode)selected;
if (!SharedData<FanModeSetting>.SetExistingValue(value))
return null;
return selected;
}
};
}
}