¶Ô±ÈÐÂÎļþ |
| | |
| | | using System; |
| | | using System.Windows.Forms; |
| | | |
| | | namespace Gs.DevApp.ToolBox |
| | | { |
| | | /// <summary> |
| | | /// ç³»ç»æ¶æ¯æç¤ºçªä½ |
| | | /// </summary> |
| | | public class MsgHelper |
| | | { |
| | | /// <summary> |
| | | /// æå¼å¯¹è¯æ¡ |
| | | /// </summary> |
| | | /// <param name="msg">æ¬æ¬¡å¯¹è¯å
容</param> |
| | | /// <returns></returns> |
| | | public static bool AskQuestion(string msg) |
| | | { |
| | | DialogResult r; |
| | | r = MessageBox.Show(msg, "æç¤º", |
| | | MessageBoxButtons.YesNo, |
| | | MessageBoxIcon.Question, |
| | | MessageBoxDefaultButton.Button2); |
| | | return r == DialogResult.Yes; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// éè¯¯æ¶æ¯æç¤ºæ¡ |
| | | /// </summary> |
| | | /// <param name="msg">éè¯¯æ¶æ¯å
容</param> |
| | | public static void ShowError(string msg) |
| | | { |
| | | MessageBox.Show(msg, "è¦å", |
| | | MessageBoxButtons.OK, |
| | | MessageBoxIcon.Hand, |
| | | MessageBoxDefaultButton.Button1); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// æ¾ç¤ºç³»ç»å¼å¸¸ |
| | | /// </summary> |
| | | /// <param name="e">ç³»ç»å¼å¸¸</param> |
| | | public static void ShowException(Exception e) |
| | | { |
| | | var s = e.Message; |
| | | var innerMsg = string.Empty; |
| | | |
| | | if (e.InnerException != null) |
| | | { |
| | | innerMsg = e.InnerException.Message; |
| | | s += "\n" + innerMsg; |
| | | } |
| | | |
| | | Warning(s); |
| | | } |
| | | |
| | | public static void ShowException(Exception ex, string customMessage) |
| | | { |
| | | //if (ex is CustomException) |
| | | //{ |
| | | // ShowException(ex); |
| | | //} |
| | | //else if (customMessage != "") |
| | | //{ |
| | | // Warning(customMessage); |
| | | //} |
| | | //else |
| | | //{ |
| | | // Warning(ex.Message); |
| | | //} |
| | | } |
| | | |
| | | /// <summary> |
| | | /// ä¿¡æ¯æç¤ºæ¡ |
| | | /// </summary> |
| | | /// <param name="msg">æ¬æ¬¡æ¾ç¤ºçæ¶æ¯</param> |
| | | public static void ShowInformation(string msg) |
| | | { |
| | | MessageBox.Show(msg, "ä¿¡æ¯", |
| | | MessageBoxButtons.OK, |
| | | MessageBoxIcon.Asterisk, |
| | | MessageBoxDefaultButton.Button1); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// è¦åæç¤ºæ¡ |
| | | /// </summary> |
| | | /// <param name="msg">è¦åå
容</param> |
| | | public static void Warning(string msg) |
| | | { |
| | | MessageBox.Show(msg, "è¦å", |
| | | MessageBoxButtons.OK, |
| | | MessageBoxIcon.Exclamation, |
| | | MessageBoxDefaultButton.Button1); |
| | | } |
| | | } |
| | | } |