using System;
using Annulus;
using Blacklight.Core;
using Glass.Blacklight;
using Prism;
namespace Glass.Testbed
{
///
/// A flat fill whose next drawing can be made to throw.
///
public record FaultyMaterial : Material
{
private static readonly SolidColorMaterial Gray =
new SolidColorMaterial { Color = Color.FromArgb(255, 70, 74, 84) };
public class Fault
{
public bool Armed;
}
public Material Fill { get; init; } = Gray;
///
/// Gets what says whether the next drawing throws.
///
public Fault NextDraw { get; init; } = new Fault();
public static void Render(Renderer renderer, Cel context, FaultyMaterial material, Rect rect,
in DrawState drawState)
{
if (material.NextDraw.Armed)
{
material.NextDraw.Armed = false;
throw new InvalidOperationException("A test exception thrown while drawing.");
}
renderer.Render(context, material.Fill, rect, in drawState);
}
}
}