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>
This commit is contained in:
@@ -0,0 +1,49 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user