blob: 7ecc74c10e5eaed262b2aea4e5edb7490b575fdb (
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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL;
using Tango.BL.Entities;
using Tango.PPC.Common;
using Tango.PPC.Jobs.Messages;
using System.Data.Entity;
using Tango.Core.Commands;
using System.Windows;
using Tango.Touch.Controls;
using System.Windows.Media;
namespace Tango.PPC.Jobs.ViewModels
{
/// <summary>
/// Represents the selected job view model.
/// </summary>
/// <seealso cref="Tango.PPC.Common.PPCViewModel" />
public class JobViewVM : PPCViewModel
{
private ObservablesContext _db;
#region Properties
private Job _job;
/// <summary>
/// Gets or sets the selected job.
/// </summary>
public Job Job
{
get { return _job; }
set { _job = value; RaisePropertyChangedAuto(); }
}
private List<ColorSpace> _colorSpaces;
/// <summary>
/// Gets or sets the available color spaces.
/// </summary>
public List<ColorSpace> ColorSpaces
{
get { return _colorSpaces; }
set { _colorSpaces = value; RaisePropertyChangedAuto(); }
}
private List<Rml> _rmls;
/// <summary>
/// Gets or sets the available RMLS.
/// </summary>
public List<Rml> Rmls
{
get { return _rmls; }
set { _rmls = value; RaisePropertyChangedAuto(); }
}
private List<SpoolType> _spoolTypes;
/// <summary>
/// Gets or sets the available spool types.
/// </summary>
public List<SpoolType> SpoolTypes
{
get { return _spoolTypes; }
set { _spoolTypes = value; RaisePropertyChangedAuto(); }
}
private List<Customer> _customers;
/// <summary>
/// Gets or sets the available customers.
/// </summary>
public List<Customer> Customers
{
get { return _customers; }
set { _customers = value; RaisePropertyChangedAuto(); }
}
private String _customersFilter;
/// <summary>
/// Gets or sets the customers filter.
/// </summary>
public String CustomersFilter
{
get { return _customersFilter; }
set { _customersFilter = value; RaisePropertyChangedAuto(); }
}
/// <summary>
/// Gets or sets the customers automatic complete provider.
/// </summary>
public AutoCompleteProvider<Customer> CustomersAutoCompleteProvider { get; set; }
#endregion
#region Commands
/// <summary>
/// Gets or sets the add solid segment command.
/// </summary>
public RelayCommand AddSolidSegmentCommand { get; set; }
/// <summary>
/// Gets or sets the add gradient segment command.
/// </summary>
public RelayCommand AddGradientSegmentCommand { get; set; }
/// <summary>
/// Gets or sets the add brush stop command.
/// </summary>
public RelayCommand<Segment> AddBrushStopCommand { get; set; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="JobViewVM"/> class.
/// </summary>
public JobViewVM()
{
RegisterForMessage<JobSelectedMessage>(HandleJobSelectedMessage);
CustomersAutoCompleteProvider = new AutoCompleteProvider<Customer>((customer, filter) =>
{
return customer.Name.ToLower().StartsWith(filter != null ? filter.ToLower() : String.Empty);
});
//Initialize Commands
AddSolidSegmentCommand = new RelayCommand(() => AddSolidSegment());
AddBrushStopCommand = new RelayCommand<Segment>(AddBrushStop);
AddGradientSegmentCommand = new RelayCommand(() => AddGradientSegment());
}
#endregion
#region Segments Management
/// <summary>
/// Adds a new solid segment.
/// </summary>
private Segment AddSolidSegment()
{
return Job.AddSolidSegment();
}
/// <summary>
/// Adds a new gradient segment.
/// </summary>
private Segment AddGradientSegment()
{
return Job.AddGradientSegment();
}
#endregion
#region Brush Stops Management
/// <summary>
/// Adds a new brush stop to the specified segment.
/// </summary>
/// <param name="segment">The segment.</param>
private void AddBrushStop(Segment segment)
{
segment.AddBrushStop();
}
#endregion
#region Job Selection Message
/// <summary>
/// Handles the job selected message.
/// </summary>
/// <param name="message">The message.</param>
private void HandleJobSelectedMessage(JobSelectedMessage message)
{
if (_db != null)
{
_db.Dispose();
}
_db = ObservablesContext.CreateDefault();
Job = _db.Jobs.SingleOrDefault(x => x.Guid == message.Job.Guid);
Rmls = _db.Rmls.ToList();
ColorSpaces = _db.ColorSpaces.ToList();
SpoolTypes = _db.SpoolTypes.ToList();
Customers = _db.Customers.Where(x => x.OrganizationGuid == Job.Machine.Organization.Guid).ToList();
}
#endregion
#region IPPC ViewModel Overrides
/// <summary>
/// Called when the application has been started.
/// </summary>
public override void OnApplicationStarted()
{
}
/// <summary>
/// Called when the navigation system has navigated to this VM view.
/// </summary>
public override void OnNavigatedTo()
{
base.OnNavigatedTo();
}
/// <summary>
/// Called before the navigation system navigates from this object.
/// Return false to abort the navigation.
/// </summary>
/// <returns></returns>
public override Task<bool> OnNavigateOutRequest()
{
return NotificationProvider.ShowQuestion("Are you sure you want to exit this job?");
}
#endregion
}
}
|