-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProgressStatus.cs
106 lines (97 loc) · 2.57 KB
/
ProgressStatus.cs
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
/*
Copyright © Bryan Apellanes 2015
*/
using System;
using System.Collections.Generic;
//using System.Linq;
using System.Text;
namespace Naizari
{
public class ProgressStatus
{
public event ProgressStatusUpdatedEventHandler Updated;
int total;
/// <summary>
/// Gets or sets the total number of operations in a set of operations
/// tracked by the current ProgressStatus instance.
/// </summary>
public int Total
{
get { return total; }
set
{
total = value;
//OnUpdated();
}
}
private void OnUpdated()
{
if (Updated != null)
Updated(this, new ProgressStatusEventArgs(this));
}
int current;
/// <summary>
/// Gets or sets the current operation in a set of operations
/// tracked by the current ProgressStatus instance.
/// </summary>
public int Current
{
get { return current; }
set
{
current = value;
OnUpdated();
}
}
/// <summary>
/// Gets the current percentage completed of a set of operations
/// tracked by the current ProgressStatus instance.
/// </summary>
public int PercentComplete
{
get
{
if (Total > 0)
return (int)(((decimal)Current / (decimal)Total) * 100);
else
return 100;
}
}
string message;
/// <summary>
/// Gets or sets the message associated with the current operation of a set
/// of operations tracked by the current ProgressStatus instance.
/// </summary>
public string Message
{
get { return message; }
set
{
message = value;
OnUpdated();
}
}
bool isActive;
/// <summary>
/// Gets or sets the active state of the set of operations represented
/// by the current ProgressStatus instance.
/// </summary>
public bool IsActive
{
get { return isActive; }
set
{
isActive = value;
OnUpdated();
}
}
public void Reset()
{
isActive = false;
message = string.Empty;
total = 0;
current = 0;
OnUpdated();
}
}
}