blob: 0f449690401e21d605286554f3a0e0b597d49d23 (
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
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
|
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL;
using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.Core.Commands;
using Tango.Core.DI;
using Tango.PPC.Common;
using Tango.PPC.Common.Connection;
using Tango.PPC.Common.Lubrication;
using Tango.Settings;
using Tango.SharedUI;
namespace Tango.PPC.Jobs.Dialogs
{
/// <summary>
/// Represents the a job type picker view model
/// </summary>
/// <seealso cref="Tango.SharedUI.DialogViewVM" />
public class JobCreationViewVM : DialogViewVM
{
public class RMLModel
{
public String Name { get; set; }
public String Guid { get; set; }
public String FinalName { get; set; }
}
/// <summary>
/// Gets or sets the machine provider.
/// </summary>
[TangoInject]
public IMachineProvider MachineProvider { get; set; }
private String _jobName;
public String JobName
{
get { return _jobName; }
set { _jobName = value;
RaisePropertyChangedAuto();
OKCommand.RaiseCanExecuteChanged();
}
}
/// <summary>
/// Gets or sets the available RMLS.
/// </summary>
public List<Rml> Rmls { get; set; }
public ObservableCollection<RMLModel> RMLDisplayList { get; set; }
private RMLModel _selectedRML;
public RMLModel SelectedRML
{
get { return _selectedRML; }
set {
if(_selectedRML != value)
{
_selectedRML = value;
OnRmlSelectionChanged();
RaisePropertyChangedAuto();
OKCommand.RaiseCanExecuteChanged();
}
}
}
private List<SpoolType> _spoolTypes;
/// <summary>
/// Gets or sets the available spool types.
/// </summary>
public List<SpoolType> SpoolTypes
{
get { return _spoolTypes; }
set { _spoolTypes = value;
RaisePropertyChangedAuto();
OKCommand.RaiseCanExecuteChanged();
}
}
private SpoolType _selectedSpoolType;
/// <summary>
/// Gets or sets the type of the selected spool.
/// </summary>
public SpoolType SelectedSpoolType
{
get { return _selectedSpoolType; }
set {
if(_selectedSpoolType != value)
{
_selectedSpoolType = value;
OnSelectedSpoolTypeChanged();
RaisePropertyChangedAuto();
}
}
}
public bool UseFlatSpool { get; set; }
private RmlLubricationLevel _lubricationLevel;
public RmlLubricationLevel LubricationLevel
{
get { return _lubricationLevel; }
set { _lubricationLevel = value; RaisePropertyChangedAuto(); }
}
private int _btsrSpoolTension;
public int BtsrSpoolTension
{
get { return _btsrSpoolTension; }
set { _btsrSpoolTension = value; RaisePropertyChangedAuto(); }
}
private PPCSettings _settings;
/// <summary>
/// Gets the main PPC settings.
/// </summary>
public PPCSettings Settings
{
get
{
if (_settings == null)
{
_settings = SettingsManager.Default.GetOrCreate<PPCSettings>();
}
return _settings;
}
private set { _settings = value; }
}
private double _whiteGap;
public double WhiteGap
{
get { return _whiteGap; }
set { _whiteGap = value;
RaisePropertyChangedAuto();
}
}
private bool _showDuplicate;
public bool ShowDuplicate
{
get { return _showDuplicate; }
set { _showDuplicate = value;
RaisePropertyChangedAuto();
}
}
public bool IsDuplicate { get; set; }
public RelayCommand DuplicateCommand { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="JobCreationViewVM"/> class.
/// </summary>
/// <param name="supportedJobTypes">The supported job types.</param>
/// <param name="supportedColorSpaces">The supported color spaces</param>
public JobCreationViewVM(List<SpoolType> spoolTypes, List<Rml> rmls, string selectedRmlGuid, double whitegap, bool showDuplicate) : base()
{
JobName = "Unnamed";
SpoolTypes = spoolTypes;
Rmls = rmls.OrderBy(x => x.Name).ToList();
DuplicateCommand = new RelayCommand(Duplicate);
IsDuplicate = false;
ShowDuplicate = showDuplicate;
WhiteGap = whitegap;
RMLDisplayList = rmls.Select( p => new RMLModel{ Guid = p.Guid, Name = p.Name, FinalName = p.FinalName }).OrderBy(x => x.FinalName).ToObservableCollection();
SelectedRML = String.IsNullOrEmpty(selectedRmlGuid) ? RMLDisplayList.FirstOrDefault() : RMLDisplayList.FirstOrDefault( x=> x.Guid == selectedRmlGuid);
}
#region Commands
private void Duplicate(object obj)
{
IsDuplicate = true;
Accept();
}
protected override bool CanOK()
{
//var ret = (false == String.IsNullOrEmpty(JobName) && SelectedRML != null && SelectedSpoolType != null);
return (false == String.IsNullOrEmpty(JobName) && SelectedRML!=null );//&& SelectedSpoolType!=null);
}
#endregion
#region update on change value
private void OnRmlSelectionChanged()
{
GetLubricationLevel();
SetSpoolTension();
}
private void OnSelectedSpoolTypeChanged()
{
SetSpoolTension();
}
#endregion
#region Lubrication Level
private void GetLubricationLevel()
{
if (SelectedRML != null)
{
LubricationLevel = Settings.LubricationLevels.FirstOrDefault(x => x.RmlGuid == SelectedRML.Guid);
}
else
{
LubricationLevel = null;
}
}
#endregion
#region Spool Tension
private async void SetSpoolTension()
{
if (SelectedRML != null && SelectedSpoolType != null)
{
using (ObservablesContext db = ObservablesContext.CreateDefault())
{
Rml selectedRML = Rmls.FirstOrDefault( x=> x.Guid == SelectedRML.Guid);
if(selectedRML != null)
{
BtsrSpoolTension = await selectedRML.GetRequiredBtsrSpoolTension(db, SelectedSpoolType);
}
}
}
}
#endregion
}
}
|