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;
        }
    }
}
uot; Width="24" Foreground="Gray"></fa:ImageAwesome> </Button> </StackPanel> </StackPanel> </Grid> <Button Margin="20 10" Grid.Row="1" Width="160" Height="40" HorizontalAlignment="Left" Command="{Binding CompareCommand}"> <StackPanel Orientation="Horizontal"> <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">COMPARE</TextBlock> <fa:ImageAwesome Icon="LongArrowRight" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome> </StackPanel> </Button> <Grid Grid.Column="1"> <Grid.RowDefinitions> <RowDefinition Height="20"/> <RowDefinition Height="205*"/> </Grid.RowDefinitions> <TextBlock Margin="10 5 0 0" FontSize="14">Differences</TextBlock> <ListBox Margin="10" Background="#F1F1F1" Grid.Row="1" ItemsSource="{Binding Differences}" SelectedItem="{Binding SelectedDifference,Mode=TwoWay}"> <ListBox.ItemTemplate> <DataTemplate> <Border Padding="10"> <StackPanel Orientation="Horizontal"> <fa:ImageAwesome Icon="Cog" Width="20" Height="20" Foreground="Gray"></fa:ImageAwesome> <TextBlock VerticalAlignment="Center" Margin="10 0 0 0" Text="{Binding Description}"> <TextBlock.Style> <Style TargetType="TextBlock"> <Setter Property="Foreground" Value="Red"></Setter> <Style.Triggers> <DataTrigger Binding="{Binding Action}" Value="ReplaceTableDataInSlave"> <Setter Property="Foreground" Value="#404040"></Setter> </DataTrigger> </Style.Triggers> </Style> </TextBlock.Style> </TextBlock> </StackPanel> </Border> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid> <Grid Grid.Row="1" Grid.Column="1"> <StackPanel Orientation="Horizontal" HorizontalAlignment="Right"> <Button Margin="10 10" Grid.Row="1" Width="240" Height="40" Background="#FF4F4F" BorderBrush="#FF4F4F" HorizontalAlignment="Right" Command="{Binding CleanCommand}"> <StackPanel Orientation="Horizontal"> <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">CLEAN SQLITE DATABASE</TextBlock> <fa:ImageAwesome Icon="TrashOutline" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome> </StackPanel> </Button> <Button Margin="10 10" Grid.Row="1" Width="160" Height="40" HorizontalAlignment="Right" Command="{Binding CommitCommand}"> <StackPanel Orientation="Horizontal"> <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">COMMIT</TextBlock> <fa:ImageAwesome Icon="Bolt" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome> </StackPanel> </Button> <Button Margin="10 10" Grid.Row="1" Width="160" Height="40" HorizontalAlignment="Right" Command="{Binding CommitAllCommand}"> <StackPanel Orientation="Horizontal"> <TextBlock VerticalAlignment="Center" Margin="10 0 10 0">COMMIT ALL</TextBlock> <fa:ImageAwesome Icon="SortAmountAsc" VerticalAlignment="Center" Foreground="{Binding RelativeSource={RelativeSource AncestorType=Button},Path=Foreground}" Width="16"></fa:ImageAwesome> </StackPanel> </Button> </StackPanel> </Grid> </Grid> </GroupBox> </Grid> </Grid> </Grid> </UserControl>