-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Message.cs
49 lines (38 loc) · 1.68 KB
/
Message.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
#region Using statements
using System;
using System.Windows.Forms;
#endregion Using statements
namespace WeekNumber
{
internal static class Message
{
#region Internal readonly strings
internal static readonly string[] SWEDISH_DAY_OF_WEEK_PREFIX = { "Söndagen ", "Måndagen ", "Tisdagen ", "Onsdagen ", "Torsdagen ", "Fredagen ", "Lördagen " };
internal static readonly string CAPTION = $"{Resources.ProductName} {Resources.Version} {Application.ProductVersion}";
#endregion Internal readonly strings
#region Show Information or Error dialog methods
internal static void Show(string text, Exception ex = null)
{
var message = ex is null ? text : $"{text}\r\n{ex}";
if (ex is null) Log.Info = message; else Log.ErrorString = message;
Forms.MessageForm.DisplayMessage(message, !(ex is null));
}
internal static void Show(string text)
{
Show(text, null);
}
internal static void Show(string message, bool isError)
{
if (isError) Log.Info = message; else Log.ErrorString = message;
Forms.MessageForm.DisplayMessage(message, isError);
}
internal static bool UserAcceptedQuestion(string message)
{
Log.Info = message;
// TODO: Customize and use MessageForm
DialogResult userAnswer = MessageBox.Show(message, CAPTION, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
return userAnswer == DialogResult.Yes;
}
#endregion Show Information or Error dialog methods
}
}