blob: 8ca2b948c452120e6db625f9b1eda6acc10910df (
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
|
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;
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;
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(); }
}
/// <summary>
/// Gets or sets the add solid segment command.
/// </summary>
public RelayCommand AddSolidSegmentCommand { get; set; }
/// <summary>
/// Initializes a new instance of the <see cref="JobViewVM"/> class.
/// </summary>
public JobViewVM()
{
RegisterForMessage<JobSelectedMessage>(HandleJobSelectedMessage);
AddSolidSegmentCommand = new RelayCommand(AddSolidSegment);
}
private void AddSolidSegment()
{
MessageBox.Show("SOLID");
}
/// <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();
}
/// <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?");
}
}
}
|