-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
76 lines (64 loc) · 2.16 KB
/
Program.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Windows.Forms;
namespace ExportDbToFile
{
static class Program
{
const string Title = "ExportDbToFile";
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new FrmMain());
}
public static void ShowError(string message)
{
MessageBox.Show(message, Title, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
public static void ShowError(Exception ex)
{
ShowError(ex.Message);
}
public static void ShowError(Exception ex, string message)
{
ShowError(message + " --> " + ex.Message);
}
public static void ShowInformation(string message)
{
MessageBox.Show(message, Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public static void ShowInformation(Form form, string message)
{
MessageBox.Show(form, message, Title, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public static bool Confirm(string message)
{
return MessageBox.Show(message, Title, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK;
}
public static bool Confirm(string title, string message)
{
return MessageBox.Show(message, title, MessageBoxButtons.OKCancel, MessageBoxIcon.Question) == DialogResult.OK;
}
public static void RunSafe(Form owner, Action action)
{
try
{
owner.Cursor = Cursors.WaitCursor;
action();
owner.Cursor = Cursors.Default;
}
catch (Exception ex)
{
owner.Cursor = Cursors.Default;
ShowError(ex);
}
}
}
}