using System;
using System.Collections.Generic;
using PepperDash.Essentials.Core.DeviceTypeInterfaces;
namespace PepperDash.Essentials.Devices.Common.Displays
{
///
/// Represents a MockDisplayInputs
///
public class MockDisplayInputs : ISelectableItems
{
private Dictionary _items;
///
/// Gets or sets the collection of selectable items
///
public Dictionary Items
{
get
{
return _items;
}
set
{
if (_items == value)
return;
_items = value;
ItemsUpdated?.Invoke(this, null);
}
}
private string _currentItem;
///
/// Gets or sets the currently selected item
///
public string CurrentItem
{
get
{
return _currentItem;
}
set
{
if (_currentItem == value)
return;
_currentItem = value;
CurrentItemChanged?.Invoke(this, null);
}
}
///
/// Occurs when the items collection is updated
///
public event EventHandler ItemsUpdated;
///
/// Occurs when the current item changes
///
public event EventHandler CurrentItemChanged;
}
///
/// Represents a MockDisplayInput
///
public class MockDisplayInput : ISelectableItem
{
private MockDisplay _parent;
private bool _isSelected;
///
/// Gets or sets a value indicating whether this input is selected
///
public bool IsSelected
{
get
{
return _isSelected;
}
set
{
if (_isSelected == value)
return;
_isSelected = value;
ItemUpdated?.Invoke(this, null);
}
}
///
/// Gets or sets the Name
///
public string Name { get; set; }
///
/// Gets or sets the Key
///
public string Key { get; set; }
///
/// Occurs when this item is updated
///
public event EventHandler ItemUpdated;
///
/// Initializes a new instance of the MockDisplayInput class
///
/// The input key
/// The input name
/// The parent mock display
public MockDisplayInput(string key, string name, MockDisplay parent)
{
Key = key;
Name = name;
_parent = parent;
}
///
/// Select method
///
public void Select()
{
if (!_parent.PowerIsOnFeedback.BoolValue) _parent.PowerOn();
foreach (var input in _parent.Inputs.Items)
{
input.Value.IsSelected = input.Key == this.Key;
}
}
}
}