90 lines
2.5 KiB
C#
90 lines
2.5 KiB
C#
using System.ComponentModel;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Windows.Media;
|
|
using ytLive.Helpers;
|
|
|
|
namespace ytLive.Models;
|
|
|
|
public enum SourceType
|
|
{
|
|
DisplayCapture,
|
|
WindowCapture,
|
|
Webcam,
|
|
Background,
|
|
Image,
|
|
TextOverlay
|
|
}
|
|
|
|
public class Source : INotifyPropertyChanged
|
|
{
|
|
public event PropertyChangedEventHandler? PropertyChanged;
|
|
|
|
private void Raise([CallerMemberName] string? name = null)
|
|
=> PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));
|
|
|
|
private bool Set<T>(ref T field, T value, [CallerMemberName] string? name = null)
|
|
{
|
|
if (EqualityComparer<T>.Default.Equals(field, value)) return false;
|
|
field = value;
|
|
Raise(name);
|
|
return true;
|
|
}
|
|
|
|
public string Id { get; init; } = Guid.NewGuid().ToString();
|
|
|
|
private string _name = string.Empty;
|
|
public string Name { get => _name; set => Set(ref _name, value); }
|
|
|
|
private SourceType _type;
|
|
public SourceType Type { get => _type; set => Set(ref _type, 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); }
|
|
|
|
// Webcam
|
|
private string? _deviceId;
|
|
public string? DeviceId { get => _deviceId; set => Set(ref _deviceId, value); }
|
|
|
|
// 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));
|
|
}
|
|
}
|
|
}
|
|
|
|
public ImageSource? ImageSource => _imageSource;
|
|
|
|
// Position/transform (per-scene usage)
|
|
private double _x;
|
|
public double X { get => _x; set => Set(ref _x, value); }
|
|
|
|
private double _y;
|
|
public double Y { get => _y; set => Set(ref _y, value); }
|
|
|
|
private double _width;
|
|
public double Width { get => _width; set => Set(ref _width, value); }
|
|
|
|
private double _height;
|
|
public double Height { get => _height; set => Set(ref _height, value); }
|
|
|
|
private double _opacity = 1.0;
|
|
public double Opacity { get => _opacity; set => Set(ref _opacity, value); }
|
|
}
|