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
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media;
using Tango.BL.Entities;
using Tango.FSE.Common;
using Tango.Integration.Operation;
using Tango.PPC.Shared.Jobs;
namespace Tango.FSE.UI.Tiles.RemoteJob
{
public class RemoteJobTile : DashboardTile
{
private Job _job;
public Job Job
{
get { return _job; }
set { _job = value; RaisePropertyChangedAuto(); }
}
private JobHandler _handler;
public JobHandler Handler
{
get { return _handler; }
set { _handler = value; RaisePropertyChangedAuto(); }
}
private RunningJobStatus _runningJobStatus;
public RunningJobStatus RunningJobStatus
{
get { return _runningJobStatus; }
set { _runningJobStatus = value; RaisePropertyChangedAuto(); }
}
private bool _isRunning;
public bool IsRunning
{
get { return _isRunning; }
set { _isRunning = value; RaisePropertyChangedAuto(); }
}
public RemoteJobTile()
{
Name = "Remote Job";
AutoTitleStyle = true;
AutoContainerStyle = false;
AutoTitleAlignment = System.Windows.Controls.Dock.Top;
Column = 0;
Row = 10;
ColumnSpan = 12;
RowSpan = 2;
InitDemoJob();
}
private void InitDemoJob()
{
IsRunning = false;
Job = new Job();
Job.NumberOfUnits = 1;
Job.Name = "N/A";
Job.AddSolidSegment(Color.FromRgb(70, 70, 70), 5);
Job.AddSolidSegment(Colors.Gray, 5);
Job.AddSolidSegment(Color.FromRgb(70, 70, 70), 5);
Job.AddSolidSegment(Colors.Gray, 5);
Handler = new JobHandler(() => { }, Job, null, new ProcessParametersTable() { DyeingSpeed = 50 }, JobHandlerModes.SettingUp);
Handler.RaiseStatusReceived(new PMR.Printing.JobStatus()
{
Message = "Ready",
CurrentSegmentIndex = 0,
Progress = 0,
});
RunningJobStatus = Handler.Status;
}
public override FrameworkElement GetView()
{
return new RemoteJobTileView();
}
public override void OnApplicationStarted()
{
base.OnApplicationStarted();
RemoteJobProvider.RemoteJobStarted += RemoteJobProvider_RemoteJobStarted;
RemoteJobProvider.RemoteJobStopped += RemoteJobProvider_RemoteJobStopped;
MachineProvider.MachineConnected += MachineProvider_MachineConnected;
}
private void MachineProvider_MachineConnected(object sender, Common.Connection.MachineConnectedEventArgs e)
{
InitDemoJob();
}
private void RemoteJobProvider_RemoteJobStopped(object sender, Common.RemoteJob.RemoteJobStoppedEventArgs e)
{
IsRunning = false;
}
private void RemoteJobProvider_RemoteJobStarted(object sender, Common.RemoteJob.RemoteJobStartedEventArgs e)
{
Handler = e.JobHandler;
Handler.StatusChanged += Handler_StatusChanged;
Job = e.JobHandler.Job;
IsRunning = true;
}
private void Handler_StatusChanged(object sender, RunningJobStatus status)
{
RunningJobStatus = status;
}
}
}
|