* UINotifier: 点击提示关闭,增加输出提示

This commit is contained in:
Sunny 2024-11-19 12:33:30 +08:00
parent 1708d57ef1
commit c6650b3c0e
2 changed files with 13 additions and 8 deletions

View File

@ -517,7 +517,7 @@ namespace Sunny.UI
UINotifier.Show(desc, type, title, isDialog, timeout, inApp); UINotifier.Show(desc, type, title, isDialog, timeout, inApp);
} }
public static void ShowNotifier(string desc, EventHandler clickEvent, UINotifierType type = UINotifierType.INFO, string title = "Notifier", int timeout = 0) public static void ShowNotifier(string desc, EventHandler<DescriptionEventArgs> clickEvent, UINotifierType type = UINotifierType.INFO, string title = "Notifier", int timeout = 0)
{ {
UINotifier.Show(desc, type, title, false, timeout, null, clickEvent); UINotifier.Show(desc, type, title, false, timeout, null, clickEvent);
} }
@ -962,22 +962,22 @@ namespace Sunny.UI
UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UIStyles.CurrentResources.ErrorTitle, isDialog, timeout); UINotifierHelper.ShowNotifier(desc, UINotifierType.ERROR, UIStyles.CurrentResources.ErrorTitle, isDialog, timeout);
} }
public static void ShowInfoNotifier(this Form form, string desc, EventHandler clickEvent, int timeout = 2000) public static void ShowInfoNotifier(this Form form, string desc, EventHandler<DescriptionEventArgs> clickEvent, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.INFO, UIStyles.CurrentResources.InfoTitle, timeout); UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.INFO, UIStyles.CurrentResources.InfoTitle, timeout);
} }
public static void ShowSuccessNotifier(this Form form, string desc, EventHandler clickEvent, int timeout = 2000) public static void ShowSuccessNotifier(this Form form, string desc, EventHandler<DescriptionEventArgs> clickEvent, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.OK, UIStyles.CurrentResources.SuccessTitle, timeout); UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.OK, UIStyles.CurrentResources.SuccessTitle, timeout);
} }
public static void ShowWarningNotifier(this Form form, string desc, EventHandler clickEvent, int timeout = 2000) public static void ShowWarningNotifier(this Form form, string desc, EventHandler<DescriptionEventArgs> clickEvent, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.WARNING, UIStyles.CurrentResources.WarningTitle, timeout); UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.WARNING, UIStyles.CurrentResources.WarningTitle, timeout);
} }
public static void ShowErrorNotifier(this Form form, string desc, EventHandler clickEvent, int timeout = 2000) public static void ShowErrorNotifier(this Form form, string desc, EventHandler<DescriptionEventArgs> clickEvent, int timeout = 2000)
{ {
UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.ERROR, UIStyles.CurrentResources.ErrorTitle, timeout); UINotifierHelper.ShowNotifier(desc, clickEvent, UINotifierType.ERROR, UIStyles.CurrentResources.ErrorTitle, timeout);
} }

View File

@ -442,7 +442,7 @@ namespace Sunny.UI
// Show the note: it is the startup of the creation process of the note // Show the note: it is the startup of the creation process of the note
//------------------------------------------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------------------------------------------
public static short Show(string desc, UINotifierType type = UINotifierType.INFO, string title = "Notifier", public static short Show(string desc, UINotifierType type = UINotifierType.INFO, string title = "Notifier",
bool isDialog = false, int timeout = 0, Form inApp = null, EventHandler clickevent = null) bool isDialog = false, int timeout = 0, Form inApp = null, EventHandler<DescriptionEventArgs> clickevent = null)
{ {
if (NotifierAlreadyPresent(desc, type, title, isDialog, out var updated_note_id, out var updated_note_occurence)) if (NotifierAlreadyPresent(desc, type, title, isDialog, out var updated_note_id, out var updated_note_occurence))
{ {
@ -713,14 +713,19 @@ namespace Sunny.UI
{ {
if (ItemClick != null) if (ItemClick != null)
{ {
ItemClick.Invoke(this, e); ItemClick.Invoke(this, new DescriptionEventArgs(Description));
closeMe(); closeMe();
} }
} }
public event EventHandler ItemClick; public event EventHandler<DescriptionEventArgs> ItemClick;
} // Close Class } // Close Class
public class DescriptionEventArgs(string message) : EventArgs
{
public string Description { get; set; } = message;
}
/// <summary> /// <summary>
/// 窗体背景风格 /// 窗体背景风格
/// </summary> /// </summary>