Files
DeskCore/Tray.cs
T
M_ViperandClaude Opus 5.5 77bb3e6b9d DeskCore 1.0.0
Desktop-Icons in eigene Kategorien sortieren: Windows-11-Design (hell/dunkel),
Desktop-Boxen, automatisches Einsortieren nach Regeln, Rückgängig, Suche,
Infobereich mit Tastenkürzel, Sicherung als ZIP und Installer ohne Adminrechte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-01 20:19:32 +02:00

50 lines
1.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Windows;
namespace DeskCore;
/// <summary>Symbol im Infobereich der Taskleiste.</summary>
public sealed class Tray : IDisposable
{
private readonly System.Windows.Forms.NotifyIcon _icon;
/// <summary>Linksklick</summary>
public event Action? Clicked;
/// <summary>Rechtsklick – Kontextmenü wird von der WPF-Seite gezeigt (sieht moderner aus)</summary>
public event Action? MenuRequested;
public event Action? BalloonClicked;
public Tray()
{
var stream = Application.GetResourceStream(new Uri("pack://application:,,,/app.ico"))!.Stream;
_icon = new System.Windows.Forms.NotifyIcon
{
Icon = new System.Drawing.Icon(stream, System.Windows.Forms.SystemInformation.SmallIconSize),
Text = "DeskCore",
};
_icon.MouseUp += (_, e) =>
{
if (e.Button == System.Windows.Forms.MouseButtons.Left) Clicked?.Invoke();
else if (e.Button == System.Windows.Forms.MouseButtons.Right) MenuRequested?.Invoke();
};
_icon.BalloonTipClicked += (_, _) => BalloonClicked?.Invoke();
}
public bool Visible
{
get => _icon.Visible;
set => _icon.Visible = value;
}
public void Notify(string title, string text)
{
if (!_icon.Visible) return;
_icon.ShowBalloonTip(3000, title, text, System.Windows.Forms.ToolTipIcon.None);
}
public void Dispose()
{
_icon.Visible = false;
_icon.Dispose();
}
}