-
Notifications
You must be signed in to change notification settings - Fork 1
/
ProgressWrapper.cs
52 lines (51 loc) · 1.31 KB
/
ProgressWrapper.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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Threading;
namespace EbayCrawlerWPF_2
{
public class ProgressWrapper
{
private Control bar;
private int current = 1;
private int sum;
public ProgressWrapper(Control bar, int sum)
{
this.bar = bar;
this.sum = sum;
}
public void Advance()
{
if (bar != null && current <= sum)
{
Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
{
(this.bar as ProgressBar).Value += (1);
});
this.current++;
}
}
}
public class TextBlockWrapper
{
private Control block;
public TextBlockWrapper(Control textBlock)
{
this.block = textBlock;
}
public void print(string value)
{
if (block != null)
{
Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)delegate
{
//(block as TextBlock).Text = value;
});
}
}
}
}