125 lines
4.6 KiB
C#
125 lines
4.6 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.ComponentModel;
|
|||
|
using System.Data;
|
|||
|
using System.Drawing;
|
|||
|
using System.Text;
|
|||
|
using System.Linq;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using System.Windows.Forms;
|
|||
|
using DevExpress.XtraEditors;
|
|||
|
|
|||
|
namespace UI.Framework.Forms
|
|||
|
{
|
|||
|
public partial class BaseForm : DevExpress.XtraEditors.XtraForm
|
|||
|
{
|
|||
|
public BaseForm()
|
|||
|
{
|
|||
|
InitializeComponent();
|
|||
|
if (PublickIcon != null) this.Icon = PublickIcon;
|
|||
|
}
|
|||
|
|
|||
|
private void BaseForm_Load(object sender, EventArgs e)
|
|||
|
{
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 代理委托更新UI
|
|||
|
/// </summary>
|
|||
|
/// <param name="act"></param>
|
|||
|
protected delegate void DelegateUpdateUI(Action act);
|
|||
|
|
|||
|
/// <summary>
|
|||
|
/// 代理委托更新UI
|
|||
|
/// </summary>
|
|||
|
/// <param name="act"></param>
|
|||
|
protected void UpdateUI(Action act)
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
if (!InvokeRequired)
|
|||
|
{
|
|||
|
act.Invoke();
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
DelegateUpdateUI delegateUpdateUI = new DelegateUpdateUI(UpdateUI);
|
|||
|
Invoke(delegateUpdateUI, act);
|
|||
|
}
|
|||
|
}
|
|||
|
catch (Exception ex)
|
|||
|
{ }
|
|||
|
}
|
|||
|
public static void ShowSuccess(string message, string title = "友情提示")
|
|||
|
{
|
|||
|
XtraMessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|||
|
}
|
|||
|
|
|||
|
public static void ShowError(Exception ex, string title = "系统错误")
|
|||
|
{
|
|||
|
//var messagebox_param = new XtraMessageBoxArgs();
|
|||
|
//messagebox_param.AutoCloseOptions.ShowTimerOnDefaultButton = true;
|
|||
|
//messagebox_param.AutoCloseOptions.Delay = 5000;
|
|||
|
//messagebox_param.Caption = title;
|
|||
|
//messagebox_param.Text = ex.Message;
|
|||
|
|
|||
|
//XtraMessageBox.Show(messagebox_param);
|
|||
|
|
|||
|
XtraMessageBox.Show(ex.Message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
}
|
|||
|
public static void ShowError(string message, string title = "系统错误")
|
|||
|
{
|
|||
|
XtraMessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error);
|
|||
|
}
|
|||
|
|
|||
|
public static void ShowErrorAutoClose(Exception ex, int secondtime = 5000, string title = "系统错误")
|
|||
|
{
|
|||
|
XtraMessageBoxArgs args = new XtraMessageBoxArgs();
|
|||
|
args.AutoCloseOptions.Delay = secondtime;
|
|||
|
args.Caption = $"{title} - {(secondtime / 1000)}秒后自动关闭";
|
|||
|
args.Text = $@"{ex.Message}";
|
|||
|
args.Buttons = new DialogResult[] { DialogResult.OK };
|
|||
|
XtraMessageBox.Show(args).ToString();
|
|||
|
}
|
|||
|
|
|||
|
public static void ShowErrorAutoClose(string message, int secondtime = 5000, string title = "系统错误")
|
|||
|
{
|
|||
|
XtraMessageBoxArgs args = new XtraMessageBoxArgs();
|
|||
|
args.AutoCloseOptions.Delay = secondtime;
|
|||
|
args.Caption = $"{title} - {(secondtime / 1000)}秒后自动关闭";
|
|||
|
args.Text = $@"{message}";
|
|||
|
args.Buttons = new DialogResult[] { DialogResult.OK };
|
|||
|
XtraMessageBox.Show(args).ToString();
|
|||
|
}
|
|||
|
|
|||
|
public static void ShowSuccessAutoClose(string message, int secondtime = 5000, string title = "友情提示")
|
|||
|
{
|
|||
|
XtraMessageBoxArgs args = new XtraMessageBoxArgs();
|
|||
|
args.AutoCloseOptions.Delay = secondtime;
|
|||
|
args.Caption = $"{title} - {(secondtime / 1000)}秒后自动关闭";
|
|||
|
args.Text = $@"{message}";
|
|||
|
args.Buttons = new DialogResult[] { DialogResult.OK };
|
|||
|
XtraMessageBox.Show(args).ToString();
|
|||
|
}
|
|||
|
|
|||
|
public static DialogResult ShowSuccessAutoClose(string message, DialogResult[] dialogResults, int defaultButtonIndex = 1, int secondtime = 5000, string title = "友情提示")
|
|||
|
{
|
|||
|
XtraMessageBoxArgs args = new XtraMessageBoxArgs();
|
|||
|
args.AutoCloseOptions.Delay = secondtime;
|
|||
|
args.Caption = $"{title} - {(secondtime / 1000)}秒后自动关闭";
|
|||
|
args.Text = $@"{message}";
|
|||
|
args.Buttons = dialogResults;// new DialogResult[] { DialogResult.OK, DialogResult.Cancel };
|
|||
|
args.DefaultButtonIndex = defaultButtonIndex;
|
|||
|
args.AutoCloseOptions.ShowTimerOnDefaultButton = true;
|
|||
|
return XtraMessageBox.Show(args);
|
|||
|
}
|
|||
|
|
|||
|
public static Icon PublickIcon { get; private set; }
|
|||
|
public static void SetIcon(Icon icon)
|
|||
|
{
|
|||
|
PublickIcon = icon;
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
}
|