mirror of
https://github.com/ayufan/steam-deck-tools.git
synced 2026-01-25 18:00:27 +01:00
PowerControl: Improve nulls in MenuItems
This commit is contained in:
parent
06f2d9a702
commit
ebe1cdba87
|
|
@ -7,18 +7,18 @@ namespace PowerControl.Menu
|
|||
public delegate object ApplyValueDelegate(object selected);
|
||||
|
||||
public IList<Object> Options { get; set; } = new List<Object>();
|
||||
public Object SelectedOption { get; set; }
|
||||
public Object ActiveOption { get; set; }
|
||||
public Object? SelectedOption { get; set; }
|
||||
public Object? ActiveOption { get; set; }
|
||||
public int ApplyDelay { get; set; }
|
||||
public bool CycleOptions { get; set; } = true;
|
||||
|
||||
public CurrentValueDelegate CurrentValue { get; set; }
|
||||
public OptionsValueDelegate OptionsValues { get; set; }
|
||||
public ApplyValueDelegate ApplyValue { get; set; }
|
||||
public CurrentValueDelegate ResetValue { get; set; }
|
||||
public Func<object>? CurrentValue { get; set; }
|
||||
public Func<object[]>? OptionsValues { get; set; }
|
||||
public Func<object, object>? ApplyValue { get; set; }
|
||||
public Func<object>? ResetValue { get; set; }
|
||||
|
||||
private System.Windows.Forms.Timer delayTimer;
|
||||
private ToolStripMenuItem toolStripItem;
|
||||
private System.Windows.Forms.Timer delayTimer = new System.Windows.Forms.Timer();
|
||||
private ToolStripMenuItem toolStripItem = new ToolStripMenuItem();
|
||||
|
||||
public MenuItemWithOptions()
|
||||
{
|
||||
|
|
@ -85,7 +85,6 @@ namespace PowerControl.Menu
|
|||
return;
|
||||
}
|
||||
|
||||
delayTimer = new System.Windows.Forms.Timer();
|
||||
delayTimer.Interval = ApplyDelay > 0 ? ApplyDelay : 1;
|
||||
delayTimer.Tick += delegate (object? sender, EventArgs e)
|
||||
{
|
||||
|
|
@ -142,10 +141,6 @@ namespace PowerControl.Menu
|
|||
|
||||
public override void CreateMenu(ToolStripItemCollection collection)
|
||||
{
|
||||
if (toolStripItem != null)
|
||||
return;
|
||||
|
||||
toolStripItem = new ToolStripMenuItem();
|
||||
toolStripItem.Text = Name;
|
||||
updateOptions();
|
||||
collection.Add(toolStripItem);
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ namespace PowerControl.Menu
|
|||
{
|
||||
public class MenuRoot : MenuItem
|
||||
{
|
||||
public IList<MenuItem> Items { get; set; } = new List<MenuItem>();
|
||||
public IList<MenuItem> Items { get; } = new List<MenuItem>();
|
||||
public MenuItem? Selected;
|
||||
public event Action VisibleChanged;
|
||||
|
||||
|
|
@ -123,4 +123,4 @@ namespace PowerControl.Menu
|
|||
return Selected;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ namespace PowerControl.Menu
|
|||
{
|
||||
public class MenuItemSeparator : MenuItem
|
||||
{
|
||||
private ToolStripItem toolStripItem;
|
||||
private ToolStripItem toolStripItem = new ToolStripSeparator();
|
||||
|
||||
public MenuItemSeparator()
|
||||
{
|
||||
|
|
@ -11,10 +11,6 @@ namespace PowerControl.Menu
|
|||
|
||||
public override void CreateMenu(ToolStripItemCollection collection)
|
||||
{
|
||||
if (toolStripItem != null)
|
||||
return;
|
||||
|
||||
toolStripItem = new ToolStripSeparator();
|
||||
collection.Add(toolStripItem);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue