using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using System.Xml.Serialization;
using Tango.BL.Entities;
using Tango.SharedUI.Helpers;
namespace Tango.MachineStudio.Technician.TechItems
{
///
/// Represents an analog style VU meter item.
///
///
[TechItem(3, true)]
public class MeterItem : TechItem
{
private TechMonitor _techMonitor;
///
/// Gets or sets the db tech monitor.
///
[XmlIgnore]
public TechMonitor TechMonitor
{
get { return _techMonitor; }
set { _techMonitor = value; RaisePropertyChangedAuto(); TechName = _techMonitor != null ? _techMonitor.Description : null; ItemGuid = value != null ? value.Guid : null; }
}
private double _value;
///
/// Gets or sets the current value.
///
[XmlIgnore]
public double Value
{
get { return _value; }
set { _value = value; RaisePropertyChanged(nameof(Value)); LastUpdateTime = DateTime.Now; }
}
private int _updateInterval;
///
/// Gets or sets the minimum update interval.
///
public int UpdateInterval
{
get { return _updateInterval; }
set { _updateInterval = value; RaisePropertyChangedAuto(); }
}
private int _ledCount;
///
/// Gets or sets the amount of LED's.
///
public int LedCount
{
get { return _ledCount; }
set { _ledCount = value; RaisePropertyChangedAuto(); }
}
private int _ticksCount;
///
/// Gets or sets the amount of meter ticks.
///
public int TicksCount
{
get { return _ticksCount; }
set { _ticksCount = value; RaisePropertyChangedAuto(); }
}
private TickPlacement _tickPlacement;
///
/// Gets or sets the ticks placement.
///
public TickPlacement TickPlacement
{
get { return _tickPlacement; }
set { _tickPlacement = value; RaisePropertyChangedAuto(); }
}
///
/// Gets or sets the last update time.
///
[XmlIgnore]
public DateTime LastUpdateTime { get; set; }
///
/// Initializes a new instance of the class.
///
public MeterItem() : base()
{
Name = "VU Monitor";
Description = "VU Meter monitor";
Image = ResourceHelper.GetImageFromResources("Images/volume.png");
LastUpdateTime = DateTime.Now;
UpdateInterval = 10;
LedCount = 14;
TicksCount = 14;
TickPlacement = TickPlacement.BottomRight;
Color = Colors.DimGray;
}
///
/// Initializes a new instance of the class.
///
/// The db tech monitor.
public MeterItem(TechMonitor techMonitor) : this()
{
TechMonitor = techMonitor;
}
///
/// Clones this instance.
///
///
public override TechItem Clone()
{
MeterItem cloned = base.Clone() as MeterItem;
cloned.TechMonitor = TechMonitor;
cloned.UpdateInterval = UpdateInterval;
cloned.LedCount = LedCount;
cloned.TicksCount = TicksCount;
return cloned;
}
}
}