aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.RML/ViewModels/CalibrationDataVM.cs
blob: 403494a8ebf64e491202978d5c1ed93b1c8ffce6 (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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.Core;
using Tango.SharedUI;

namespace Tango.MachineStudio.RML.ViewModels
{
    public class CalibrationDataVM : ExtendedObject
    {
        private LiquidType _liquidType;

        public LiquidType LiquidType
        {
            get { return _liquidType; }
            set { _liquidType = value; RaisePropertyChangedAuto(); }
        }

        private IdsPack _idsPack;

        public IdsPack IdsPack
        {
            get { return _idsPack; }
            set { _idsPack = value; RaisePropertyChangedAuto(); }
        }

        private ObservableCollection<CalibrationDataPointVM> _calibrationPoints;

        public ObservableCollection<CalibrationDataPointVM> CalibrationPoints
        {
            get { return _calibrationPoints; }
            set { _calibrationPoints = value; RaisePropertyChangedAuto(); OnCalibrationPointsChanged(); }
        }

        private void OnCalibrationPointsChanged()
        {
            if (CalibrationPoints != null)
            {
                CalibrationPoints.CollectionChanged -= CalibrationPoints_CollectionChanged;
                CalibrationPoints.CollectionChanged += CalibrationPoints_CollectionChanged;

                SetIndices();
            }
        }

        private void CalibrationPoints_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
        {
            SetIndices();
        }

        private void SetIndices()
        {
            if (CalibrationPoints != null)
            {
                int index = 1;
                foreach (var p in CalibrationPoints)
                {
                    p.Index = index++;
                }
            }
        }

        private CalibrationDataVM()
        {
            CalibrationPoints = new ObservableCollection<CalibrationDataPointVM>();
        }

        public CalibrationDataVM(IdsPack pack) : this()
        {
            IdsPack = pack;
            LiquidType = pack.LiquidType;
        }

        public CalibrationDataVM(LiquidType liquidType) : this()
        {
            LiquidType = liquidType;
        }
    }
}
/span>,NULL /* reserved1,reserved2, etc */ }, { "", 2, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ offsetof(StartThreadLoadingResponse, errorreason), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { "", 3, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_DOUBLE, offsetof(StartThreadLoadingResponse, has_progresspercentage), offsetof(StartThreadLoadingResponse, progresspercentage), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, { "", 4, PROTOBUF_C_LABEL_OPTIONAL, PROTOBUF_C_TYPE_STRING, 0, /* quantifier_offset */ offsetof(StartThreadLoadingResponse, message), NULL, NULL, 0, /* flags */ 0,NULL,NULL /* reserved1,reserved2, etc */ }, }; static const unsigned start_thread_loading_response__field_indices_by_name[] = { 1, /* field[1] = ErrorReason */ 3, /* field[3] = Message */ 2, /* field[2] = ProgressPercentage */ 0, /* field[0] = State */ }; static const ProtobufCIntRange start_thread_loading_response__number_ranges[1 + 1] = { { 1, 0 }, { 0, 4 } }; const ProtobufCMessageDescriptor start_thread_loading_response__descriptor = { PROTOBUF_C__MESSAGE_DESCRIPTOR_MAGIC, "", "", "", "", sizeof(StartThreadLoadingResponse), 4, start_thread_loading_response__field_descriptors, start_thread_loading_response__field_indices_by_name, 1, start_thread_loading_response__number_ranges, (ProtobufCMessageInit) start_thread_loading_response__init, NULL,NULL,NULL /* reserved[123] */ };