mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-04-06 23:03:59 +00:00
PowerControl: Provide ValueChanged event
This commit is contained in:
parent
f6dbf3c199
commit
49b94e274c
3 changed files with 35 additions and 0 deletions
|
|
@ -6,11 +6,14 @@ namespace PowerControl.Menu
|
|||
{
|
||||
public IList<MenuItem> Items { get; } = new List<MenuItem>();
|
||||
public MenuItem? Selected;
|
||||
|
||||
public event Action VisibleChanged;
|
||||
public event Action<MenuItemWithOptions, String?, String> ValueChanged;
|
||||
|
||||
public MenuRoot()
|
||||
{
|
||||
VisibleChanged += delegate { };
|
||||
ValueChanged += delegate { };
|
||||
}
|
||||
|
||||
public MenuItem? this[String name]
|
||||
|
|
@ -26,12 +29,34 @@ namespace PowerControl.Menu
|
|||
}
|
||||
}
|
||||
|
||||
public IEnumerable<MenuItemWithOptions> AllMenuItemOptions()
|
||||
{
|
||||
foreach (var item in Items)
|
||||
{
|
||||
if (item is MenuItemWithOptions)
|
||||
yield return (MenuItemWithOptions)item;
|
||||
}
|
||||
}
|
||||
|
||||
public override void CreateMenu(System.Windows.Forms.ContextMenuStrip contextMenu)
|
||||
{
|
||||
foreach (var item in Items)
|
||||
item.CreateMenu(contextMenu);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
foreach (var item in AllMenuItemOptions())
|
||||
{
|
||||
item.ValueChanged += MenuItem_ValueChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void MenuItem_ValueChanged(MenuItemWithOptions item, String? was, String isNow)
|
||||
{
|
||||
ValueChanged(item, was, isNow);
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
foreach (var item in Items)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue