* 弹窗增加线程安全调用

This commit is contained in:
Sunny 2024-08-10 20:47:20 +08:00
parent 753d5b13d9
commit c328bb7f02
2 changed files with 35 additions and 11 deletions

View File

@ -1346,7 +1346,7 @@ namespace Sunny.UI
//绘制左侧+号 //绘制左侧+号
if (ShowPlusMinus && e.Node.Nodes.Count > 0) if (ShowPlusMinus && e.Node.Nodes.Count > 0)
{ {
if (ShowLines) if (ShowLinesEx)
{ {
e.Graphics.FillRectangle(Color.White, new Rectangle(lineX - 4, lineY - 4, 8, 8)); e.Graphics.FillRectangle(Color.White, new Rectangle(lineX - 4, lineY - 4, 8, 8));
e.Graphics.DrawRectangle(UIFontColor.Primary, new Rectangle(lineX - 4, lineY - 4, 8, 8)); e.Graphics.DrawRectangle(UIFontColor.Primary, new Rectangle(lineX - 4, lineY - 4, 8, 8));

View File

@ -169,12 +169,25 @@ namespace Sunny.UI
public static bool ShowMessageDialog(Form owner, string message, string title, bool showCancel, public static bool ShowMessageDialog(Form owner, string message, string title, bool showCancel,
UIStyle style, bool showMask = false, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Ok, int delay = 0) UIStyle style, bool showMask = false, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Ok, int delay = 0)
{ {
using UIMessageForm frm = new UIMessageForm(); if (owner == null)
frm.ShowMessage(message, title, showCancel, style); {
frm.DefaultButton = showCancel ? defaultButton : UIMessageDialogButtons.Ok; using UIMessageForm frm = new UIMessageForm();
frm.Delay = delay; frm.ShowMessage(message, title, showCancel, style);
frm.DefaultButton = showCancel ? defaultButton : UIMessageDialogButtons.Ok;
return frm.ShowForm(owner, showMask || owner == null, showMask); frm.Delay = delay;
return frm.ShowForm(owner, showMask || owner == null, showMask);
}
else
{
return owner.ThreadSafeCall<bool>(() =>
{
using UIMessageForm frm = new UIMessageForm();
frm.ShowMessage(message, title, showCancel, style);
frm.DefaultButton = showCancel ? defaultButton : UIMessageDialogButtons.Ok;
frm.Delay = delay;
return frm.ShowForm(owner, showMask || owner == null, showMask);
});
}
} }
/// <summary> /// <summary>
@ -188,10 +201,21 @@ namespace Sunny.UI
/// <returns>结果</returns> /// <returns>结果</returns>
public static bool ShowMessageDialog2(Form owner, string title, string message, UINotifierType noteType, bool showMask = false, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Cancel, int delay = 0) public static bool ShowMessageDialog2(Form owner, string title, string message, UINotifierType noteType, bool showMask = false, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Cancel, int delay = 0)
{ {
using UIMessageForm2 frm = new UIMessageForm2(title, message, noteType, defaultButton); if (owner == null)
frm.Delay = delay; {
using UIMessageForm2 frm = new UIMessageForm2(title, message, noteType, defaultButton);
return frm.ShowForm(owner, showMask || owner == null, showMask); frm.Delay = delay;
return frm.ShowForm(owner, showMask || owner == null, showMask);
}
else
{
return owner.ThreadSafeCall<bool>(() =>
{
using UIMessageForm2 frm = new UIMessageForm2(title, message, noteType, defaultButton);
frm.Delay = delay;
return frm.ShowForm(owner, showMask || owner == null, showMask);
});
}
} }
internal static bool ShowForm(this UIForm frm, Form owner, bool screenCenter, bool showMask) internal static bool ShowForm(this UIForm frm, Form owner, bool screenCenter, bool showMask)