Files
notify/Notify/Models/ToastSettings.cs
chuan 5ce2c8a982 feat: Claude Code 原生 Windows 通知(C# / .NET 10 + Avalonia 12)
为 Claude Code 提供原生 Windows toast 通知:点击跳回原窗口、切回 Windows
Terminal 标签、跨虚拟桌面、调用方图标、非阻塞投递;NativeAOT 单文件分发。
2026-06-22 18:05:15 +08:00

85 lines
1.9 KiB
C#
Raw Permalink 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.
namespace Notify.Models;
/// <summary>
/// 水平方向:决定 toast 贴左/居中/贴右
/// </summary>
public enum HEdge
{
Left,
Center,
Right,
}
/// <summary>
/// 垂直方向:决定 toast 贴上/居中/贴下,并决定堆叠方向
/// </summary>
public enum VEdge
{
Top,
Center,
Bottom,
}
/// <summary>
/// 持久化的弹窗设置(纯数据模型,序列化到磁盘)
/// </summary>
public sealed class ToastSettings
{
/// <summary>
/// 自动消失前的停留秒数
/// </summary>
public int DurationSeconds { get; set; } = 4;
/// <summary>
/// 目标窗口已在前台时的停留秒数(你正盯着看,弹一下即可)
/// </summary>
public int FocusedDurationSeconds { get; set; } = 2;
/// <summary>
/// 水平方向
/// </summary>
public HEdge Horizontal { get; set; } = HEdge.Right;
/// <summary>
/// 垂直方向
/// </summary>
public VEdge Vertical { get; set; } = VEdge.Bottom;
/// <summary>
/// 与屏幕边缘的留白(DIP
/// </summary>
public int Margin { get; set; } = 12;
/// <summary>
/// 不透明度 01
/// </summary>
public double Opacity { get; set; } = 0.96;
/// <summary>
/// 最多同时可见的 toast 数量,超出则排队
/// </summary>
public int MaxVisible { get; set; } = 5;
/// <summary>
/// 是否播放提示音
/// </summary>
public bool PlaySound { get; set; } = true;
/// <summary>
/// toast 宽度(DIP
/// </summary>
public double Width { get; set; } = 340;
/// <summary>
/// 淡入/淡出时长(毫秒)
/// </summary>
public int FadeMilliseconds { get; set; } = 300;
/// <summary>
/// 跨所有虚拟桌面显示(未公开 API,失败自动退回单桌面)
/// </summary>
public bool ShowOnAllDesktops { get; set; } = true;
public ToastSettings Clone() => (ToastSettings)MemberwiseClone();
}