-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathWaitCursor.cs
More file actions
63 lines (51 loc) · 1.37 KB
/
WaitCursor.cs
File metadata and controls
63 lines (51 loc) · 1.37 KB
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
namespace Menees.Windows.Presentation
{
#region Using Directives
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Windows.Input;
#endregion
/// <summary>
/// A disposable object that can be used to specify a "wait" cursor during long operations.
/// </summary>
/// <devnote>
/// Based on WinForms WaitCursor and http://stackoverflow.com/questions/3480966/display-hourglass-when-application-is-busy.
/// </devnote>
public sealed class WaitCursor : IDisposable
{
#region Private Data Members
private readonly Cursor previous;
#endregion
#region Constructors
/// <summary>
/// Creates a new instance that changes the application's cursor to a wait cursor.
/// </summary>
public WaitCursor()
{
// Save the previous cursor so Dispose can restore it. This allows us to work
// correctly even if WaitCursor instances are nested.
this.previous = Mouse.OverrideCursor;
Apply();
}
#endregion
#region Public Methods
/// <summary>
/// Changes the application's cursor to a wait cursor.
/// </summary>
public static void Apply()
{
Mouse.OverrideCursor = Cursors.Wait;
}
/// <summary>
/// Returns the application's cursor to its original state.
/// </summary>
public void Dispose()
{
Mouse.OverrideCursor = this.previous;
}
#endregion
}
}