ShowMessageBox.cs
4.8 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
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace App
{
public static class ShowMessageBox
{
/// <summary>
/// 获得对应语言的消息文本
/// </summary>
/// <param name="textId">消息ID</param>
/// <returns>对应语言的消息文本</returns>
private static String GetMsgText(string str_Text)
{
FrmBase frmBase = new FrmBase();
frmBase.GetCurrLanguage();
return frmBase.getMsg("msg-" + str_Text);
}
/// <summary>
/// 获得对应语言的消息文本
/// </summary>
/// <param name="textId">消息ID</param>
/// <returns>对应语言的消息文本</returns>
private static String GetMsgTextWithoutAppGlobal(string str_TextID, string str_Language)
{
FrmBase frmBase = new FrmBase();
frmBase.GetCurrLanguageWithoutAppGlobal(str_Language);
return frmBase.getMsg("msg-" + str_TextID);
}
/// <summary>
/// 提示消息框
/// </summary>
public static void ShowInfo(string captionStr, int textId)
{
string caption = GetMsgText(captionStr);
string text = GetMsgText(textId.ToString());
MessageBox.Show(text, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
public static void ShowInfo(IWin32Window win32Window, string captionStr, int textId)
{
string caption = GetMsgText(captionStr);
string text = GetMsgText(textId.ToString());
MessageBox.Show(win32Window,text, caption, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
/// <summary>
/// 询问消息框
/// </summary>
public static bool ShowQuestion(string captionStr, int textId)
{
string caption = GetMsgText(captionStr);
string text = GetMsgText(textId.ToString());
return MessageBox.Show(text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes;
}
public static bool ShowQuestion(IWin32Window win32Window, string captionStr, int textId)
{
string caption = GetMsgText(captionStr);
string text = GetMsgText(textId.ToString());
return MessageBox.Show(win32Window, text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes;
}
public static bool ShowQuestionForDeleteProduce(string captionStr, string info)
{
string caption = GetMsgText(captionStr);
FrmBase frmBase = new FrmBase();
frmBase.GetCurrLanguage();
string text = frmBase.getMsg("ConfirmDelete") + info + "?";
return MessageBox.Show(text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.Yes;;
}
/// <summary>
/// 警告消息框
/// </summary>
public static bool ShowWarning(IWin32Window win32Window, string captionStr, int textId)
{
string caption = GetMsgText(captionStr);
string text = GetMsgText(textId.ToString());
return MessageBox.Show(win32Window,text, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button1) == DialogResult.Yes;
}
public static bool ShowWarning(string captionStr, int textId)
{
return ShowWarning(null,captionStr, textId);
}
public static void ShowError(Form win32Window ,string captionStr, string name, int textId) {
if (win32Window.InvokeRequired)
{
win32Window.Invoke(new Action(() =>
{
ShowError(captionStr, name, textId);
}));
}
else {
ShowError(captionStr, name, textId);
}
}
/// <summary>
/// 错误消息框
/// </summary>
public static void ShowError(string captionStr,string name, int textId)
{
string caption = GetMsgText(captionStr);
string text = GetMsgText(textId.ToString());
MessageBox.Show(name+text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
/// <summary>
/// 错误消息框,用于还未登录时,因为Appglobel为空
/// </summary>
public static void ShowErrorWithoutAppGlobal(string captionStr,string name ,int textId,string str_Language)
{
string caption = GetMsgTextWithoutAppGlobal(captionStr, str_Language);
string text = GetMsgTextWithoutAppGlobal(textId.ToString(), str_Language);
MessageBox.Show(name+text, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}