-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathMainWindow.xaml.cs
More file actions
135 lines (116 loc) · 4.84 KB
/
MainWindow.xaml.cs
File metadata and controls
135 lines (116 loc) · 4.84 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
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Interop;
using System.Windows.Media.Imaging;
using WPFCustomMessageBox;
namespace CustomMessageBoxDemo
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void button_StandardMessage_Click(object sender, RoutedEventArgs e)
{
var result = MessageBox.Show(string.Join("\n", Enumerable.Repeat("Hello World!", 12)));
Debug.WriteLine(result.ToString());
}
private void button_StandardMessageNew_Click(object sender, RoutedEventArgs e)
{
var result = CustomMessageBox.Show(string.Join("\n", Enumerable.Repeat("Hello World!", 12)));
Debug.WriteLine(result.ToString());
}
private void button_MessageWithCaption_Click(object sender, RoutedEventArgs e)
{
var result = MessageBox.Show("Hello World!", "Hello World the title.");
Debug.WriteLine(result.ToString());
}
private void button_MessageWithCaptionNew_Click(object sender, RoutedEventArgs e)
{
var result = CustomMessageBox.Show("Hello world!", "Hello World the title.");
Debug.WriteLine(result.ToString());
}
private void button_MessageWithCaptionAndButton_Click(object sender, RoutedEventArgs e)
{
var result = MessageBox.Show("Hello World!", "Hello World the title.", MessageBoxButton.OKCancel);
Debug.WriteLine(result.ToString());
}
private void button_MessageWithCaptionAndButtonNew_Click(object sender, RoutedEventArgs e)
{
var result = CustomMessageBox.Show("Hello World!", "Hello World the title.", MessageBoxButton.OKCancel);
Debug.WriteLine(result.ToString());
}
private void button_MessageWithCaptionButtonImage_Click(object sender, RoutedEventArgs e)
{
var result = MessageBox.Show(
"Are you sure you want to eject the nuclear fuel rods?",
"Confirm Fuel Ejection",
MessageBoxButton.OKCancel,
MessageBoxImage.Exclamation);
Debug.WriteLine(result.ToString());
}
private void button_MessageWithCaptionButtonImageNew_Click(object sender, RoutedEventArgs e)
{
var result = CustomMessageBox.Show("This is a message.", "This is a caption", MessageBoxButton.YesNo, MessageBoxImage.Asterisk);
Debug.WriteLine(result.ToString());
}
private void button_MessageWithCaptionButtonCustomImageNew_Click(object sender, RoutedEventArgs e)
{
var shield = Imaging.CreateBitmapSourceFromHIcon(
SystemIcons.Shield.Handle,
Int32Rect.Empty,
BitmapSizeOptions.FromEmptyOptions());
var msgBox = new MessageBoxModel()
{
Message = "This is a wide message with a windows shield beside it.",
Caption = "This is a caption",
Width = 900,
MinButtonWidth = 40,
YesButtonWidth = 300,
Buttons = MessageBoxButton.YesNo,
CustomImage = shield
};
var result = msgBox.ShowDialog();
Debug.WriteLine(result.ToString());
}
private void button_SelfUpdatingMessage_Click(object sender, RoutedEventArgs e)
{
var stopwatch = Stopwatch.StartNew();
var msgBox = new MessageBoxModel()
{
Message = $"This message box is open since {(int)stopwatch.Elapsed.TotalSeconds}s",
Caption = $"Open since {(int)stopwatch.Elapsed.TotalSeconds}s",
Buttons = MessageBoxButton.OK
};
var task = msgBox.Show();
while (task.Status == TaskStatus.Running)
{
msgBox.Message = $"This message box is open since {(int)stopwatch.Elapsed.TotalSeconds}s";
msgBox.Caption = $"Open since {(int)stopwatch.Elapsed.TotalSeconds}s";
Task.Delay(100).Wait();
}
Debug.WriteLine(task.Result.ToString());
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
}
private void button1_Click(object sender, RoutedEventArgs e)
{
var result = CustomMessageBox.ShowYesNoCancel(
"You have unsaved changes.",
"Unsaved Changes!",
"Evan Wondrasek",
"Don't Save",
"Cancel",
MessageBoxImage.Exclamation);
Debug.WriteLine(result.ToString());
}
}
}