aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Technician/TechItems/SingleGraphItem.cs
blob: 1efcd93a8dc8a17bd89f42f00e4131e37fd1dbc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using Tango.Integration.Observables;
using Tango.MachineStudio.Technician.Editors;
using Tango.SharedUI.Helpers;

namespace Tango.MachineStudio.Technician.TechItems
{
    public class SingleGraphItem : TechItem
    {
        private TechMonitor _techMonitor;
        [XmlIgnore]
        public TechMonitor TechMonitor
        {
            get { return _techMonitor; }
            set
            {
                TechMonitor old = _techMonitor;

                _techMonitor = value;
                RaisePropertyChangedAuto();

                if (_techMonitor != old && Editor != null)
                {
                    Editor.InnerGraph.InnerGraph.MaxPoints = Common.Helpers.GraphsHelper.GetMaxPoints(TechMonitor.PointsPerFrame);
                    Editor.InnerGraph.InvalidateGraph();
                }

                ItemGuid = value != null ? value.Guid : null;
                TechName = _techMonitor != null ? _techMonitor.Description : null;
            }
        }

        [XmlIgnore]
        public SingleGraphElementEditor Editor { get; set; }

        public SingleGraphItem() : base()
        {
            Name = "Single Channel Graph";
            Description = "Single channel real-time graph";
            Image = ResourceHelper.GetImageFromResources("Images/single-graph.png");
        }

        public SingleGraphItem(TechMonitor techMonitor) : this()
        {
            TechMonitor = techMonitor;
        }

        public override TechItem Clone()
        {
            SingleGraphItem cloned = base.Clone() as SingleGraphItem;
            cloned.TechMonitor = TechMonitor;
            return cloned;
        }
    }
}