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.Core.Commands;
using Tango.BL.Entities;
using Tango.SharedUI.Helpers;
using System.Collections.ObjectModel;
namespace Tango.MachineStudio.Technician.TechItems
{
///
/// Represents a SpeedSensor controller item.
///
///
[TechItem(15, false)]
public class SpeedSensorItem : TechItem
{
private static List _SpeedSensorConfigurations;
///
/// Gets or sets the SpeedSensor configurations.
///
public static List SpeedSensorConfigurations
{
get { return _SpeedSensorConfigurations; }
set { _SpeedSensorConfigurations = value; }
}
static SpeedSensorItem()
{
SpeedSensorConfigurations = new List();
foreach (var SpeedSensorType in BL.ObservablesStaticCollections.Instance.HardwareSpeedSensorTypes)
{
SpeedSensorConfigurations.Add(new HardwareSpeedSensor() { HardwareSpeedSensorType = SpeedSensorType });
}
}
private HardwareSpeedSensorType _hardwareSpeedSensorType;
///
/// Gets or sets the type of the hardware SpeedSensor.
///
[XmlIgnore]
public HardwareSpeedSensorType HardwareSpeedSensorType
{
get { return _hardwareSpeedSensorType; }
set
{
_hardwareSpeedSensorType = value; RaisePropertyChangedAuto(); TechName = _hardwareSpeedSensorType != null ? _hardwareSpeedSensorType.Description : null; ItemGuid = value != null ? value.Guid : null;
if (_hardwareSpeedSensorType != null)
{
HardwareSpeedSensor = SpeedSensorConfigurations.SingleOrDefault(x => x.HardwareSpeedSensorType == _hardwareSpeedSensorType);
}
}
}
private HardwareSpeedSensor _hardwareSpeedSensor;
///
/// Gets or sets the hardware SpeedSensor.
///
[XmlIgnore]
public HardwareSpeedSensor HardwareSpeedSensor
{
get { return _hardwareSpeedSensor; }
set { _hardwareSpeedSensor = value; RaisePropertyChangedAuto(); }
}
///
/// Initializes a new instance of the class.
///
public SpeedSensorItem() : base()
{
Name = "Speed Sensor";
Description = "Speed Sensor Controller";
Image = ResourceHelper.GetImageFromResources("Images/speed.png");
Color = Colors.White;
HardwareSpeedSensor = new HardwareSpeedSensor();
}
///
/// Initializes a new instance of the class.
///
/// Type of the SpeedSensor.
public SpeedSensorItem(HardwareSpeedSensorType SpeedSensorType) : this()
{
HardwareSpeedSensorType = SpeedSensorType;
}
///
/// Clones this instance.
///
///
public override TechItem Clone()
{
SpeedSensorItem cloned = base.Clone() as SpeedSensorItem;
cloned.HardwareSpeedSensorType = HardwareSpeedSensorType;
return cloned;
}
}
}