using System.Windows.Media; using ytLive.Helpers; namespace ytLive.Models; public enum SourceType { DisplayCapture, WindowCapture, Background, Image, TextOverlay, Countdown, WebSource, ChatBox } public enum ClipShape { Traditional, Round } /// /// A multi-instance scene object: image/background/text (screen/window later). /// The webcam is NOT a Source — it's a singleton resource whose per-scene usage /// is a . See the singleton-vs-multi-instance /// discriminator in ai.md. /// public class Source : SceneElement { private SourceType _type; public SourceType Type { get => _type; set { if (Set(ref _type, value)) { Raise(nameof(IsLiveCapture)); Raise(nameof(DisplaySource)); Raise(nameof(IsWebSource)); } } } public override bool IsDraggable => Type is SourceType.Image or SourceType.WebSource or SourceType.ChatBox; public override bool IsWebSource => Type == SourceType.WebSource; /// The permanent scene backdrop (live desktop/game capture). Never removable/reorderable. private bool _isBackdrop; public bool IsBackdrop { get => _isBackdrop; set => Set(ref _isBackdrop, value); } private bool _showDesktop; public bool ShowDesktop { get => _showDesktop; set => Set(ref _showDesktop, value); } private bool _isEnabled = true; public bool IsEnabled { get => _isEnabled; set => Set(ref _isEnabled, value); } // Display/Window capture private int? _monitorIndex; public int? MonitorIndex { get => _monitorIndex; set => Set(ref _monitorIndex, value); } private IntPtr? _windowHandle; public IntPtr? WindowHandle { get => _windowHandle; set => Set(ref _windowHandle, value); } /// /// Identifies what this live-capture source points at: "monitor:<index>" or /// "window:<hwnd>". Persisted so a re-designated backdrop survives a reload. /// private string? _captureKey; public string? CaptureKey { get => _captureKey; set => Set(ref _captureKey, value); } public bool IsLiveCapture => Type is SourceType.DisplayCapture or SourceType.WindowCapture; // Image (asset stored in the layout database) private string? _assetId; private ImageSource? _imageSource; public string? AssetId { get => _assetId; set { if (Set(ref _assetId, value)) { _imageSource = ImageCache.Get(value ?? string.Empty); Raise(nameof(ImageSource)); Raise(nameof(DisplaySource)); } } } public ImageSource? ImageSource => _imageSource; public override ImageSource? DisplaySource => IsLiveCapture ? (VideoImageSource ?? _imageSource) : (Type == SourceType.ChatBox ? VideoImageSource : _imageSource); public override bool IsImageSource => Type == SourceType.Image; // Countdown config private int _timerMinutes = 15; public int TimerMinutes { get => _timerMinutes; set => Set(ref _timerMinutes, Math.Clamp(value, 1, 60)); } // Web source config private string? _webUri; public string? WebUri { get => _webUri; set => Set(ref _webUri, value); } // Chat box config (TASK 3.18) private double _chatFontSize = 16; public double ChatFontSize { get => _chatFontSize; set => Set(ref _chatFontSize, Math.Clamp(value, 8, 72)); } private string _chatFontColor = "#FFFFFF"; public string ChatFontColor { get => _chatFontColor; set => Set(ref _chatFontColor, value); } private string _chatBackgroundColor = "#80000000"; public string ChatBackgroundColor { get => _chatBackgroundColor; set { if (Set(ref _chatBackgroundColor, value)) Raise(nameof(ChatBackgroundOpacity)); } } /// Alpha channel of ChatBackgroundColor as 0.0–1.0. Slider writes back the full hex string. public double ChatBackgroundOpacity { get { var hex = _chatBackgroundColor.Trim().TrimStart('#'); return hex.Length == 8 ? byte.Parse(hex.AsSpan(0, 2), System.Globalization.NumberStyles.HexNumber) / 255.0 : 1.0; } set { var alpha = (byte)Math.Clamp(value * 255, 0, 255); var hex = _chatBackgroundColor.Trim().TrimStart('#'); if (hex.Length == 8) hex = hex[2..]; if (hex.Length == 6) ChatBackgroundColor = $"#{alpha:X2}{hex}"; } } private int _chatMaxMessages = 5; public int ChatMaxMessages { get => _chatMaxMessages; set => Set(ref _chatMaxMessages, Math.Clamp(value, 1, 20)); } private bool _chatShowTimestamps = true; public bool ChatShowTimestamps { get => _chatShowTimestamps; set => Set(ref _chatShowTimestamps, value); } private bool _chatShowBadges = true; public bool ChatShowBadges { get => _chatShowBadges; set => Set(ref _chatShowBadges, value); } private string _chatMemberColor = "#e94560"; public string ChatMemberColor { get => _chatMemberColor; set => Set(ref _chatMemberColor, value); } private string _chatSuperChatColor = "#eab308"; public string ChatSuperChatColor { get => _chatSuperChatColor; set => Set(ref _chatSuperChatColor, value); } private string _chatFontFamily = "Segoe UI"; public string ChatFontFamily { get => _chatFontFamily; set => Set(ref _chatFontFamily, value); } private int _chatFadeSeconds; public int ChatFadeSeconds { get => _chatFadeSeconds; set => Set(ref _chatFadeSeconds, Math.Clamp(value, 0, 60)); } public override bool IsChatBox => Type == SourceType.ChatBox; private bool _chatPreviewEnabled = true; public bool ChatPreviewEnabled { get => _chatPreviewEnabled; set => Set(ref _chatPreviewEnabled, value); } }