fix: better implmentation of input select

This commit is contained in:
Neil Dorin
2024-05-10 13:16:59 -06:00
parent 8878ff7ddd
commit a11ad421f0
2 changed files with 11 additions and 32 deletions

View File

@@ -121,7 +121,7 @@ namespace PepperDash.Essentials.Devices.Common.Displays
// Fake cool-down cycle
CooldownTimer = new CTimer(o =>
{
Debug.LogMessage(LogEventLevel.Verbose, this, "Cooldown timer ending");
Debug.LogMessage(LogEventLevel.Verbose, "Cooldown timer ending", this);
_IsCoolingDown = false;
IsCoolingDownFeedback.InvokeFireUpdate();
_PowerIsOn = false;
@@ -142,10 +142,10 @@ namespace PepperDash.Essentials.Devices.Common.Displays
{
Debug.LogMessage(LogEventLevel.Verbose, this, "ExecuteSwitch: {0}", selector);
if (!_PowerIsOn)
{
PowerOn();
}
if (!_PowerIsOn)
{
PowerOn();
}
if (!Inputs.Items.TryGetValue(selector.ToString(), out var input))
return;
@@ -153,32 +153,6 @@ namespace PepperDash.Essentials.Devices.Common.Displays
input.Select();
}
public void SetInput(string selector)
{
ISelectableItem currentInput = null;
try
{
currentInput = Inputs.Items.SingleOrDefault(Inputs => Inputs.Value.IsSelected).Value;
}
catch { }
if (currentInput != null)
{
Debug.LogMessage(LogEventLevel.Verbose, this, "SetInput: {0}", selector);
currentInput.IsSelected = false;
}
if (!Inputs.Items.TryGetValue(selector, out var input))
return;
input.IsSelected = true;
Inputs.CurrentItem = selector;
}
#region IBasicVolumeWithFeedback Members

View File

@@ -90,7 +90,12 @@ namespace PepperDash.Essentials.Devices.Common.Displays
public void Select()
{
_parent.SetInput(Key);
if (!_parent.PowerIsOnFeedback.BoolValue) _parent.PowerOn();
foreach(var input in _parent.Inputs.Items)
{
input.Value.IsSelected = input.Key == this.Key;
}
}
}
}