implement icon

This commit is contained in:
mshafer1
2024-12-20 13:32:19 -06:00
parent f5298e1a4e
commit e24ef645ac
3 changed files with 39 additions and 6 deletions

View File

@@ -21,6 +21,7 @@ namespace ntfysh_client
private const int ScreenMargin = 20;
private System.Timers.Timer? timer = null;
private ToolTipIcon? _icon;
private void SetWindowPosition()
{
@@ -68,8 +69,13 @@ namespace ntfysh_client
}
}
public void ShowNotification(string title, string message, int timeout_ms=-1)
public void ShowNotification(string title, string message, int timeout_ms = -1, ToolTipIcon? icon = null)
{
this._icon = icon;
if (this._icon != null)
{
this.iconBox.Image = ConvertToolTipIconToImage(_icon.Value);
}
if (this.timer != null)
{
this.timer.Stop();
@@ -87,6 +93,22 @@ namespace ntfysh_client
this.SetWindowPosition();
}
private Image? ConvertToolTipIconToImage(ToolTipIcon icon)
{
switch (icon)
{
case ToolTipIcon.Info:
return SystemIcons.Information.ToBitmap();
case ToolTipIcon.Warning:
return SystemIcons.Warning.ToBitmap();
case ToolTipIcon.Error:
return SystemIcons.Error.ToBitmap();
case ToolTipIcon.None:
default:
return null;
}
}
public bool IsVisible
{
get { return this.Visible; }