Scene/source builder with image overlays, reuse dialog, and SQLite layout persistence
This commit is contained in:
+69
-15
@@ -1,3 +1,8 @@
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows.Media;
|
||||
using ytLive.Helpers;
|
||||
|
||||
namespace ytLive.Models;
|
||||
|
||||
public enum SourceType
|
||||
@@ -5,31 +10,80 @@ public enum SourceType
|
||||
DisplayCapture,
|
||||
WindowCapture,
|
||||
Webcam,
|
||||
Background,
|
||||
Image,
|
||||
TextOverlay
|
||||
}
|
||||
|
||||
public class Source
|
||||
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();
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public SourceType Type { get; set; }
|
||||
public bool IsEnabled { get; set; } = true;
|
||||
|
||||
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
|
||||
public int? MonitorIndex { get; set; }
|
||||
public IntPtr? WindowHandle { get; set; }
|
||||
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
|
||||
public string? DeviceId { get; set; }
|
||||
private string? _deviceId;
|
||||
public string? DeviceId { get => _deviceId; set => Set(ref _deviceId, value); }
|
||||
|
||||
// Image
|
||||
public string? FilePath { get; set; }
|
||||
// Image (asset stored in the layout database)
|
||||
private string? _assetId;
|
||||
private ImageSource? _imageSource;
|
||||
|
||||
// Position/transform
|
||||
public double X { get; set; }
|
||||
public double Y { get; set; }
|
||||
public double Width { get; set; }
|
||||
public double Height { get; set; }
|
||||
public double Opacity { get; set; } = 1.0;
|
||||
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); }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user