Files

90 lines
2.5 KiB
C#

using System.Windows.Media;
using ytLive.Helpers;
namespace ytLive.Models;
public enum SourceType
{
DisplayCapture,
WindowCapture,
Background,
Image,
TextOverlay
}
public enum ClipShape
{
Traditional,
Round
}
/// <summary>
/// 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 cref="WebcamSceneConfig"/>. See the singleton-vs-multi-instance
/// discriminator in ai.md.
/// </summary>
public class Source : SceneElement
{
private SourceType _type;
public SourceType Type
{
get => _type;
set
{
if (Set(ref _type, value))
{
Raise(nameof(IsLiveCapture));
Raise(nameof(DisplaySource));
}
}
}
/// <summary>The permanent scene backdrop (live desktop/game capture). Never removable/reorderable.</summary>
private bool _isBackdrop;
public bool IsBackdrop { get => _isBackdrop; set => Set(ref _isBackdrop, 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); }
/// <summary>
/// Identifies what this live-capture source points at: "monitor:&lt;index&gt;" or
/// "window:&lt;hwnd&gt;". Persisted so a re-designated backdrop survives a reload.
/// </summary>
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;
public override bool IsImageSource => Type == SourceType.Image;
}