検索
1|using System; 2|using System.Windows.Forms; 3| 4|namespace net.e_ioo.Common 5|{ 6| public class MessageDlg 7| { 8| private static MessageDlgParam _param = null; 9| private static MessageInfoLib _infoLib = null; 10| 11| private MessageDlg() 12| { 13| } 14| 15| public static void Initialize(MessageDlgParam param) 16| { 17| _param = param; 18| _infoLib = new MessageInfoLib(_param.InfoFilePath); 19| } 20| 21| public static DialogResult Show(int id) 22| { 23| return Show(id.Tostring()); 24| } 25| public static DialogResult Show(string id) 26| { 27| return Show(id, null); 28| } 29| public static DialogResult Show(int id, object[] args) 30| { 31| return Show(id.Tostring(), args); 32| } 33| public static DialogResult Show(string id, object[] args) 34| { 35| if(_infoLib == null){ 36| return DialogResult.None; 37| } 38| 39| MessageInfo info = _infoLib[id]; 40| if(info == null){ 41| return DialogResult.None; 42| } 43| 44| string text = info.Text; 45| switch(_param.ShowId){ 46| case MessageDlgShowId.Top: 47| text = string.Format("[{0}]", info.Id) + "\r\n" + info.Text; 48| break; 49| case MessageDlgShowId.Bottom: 50| text = info.Text + "\r\n" + string.Format("[{0}]", info.Id); 51| break; 52| } 53| 54| if(args != null){ 55| text = string.Format(text, args); 56| } 57| 58| return MessageBox.Show(text, 59| info.Title, 60| info.Buttons, 61| info.Icon, 62| info.DefaultButton 63| ); 64| } 65| 66| } 67|}