/
MyProgressIndicator.cs
67 lines (59 loc) · 2.11 KB
/
MyProgressIndicator.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
// Developer Express Code Central Example:
// How to implement progress indicator for slow RichEditControl operations
//
// This example demonstrates how to utilize the IProgressIndicationService service
// interface of the RichEditControl. The ProgressBar control on the form indicates
// how the mail merge operation proceeds.
//
// You can find sample updates and versions for different programming languages here:
// http://www.devexpress.com/example=E3075
using System;
using System.Collections.Generic;
using System.Text;
using DevExpress.XtraEditors;
using DevExpress.Services;
using System.Windows.Forms;
using DevExpress.Xpf.Editors;
using System.Windows.Threading;
namespace ProgressIndicator
{
#region #myprogressindicator
class MyProgressIndicatorService : IProgressIndicationService
{
private ProgressBarEdit _Indicator;
public ProgressBarEdit Indicator
{
get { return _Indicator; }
set { _Indicator = value; }
}
public MyProgressIndicatorService(IServiceProvider provider, ProgressBarEdit indicator)
{
_Indicator = indicator;
}
#region IProgressIndicationService Members
void IProgressIndicationService.Begin(string displayName, int minProgress, int maxProgress, int currentProgress)
{
_Indicator.Minimum = minProgress;
_Indicator.Maximum = maxProgress;
_Indicator.EditValue = currentProgress;
_Indicator.Visibility = System.Windows.Visibility.Visible;
Refresh();
}
void IProgressIndicationService.End()
{
_Indicator.Visibility = System.Windows.Visibility.Collapsed;
Refresh();
}
void IProgressIndicationService.SetProgress(int currentProgress)
{
_Indicator.EditValue = currentProgress;
Refresh();
}
#endregion
void Refresh() {
Action emptyDelegate = delegate() { };
_Indicator.Dispatcher.Invoke(DispatcherPriority.Render, emptyDelegate);
}
}
#endregion #myprogressindicator
}