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.SharedUI.Helpers;
namespace Tango.MachineStudio.Technician.TechItems
{
///
/// Represents a BreakSensor controller item.
///
///
[TechItem(17, false)]
public class BreakSensorItem : TechItem
{
private static List _BreakSensorConfigurations;
///
/// Gets or sets the BreakSensor configurations.
///
public static List BreakSensorConfigurations
{
get { return _BreakSensorConfigurations; }
set { _BreakSensorConfigurations = value; }
}
static BreakSensorItem()
{
BreakSensorConfigurations = new List();
foreach (var BreakSensorType in ObservablesStaticCollections.Instance.HardwareBreakSensorTypes)
{
BreakSensorConfigurations.Add(new HardwareBreakSensor() { HardwareBreakSensorType = BreakSensorType });
}
}
private HardwareBreakSensorType _hardwareBreakSensorType;
///
/// Gets or sets the type of the hardware BreakSensor.
///
[XmlIgnore]
public HardwareBreakSensorType HardwareBreakSensorType
{
get { return _hardwareBreakSensorType; }
set
{
_hardwareBreakSensorType = value; RaisePropertyChangedAuto(); TechName = _hardwareBreakSensorType != null ? _hardwareBreakSensorType.Description : null; ItemGuid = value != null ? value.Guid : null;
if (_hardwareBreakSensorType != null)
{
HardwareBreakSensor = BreakSensorConfigurations.SingleOrDefault(x => x.HardwareBreakSensorType == _hardwareBreakSensorType);
}
}
}
private HardwareBreakSensor _hardwareBreakSensor;
///
/// Gets or sets the hardware BreakSensor.
///
[XmlIgnore]
public HardwareBreakSensor HardwareBreakSensor
{
get { return _hardwareBreakSensor; }
set { _hardwareBreakSensor = value; RaisePropertyChangedAuto(); }
}
///
/// Initializes a new instance of the class.
///
public BreakSensorItem() : base()
{
Name = "Break Sensor";
Description = "Break Sensor Controller";
Image = ResourceHelper.GetImageFromResources("Images/break.png");
Color = Colors.White;
HardwareBreakSensor = new HardwareBreakSensor();
}
///
/// Initializes a new instance of the class.
///
/// Type of the BreakSensor.
public BreakSensorItem(HardwareBreakSensorType BreakSensorType) : this()
{
HardwareBreakSensorType = BreakSensorType;
}
///
/// Clones this instance.
///
///
public override TechItem Clone()
{
BreakSensorItem cloned = base.Clone() as BreakSensorItem;
cloned.HardwareBreakSensorType = HardwareBreakSensorType;
return cloned;
}
}
}