119 lines
3.3 KiB
C#
119 lines
3.3 KiB
C#
using System.Collections.ObjectModel;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace OmniNotify;
|
|
|
|
public enum NotificationStatus
|
|
{
|
|
Displayed,
|
|
DndMuted,
|
|
IllegalChannel,
|
|
System
|
|
}
|
|
|
|
public enum ScreenAnchor
|
|
{
|
|
TopLeft,
|
|
TopCenter,
|
|
TopRight,
|
|
MiddleLeft,
|
|
Center,
|
|
MiddleRight,
|
|
BottomLeft,
|
|
BottomCenter,
|
|
BottomRight
|
|
}
|
|
|
|
public enum StackMode
|
|
{
|
|
Queue,
|
|
Push,
|
|
Replace
|
|
}
|
|
|
|
public enum OverflowMode
|
|
{
|
|
Truncate,
|
|
VerticalScroll,
|
|
Split
|
|
}
|
|
|
|
public enum PopupAnimation
|
|
{
|
|
Fade,
|
|
Slide,
|
|
Zoom
|
|
}
|
|
|
|
public sealed class AppState
|
|
{
|
|
public GlobalSettings Settings { get; set; } = new();
|
|
public ObservableCollection<Channel> Channels { get; set; } = [];
|
|
public ObservableCollection<HistoryItem> History { get; set; } = [];
|
|
}
|
|
|
|
public sealed class GlobalSettings
|
|
{
|
|
public bool DndEnabled { get; set; }
|
|
public bool CircuitBreakerOpen { get; set; }
|
|
public int MaxMessagesPerSecond { get; set; } = 8;
|
|
public int RetainDays { get; set; } = 30;
|
|
public int RetainCount { get; set; } = 1000;
|
|
public int LocalPort { get; set; } = 19845;
|
|
}
|
|
|
|
public sealed class Channel
|
|
{
|
|
public Guid Id { get; set; } = Guid.NewGuid();
|
|
public string Name { get; set; } = "default";
|
|
public NotificationProfile Profile { get; set; } = NotificationProfile.CreateDefault();
|
|
}
|
|
|
|
public sealed class NotificationProfile
|
|
{
|
|
public int ScreenIndex { get; set; }
|
|
public ScreenAnchor Anchor { get; set; } = ScreenAnchor.TopRight;
|
|
public double MarginX { get; set; } = 24;
|
|
public double MarginY { get; set; } = 24;
|
|
public double Width { get; set; } = 360;
|
|
public double MaxHeight { get; set; } = 220;
|
|
public double Padding { get; set; } = 18;
|
|
public string FontFamily { get; set; } = "Microsoft YaHei UI";
|
|
public double TitleFontSize { get; set; } = 16;
|
|
public double BodyFontSize { get; set; } = 13;
|
|
public string TextColor { get; set; } = "#F8FAFC";
|
|
public string BackgroundColor { get; set; } = "#242934";
|
|
public double BackgroundOpacity { get; set; } = 0.94;
|
|
public string BorderColor { get; set; } = "#5B6B84";
|
|
public double BorderOpacity { get; set; } = 0.65;
|
|
public double OverallOpacity { get; set; } = 1;
|
|
public double LifetimeSeconds { get; set; } = 4.5;
|
|
public PopupAnimation EnterAnimation { get; set; } = PopupAnimation.Slide;
|
|
public PopupAnimation ExitAnimation { get; set; } = PopupAnimation.Fade;
|
|
public StackMode StackMode { get; set; } = StackMode.Queue;
|
|
public OverflowMode OverflowMode { get; set; } = OverflowMode.Truncate;
|
|
public double SplitIntervalSeconds { get; set; } = 0.6;
|
|
[JsonPropertyName("MarqueeHoldSeconds")]
|
|
public double VerticalScrollHoldSeconds { get; set; } = 1;
|
|
public double VerticalScrollSpeed { get; set; } = 30;
|
|
|
|
public static NotificationProfile CreateDefault() => new();
|
|
}
|
|
|
|
public sealed class HistoryItem
|
|
{
|
|
public Guid Id { get; set; } = Guid.NewGuid();
|
|
public DateTime ReceivedAt { get; set; } = DateTime.Now;
|
|
public string Channel { get; set; } = "";
|
|
public string Title { get; set; } = "";
|
|
public string Body { get; set; } = "";
|
|
public NotificationStatus Status { get; set; }
|
|
}
|
|
|
|
public sealed class IncomingMessage
|
|
{
|
|
public string Channel { get; set; } = "";
|
|
public string Title { get; set; } = "";
|
|
public string Body { get; set; } = "";
|
|
}
|