using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Media; using System.Xml.Serialization; using Tango.BL; using Tango.BL.Entities; using Tango.Core.Commands; using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.Technician.TechItems { /// /// Represents a Blower controller item. /// /// [TechItem(16, true)] public class BlowerItem : TechItem { public event EventHandler SetCommandClicked; private static List _BlowerConfigurations; /// /// Gets or sets the Blower configurations. /// public static List BlowerConfigurations { get { return _BlowerConfigurations; } set { _BlowerConfigurations = value; } } static BlowerItem() { BlowerConfigurations = new List(); foreach (var BlowerType in ObservablesStaticCollections.Instance.HardwareBlowerTypes) { BlowerConfigurations.Add(new HardwareBlower() { HardwareBlowerType = BlowerType }); } } private HardwareBlowerType _hardwareBlowerType; /// /// Gets or sets the type of the hardware Blower. /// [XmlIgnore] public HardwareBlowerType HardwareBlowerType { get { return _hardwareBlowerType; } set { _hardwareBlowerType = value; RaisePropertyChangedAuto(); TechName = _hardwareBlowerType != null ? _hardwareBlowerType.Description : null; ItemGuid = value != null ? value.Guid : null; if (_hardwareBlowerType != null) { HardwareBlower = BlowerConfigurations.SingleOrDefault(x => x.HardwareBlowerType == _hardwareBlowerType); } } } private HardwareBlower _hardwareBlower; /// /// Gets or sets the hardware Blower. /// [XmlIgnore] public HardwareBlower HardwareBlower { get { return _hardwareBlower; } set { _hardwareBlower = value; RaisePropertyChangedAuto(); } } private bool _isActive; [XmlIgnore] public bool IsActive { get { return _isActive; } set { _isActive = value; RaisePropertyChangedAuto(); } } private bool _effectiveActive; [XmlIgnore] public bool EffectiveActive { get { return _effectiveActive; } set { _effectiveActive = value; RaisePropertyChangedAuto(); IsActive = _effectiveActive; } } /// /// Gets or sets the set command. /// [XmlIgnore] public RelayCommand SetCommand { get; set; } [XmlIgnore] public RelayCommand ToggleActiveCommand { get; set; } /// /// Initializes a new instance of the class. /// public BlowerItem() : base() { Name = "Blower"; Description = "Blower Controller"; Image = ResourceHelper.GetImageFromResources("Images/blower.png"); Color = Colors.White; HardwareBlower = new HardwareBlower(); SetCommand = new RelayCommand(() => { SetCommandClicked?.Invoke(this, _isActive); }); ToggleActiveCommand = new RelayCommand(() => { SetCommandClicked?.Invoke(this, _isActive); }); } /// /// Initializes a new instance of the class. /// /// Type of the Blower. public BlowerItem(HardwareBlowerType BlowerType) : this() { HardwareBlowerType = BlowerType; } /// /// Clones this instance. /// /// public override TechItem Clone() { BlowerItem cloned = base.Clone() as BlowerItem; cloned.HardwareBlowerType = HardwareBlowerType; return cloned; } } }