-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathMessageBoxNotificationHandler.cs
More file actions
47 lines (39 loc) · 1.45 KB
/
MessageBoxNotificationHandler.cs
File metadata and controls
47 lines (39 loc) · 1.45 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
using PS5_NOR_Modifier.Extensions;
using UART.Core.Abstractions;
using UART.Core.Models;
namespace PS5_NOR_Modifier.Dialogs;
public class MessageBoxNotificationHandler : INotificationHandler
{
public void HandleMessage(Notification notificationDetails)
{
MessageBox.Show(
notificationDetails.Message,
notificationDetails.Title,
notificationDetails.Type.ToMessageBoxButtons(),
notificationDetails.Type.ToMessageBoxIcon());
}
public void HandleQuestion(Question question)
{
DialogResult result = MessageBox.Show(
question.Message,
question.Title,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (result == DialogResult.Yes && question.OnYes != null)
question.OnYes.Invoke();
if (result == DialogResult.No && question.OnNo != null)
question.OnNo.Invoke();
}
public async Task HandleQuestion(AsyncQuestion asyncQuestion)
{
DialogResult result = MessageBox.Show(
asyncQuestion.Message,
asyncQuestion.Title,
MessageBoxButtons.YesNo,
MessageBoxIcon.Question);
if (result == DialogResult.Yes && asyncQuestion.OnYes != null)
await asyncQuestion.OnYes.Invoke();
if (result == DialogResult.No && asyncQuestion.OnNo != null)
await asyncQuestion.OnNo.Invoke();
}
}