using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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 multi channel real-time graph item.
///
///
[TechItem(5)]
public class MultiGraphItem : 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 MultiGraphElementEditor 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 MultiGraphItem() : base()
{
Max = 100;
Name = "Multi Channel Graph";
Description = "Multi channel real-time graph";
Image = ResourceHelper.GetImageFromResources("Images/multi-graph.png");
ClearCommand = new RelayCommand(() =>
{
if (Editor != null)
{
Editor.InnerGraph.Controller.Clear();
}
});
}
///
/// Initializes a new instance of the class.
///
/// The db tech monitor.
public MultiGraphItem(TechMonitor techMonitor) : this()
{
TechMonitor = techMonitor;
}
///
/// Clones this instance.
///
///
public override TechItem Clone()
{
MultiGraphItem cloned = base.Clone() as MultiGraphItem;
cloned.TechMonitor = TechMonitor;
cloned.Min = Min;
cloned.Max = Max;
cloned.UseMinMax = UseMinMax;
cloned.UseAutoRange = UseAutoRange;
return cloned;
}
}
}