aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Integration/Printing/JobHandler.cs
blob: d6c2308c06639d263a6da36e3920c1d9496dc578 (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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.PMR.Printing;

namespace Tango.Integration.Printing
{
    public class JobHandler
    {
        private Action _cancelAction;

        public event EventHandler<JobStatus> StatusReceived;
        public event EventHandler<Exception> Failed;
        public event EventHandler Completed;
        public event EventHandler Canceled;

        public JobHandler()
        {

        }

        internal JobHandler(Action cancelAction) : this()
        {
            _cancelAction = cancelAction;
        }

        internal void RaiseStatusReceived(JobStatus status)
        {
            StatusReceived?.Invoke(this, status);
        }

        internal void RaiseFailed(Exception ex)
        {
            Failed?.Invoke(this, ex);
        }

        internal void RaiseCompleted()
        {
            Completed?.Invoke(this, new EventArgs());
        }

        internal void RaiseCanceled()
        {
            Canceled?.Invoke(this, new EventArgs());
        }

        public void Cancel()
        {
            _cancelAction();
        }
    }
}