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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
|
using ColorMine.ColorSpaces;
using LiteDB;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
using Tango.Core;
namespace Tango.PPC.Jobs.Models
{
public class TrialsLogModel: ExtendedObject
{
#region Properties
[BsonIgnore]
public String JobRunGuid { get; set; }
private int _trialNumber;
public int TrialNumber
{
get { return _trialNumber; }
set
{
_trialNumber = value;
RaisePropertyChangedAuto();
RaisePropertyChanged(nameof(Trial));
}
}
[BsonIgnore]
public string Trial {
get {
if(TrialNumber == 0)
return "T";
return TrialNumber.ToString();
}
}
//LAB
private double? _l;
public double? L
{
get { return _l; }
set { _l = value;
RaisePropertyChanged(nameof(LAB));
OnLABChanged();}
}
private double? _a;
public double? A
{
get { return _a; }
set { _a = value;
RaisePropertyChanged(nameof(LAB)); OnLABChanged(); }
}
private double? _b;
public double? B
{
get { return _b; }
set { _b = value; RaisePropertyChanged(nameof(LAB)); OnLABChanged(); }
}
public double VectorCorrectionL { get; set; }
public double VectorCorrectionA { get; set; }
public double VectorCorrectionB { get; set; }
public double LightnessOffset { get; set; }
public double ChromaOffset { get; set; }
public double HueOffset { get; set; }
public bool IsManualCorrection { get; set; }
//LCH
private double _LCH_C;
public double LCH_C
{
get { return _LCH_C; }
set {
_LCH_C = value;
//RaisePropertyChanged(nameof(LAB));
}
}
private double _h;
public double H
{
get { return _h; }
set { _h = value;
//RaisePropertyChanged(nameof(LAB));
}
}
public double dL { get; set; }
public double dC { get; set; }
public double dH { get; set; }
public bool CorrectOnlyHue { get; set; }
public double SuggestionL { get; set; }
public double SuggestionA { get; set; }
public double SuggestionB { get; set; }
public double C { get; set; }
public double M { get; set; }
public double Y { get; set; }
public double K { get; set; }
[BsonIgnore]
public string CMYK
{
get
{
return String.Format("{0:0.##},{1:0.##},{2:0.##},{3:0.##}", C, M, Y, K);
}
}
public double NewSuggestionL { get; set; }
public double NewSuggestionA { get; set; }
public double NewSuggestionB { get; set; }
private DateTime _date;
public DateTime Date
{
get { return _date; }
set { _date = value; RaisePropertyChangedAuto(); }
}
private double? _deltaE;
public double? DeltaE
{
get { return _deltaE; }
set { _deltaE = value;
RaisePropertyChangedAuto();
RaisePropertyChanged(nameof(DeltaEDisplay));
}
}
public string DeltaEDisplay
{
get
{
if (DeltaE == null)
return "";
// if (IsBest)
// return String.Format($"{DeltaE:0.##} Best");
return String.Format($"{DeltaE:0.##}");
}
}
private bool _IsActiveTrial;
[BsonIgnore]
public bool IsActiveTrial
{
get { return _IsActiveTrial; }
set { _IsActiveTrial = value;
RaisePropertyChangedAuto();
}
}
[BsonIgnore]
public string LAB
{
get {
if(!ValidationLAB())
return "";
return String.Format("{0:0.##},{1:0.##},{2:0.##}", L, A, B); }
}
private bool _istested;
public bool IsTested
{
get { return _istested; }
set
{
_istested = value;
if (_istested)
{
IsSelectionEnable = true;
}
}
}
private bool _isBest;
public bool IsBest
{
get { return _isBest; }
set { _isBest = value;
RaisePropertyChangedAuto();
RaisePropertyChanged(nameof(DeltaEDisplay));}
}
private bool _isSelectionEnable;
[BsonIgnore]
public bool IsSelectionEnable
{
get { return _isSelectionEnable; }
set { _isSelectionEnable = value;
RaisePropertyChangedAuto();
}
}
[BsonIgnore]
public System.Windows.Media.Color SuggestedColor
{
get {
Lab lab = new Lab() { L = NewSuggestionL, A = NewSuggestionA, B = NewSuggestionB };
//Cmyk cmyk = new Cmyk { C = C, M = M, Y = Y, K = K};
IRgb RGB = lab.ToRgb();
//IRgb RGB = cmyk.ToRgb();
return Color.FromRgb((byte)RGB.R, (byte)RGB.G, (byte)RGB.B);
}
}
#endregion
public TrialsLogModel(int trial, double c, double m, double y, double k)
{
TrialNumber = trial;
IsActiveTrial = false;
C = c;
M = m;
Y = y;
K = k;
L = A = B = null;
Date = DateTime.UtcNow;
RaisePropertyChanged(nameof(CMYK));
IsTested = false;
IsSelectionEnable = true;
IsBest = false;
}
#region Methods
private bool ValidationLAB()
{
if (L == null || L < 0 || L > 100
|| A == null || A < -128 || A > 127
|| B == null || B < -128 || B > 127)
return false;
return true;
}
private void OnLABChanged()
{
if (ValidationLAB())
{
;
}
}
#endregion
}
}
|