* 弹窗增加线程安全调用

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 (ShowLines)
if (ShowLinesEx)
{
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));

View File

@ -169,12 +169,25 @@ namespace Sunny.UI
public static bool ShowMessageDialog(Form owner, string message, string title, bool showCancel,
UIStyle style, bool showMask = false, UIMessageDialogButtons defaultButton = UIMessageDialogButtons.Ok, int delay = 0)
{
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);
if (owner == null)
{
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);
}
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>
@ -188,10 +201,21 @@ namespace Sunny.UI
/// <returns>结果</returns>
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);
frm.Delay = delay;
return frm.ShowForm(owner, showMask || owner == null, showMask);
if (owner == null)
{
using UIMessageForm2 frm = new UIMessageForm2(title, message, noteType, defaultButton);
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)