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.Entities; using Tango.Core.Commands; using Tango.MachineStudio.Technician.Editors; using Tango.MachineStudio.Technician.Helpers; using Tango.SharedUI.Helpers; namespace Tango.MachineStudio.Technician.TechItems { /// /// Represents a single channel real-time graph item. /// /// [TechItem(4)] public class SingleGraphItem : TechItem { private TechMonitor _techMonitor; /// /// Gets or sets the db tech monitor. /// [XmlIgnore] public TechMonitor TechMonitor { get { return _techMonitor; } set { TechMonitor old = _techMonitor; _techMonitor = value; RaisePropertyChangedAuto(); if (_techMonitor != old && Editor != null) { Editor.InnerGraph.InnerGraph.MaxPoints = GraphsHelper.GetMaxPoints(TechMonitor.PointsPerFrame); Editor.InnerGraph.InvalidateGraph(); } ItemGuid = value != null ? value.Guid : null; TechName = _techMonitor != null ? _techMonitor.Description : null; } } /// /// Gets or sets the item editor. /// [XmlIgnore] public SingleGraphElementEditor Editor { get; set; } private double _min; /// /// Gets or sets the minimum graph value. /// public double Min { get { return _min; } set { _min = value; RaisePropertyChangedAuto(); } } private double _max; /// /// Gets or sets the maximum graph value. /// public double Max { get { return _max; } set { _max = value; RaisePropertyChangedAuto(); } } private bool _useMinMax; /// /// Gets or sets a value indicating whether [use minimum maximum]. /// public bool UseMinMax { get { return _useMinMax; } set { _useMinMax = value; RaisePropertyChangedAuto(); } } private bool _useAutoRange; /// /// Gets or sets a value indicating whether [use automatic range]. /// public bool UseAutoRange { get { return _useAutoRange; } set { _useAutoRange = value; RaisePropertyChangedAuto(); } } private bool _isPaused; /// /// Gets or sets a value indicating whether this instance is paused. /// [XmlIgnore] public bool IsPaused { get { return _isPaused; } set { _isPaused = value; RaisePropertyChangedAuto(); if (Editor != null) { Editor.InnerGraph.Controller.IsPaused = _isPaused; } } } [XmlIgnore] public RelayCommand ClearCommand { get; set; } /// /// Initializes a new instance of the class. /// public SingleGraphItem() : base() { Max = 100; Name = "Single Channel Graph"; Description = "Single channel real-time graph"; Image = ResourceHelper.GetImageFromResources("Images/single-graph.png"); Color = Colors.DodgerBlue; ClearCommand = new RelayCommand(() => { if (Editor != null) { Editor.InnerGraph.Controller.Clear(); } }); } /// /// Initializes a new instance of the class. /// /// The db tech monitor. public SingleGraphItem(TechMonitor techMonitor) : this() { TechMonitor = techMonitor; } /// /// Clones this instance. /// /// public override TechItem Clone() { SingleGraphItem cloned = base.Clone() as SingleGraphItem; cloned.TechMonitor = TechMonitor; cloned.Min = Min; cloned.Max = Max; cloned.UseMinMax = UseMinMax; cloned.UseAutoRange = UseAutoRange; return cloned; } } }