Files
LlamaCasty/Models/WebcamSceneConfig.cs
T

61 lines
2.4 KiB
C#

using System.Windows.Media;
namespace ytLive.Models;
/// <summary>
/// A scene's usage of the app-wide webcam — conceptually `webcam.{scene}.config`.
/// The identity lives once on the <see cref="Webcam"/> entity; this object is that
/// scene's placement, clip/mirror, border, and visibility for it. Exists only in
/// scenes where the creator added the webcam.
/// </summary>
public class WebcamSceneConfig : SceneElement
{
public string WebcamId { get; init; } = string.Empty;
public override bool IsWebcam => true;
public override bool IsDraggable => true;
public override ElementKind Kind => ElementKind.Dynamic;
public override ImageSource? DisplaySource => VideoImageSource;
private BackgroundEffect _backgroundEffect = BackgroundEffect.None;
/// <summary>TASK 51: this scene's background effect for the webcam (persisted).</summary>
public BackgroundEffect BackgroundEffect
{
get => _backgroundEffect;
set
{
if (!Set(ref _backgroundEffect, value)) return;
Raise(nameof(RemoveBackground));
Raise(nameof(BlurBackground));
Raise(nameof(HasBackgroundEffect));
}
}
/// <summary>True while Remove or Blur is on — shows the strength slider.</summary>
public bool HasBackgroundEffect => BackgroundEffect != BackgroundEffect.None;
private double _backgroundStrength = 0.5;
/// <summary>TASK 51: 0..1 — Blur amount, or Remove's edge softness (persisted).</summary>
public double BackgroundStrength
{
get => _backgroundStrength;
set => Set(ref _backgroundStrength, Math.Clamp(value, 0, 1));
}
/// <summary>Pill-switch surface: Remove and Blur behave like radio buttons — turning one
/// on turns the other off; turning the active one off means <see cref="BackgroundEffect.None"/>.</summary>
public bool RemoveBackground
{
get => BackgroundEffect == BackgroundEffect.Remove;
set => BackgroundEffect = value ? BackgroundEffect.Remove
: BackgroundEffect == BackgroundEffect.Remove ? BackgroundEffect.None : BackgroundEffect;
}
/// <inheritdoc cref="RemoveBackground"/>
public bool BlurBackground
{
get => BackgroundEffect == BackgroundEffect.Blur;
set => BackgroundEffect = value ? BackgroundEffect.Blur
: BackgroundEffect == BackgroundEffect.Blur ? BackgroundEffect.None : BackgroundEffect;
}
}