mirror of
https://github.com/Artemis-RGB/Artemis
synced 2026-11-12 03:48:56 +00:00
Profiles - Added system that displays when a layer is causing errors
This commit is contained in:
1 parent
3b7e226885
commit
5b6fc9eec7
18 files changed
+457
-95
No files matched your search
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Provides a default implementation for models that can have a broken state
|
||||
/// </summary>
|
||||
public abstract class BreakableModel : CorePropertyChanged, IBreakableModel
|
||||
{
|
||||
private string? _brokenState;
|
||||
private Exception? _brokenStateException;
|
||||
|
||||
/// <summary>
|
||||
/// Invokes the <see cref="BrokenStateChanged" /> event
|
||||
/// </summary>
|
||||
protected virtual void OnBrokenStateChanged()
|
||||
{
|
||||
BrokenStateChanged?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public abstract string BrokenDisplayName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the broken state of this breakable model, if <see langword="null" /> this model is not broken.
|
||||
/// <para>Note: If setting this manually you are also responsible for invoking <see cref="BrokenStateChanged" /></para>
|
||||
/// </summary>
|
||||
public string? BrokenState
|
||||
{
|
||||
get => _brokenState;
|
||||
set => SetAndNotify(ref _brokenState, value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the exception that caused the broken state
|
||||
/// <para>Note: If setting this manually you are also responsible for invoking <see cref="BrokenStateChanged" /></para>
|
||||
/// </summary>
|
||||
public Exception? BrokenStateException
|
||||
{
|
||||
get => _brokenStateException;
|
||||
set => SetAndNotify(ref _brokenStateException, value);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public bool TryOrBreak(Action action, string breakMessage)
|
||||
{
|
||||
try
|
||||
{
|
||||
action();
|
||||
ClearBrokenState(breakMessage);
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
SetBrokenState(breakMessage, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetBrokenState(string state, Exception? exception)
|
||||
{
|
||||
BrokenState = state ?? throw new ArgumentNullException(nameof(state));
|
||||
BrokenStateException = exception;
|
||||
OnBrokenStateChanged();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void ClearBrokenState(string state)
|
||||
{
|
||||
if (state == null) throw new ArgumentNullException(nameof(state));
|
||||
if (BrokenState == null)
|
||||
return;
|
||||
|
||||
if (BrokenState != state) return;
|
||||
BrokenState = null;
|
||||
BrokenStateException = null;
|
||||
OnBrokenStateChanged();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public virtual IEnumerable<IBreakableModel> GetBrokenHierarchy()
|
||||
{
|
||||
if (BrokenState != null)
|
||||
yield return this;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public event EventHandler? BrokenStateChanged;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Artemis.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents a model that can have a broken state
|
||||
/// </summary>
|
||||
public interface IBreakableModel
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the display name of this breakable model
|
||||
/// </summary>
|
||||
string BrokenDisplayName { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the broken state of this breakable model, if <see langword="null" /> this model is not broken.
|
||||
/// </summary>
|
||||
string? BrokenState { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the exception that caused the broken state
|
||||
/// </summary>
|
||||
Exception? BrokenStateException { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Try to execute the provided action. If the action succeeded the broken state is cleared if it matches
|
||||
/// <see paramref="breakMessage" />, if the action throws an exception <see cref="BrokenState" /> and
|
||||
/// <see cref="BrokenStateException" /> are set accordingly.
|
||||
/// </summary>
|
||||
/// <param name="action">The action to attempt to execute</param>
|
||||
/// <param name="breakMessage">The message to clear on succeed or set on failure (exception)</param>
|
||||
/// <returns><see langword="true" /> if the action succeeded; otherwise <see langword="false" />.</returns>
|
||||
bool TryOrBreak(Action action, string breakMessage);
|
||||
|
||||
/// <summary>
|
||||
/// Sets the broken state to the provided state and optional exception.
|
||||
/// </summary>
|
||||
/// <param name="state">The state to set the broken state to</param>
|
||||
/// <param name="exception">The exception that caused the broken state</param>
|
||||
public void SetBrokenState(string state, Exception? exception);
|
||||
|
||||
/// <summary>
|
||||
/// Clears the broken state and exception if <see cref="BrokenState" /> equals <see paramref="state"></see>.
|
||||
/// </summary>
|
||||
/// <param name="state"></param>
|
||||
public void ClearBrokenState(string state);
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list containing all broken models, including self and any children
|
||||
/// </summary>
|
||||
IEnumerable<IBreakableModel> GetBrokenHierarchy();
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when the broken state of this model changes
|
||||
/// </summary>
|
||||
event EventHandler BrokenStateChanged;
|
||||
}
|
||||
}
|
||||
@@ -183,18 +183,15 @@ namespace Artemis.Core
|
||||
|
||||
lock (Timeline)
|
||||
{
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
|
||||
{
|
||||
baseLayerEffect.BaseProperties?.Update(Timeline);
|
||||
baseLayerEffect.Update(Timeline.Delta.TotalSeconds);
|
||||
}
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
|
||||
baseLayerEffect.InternalUpdate(Timeline);
|
||||
|
||||
SKPaint layerPaint = new() {FilterQuality = SKFilterQuality.Low};
|
||||
try
|
||||
{
|
||||
SKRectI rendererBounds = SKRectI.Create(0, 0, Bounds.Width, Bounds.Height);
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
|
||||
baseLayerEffect.PreProcess(canvas, rendererBounds, layerPaint);
|
||||
baseLayerEffect.InternalPreProcess(canvas, rendererBounds, layerPaint);
|
||||
|
||||
// No point rendering if the alpha was set to zero by one of the effects
|
||||
if (layerPaint.Color.Alpha == 0)
|
||||
@@ -208,7 +205,7 @@ namespace Artemis.Core
|
||||
Children[index].Render(canvas, new SKPointI(Bounds.Left, Bounds.Top));
|
||||
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
|
||||
baseLayerEffect.PostProcess(canvas, rendererBounds, layerPaint);
|
||||
baseLayerEffect.InternalPostProcess(canvas, rendererBounds, layerPaint);
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -228,8 +225,6 @@ namespace Artemis.Core
|
||||
if (Enabled)
|
||||
return;
|
||||
|
||||
Debug.WriteLine($"Enabling {this}");
|
||||
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
|
||||
baseLayerEffect.InternalEnable();
|
||||
|
||||
@@ -248,8 +243,6 @@ namespace Artemis.Core
|
||||
if (!Enabled)
|
||||
return;
|
||||
|
||||
Debug.WriteLine($"Disabled {this}");
|
||||
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
|
||||
baseLayerEffect.InternalDisable();
|
||||
|
||||
@@ -344,5 +337,15 @@ namespace Artemis.Core
|
||||
{
|
||||
RenderPropertiesUpdated?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
#region Overrides of BreakableModel
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<IBreakableModel> GetBrokenHierarchy()
|
||||
{
|
||||
return LayerEffects.Where(e => e.BrokenState != null);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -206,6 +206,7 @@ namespace Artemis.Core
|
||||
GetType().GetProperty(nameof(Transform))!,
|
||||
typeof(PropertyGroupDescriptionAttribute)
|
||||
)!;
|
||||
|
||||
General.GroupDescription = (PropertyGroupDescriptionAttribute) generalAttribute;
|
||||
General.Initialize(this, "General.", Constants.CorePluginFeature);
|
||||
Transform.GroupDescription = (PropertyGroupDescriptionAttribute) transformAttribute;
|
||||
@@ -288,7 +289,7 @@ namespace Artemis.Core
|
||||
|
||||
// Adaption hints
|
||||
Adapter.Save();
|
||||
|
||||
|
||||
SaveRenderElement();
|
||||
}
|
||||
|
||||
@@ -320,7 +321,7 @@ namespace Artemis.Core
|
||||
{
|
||||
if (Disposed)
|
||||
throw new ObjectDisposedException("Layer");
|
||||
|
||||
|
||||
UpdateDisplayCondition();
|
||||
UpdateTimeline(deltaTime);
|
||||
|
||||
@@ -366,9 +367,17 @@ namespace Artemis.Core
|
||||
if (Enabled)
|
||||
return;
|
||||
|
||||
LayerBrush?.InternalEnable();
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
|
||||
baseLayerEffect.InternalEnable();
|
||||
bool tryOrBreak = TryOrBreak(() => LayerBrush?.InternalEnable(), "Failed to enable layer brush");
|
||||
if (!tryOrBreak)
|
||||
return;
|
||||
|
||||
tryOrBreak = TryOrBreak(() =>
|
||||
{
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects)
|
||||
baseLayerEffect.InternalEnable();
|
||||
}, "Failed to enable one or more effects");
|
||||
if (!tryOrBreak)
|
||||
return;
|
||||
|
||||
Enabled = true;
|
||||
}
|
||||
@@ -393,17 +402,10 @@ namespace Artemis.Core
|
||||
|
||||
General.Update(timeline);
|
||||
Transform.Update(timeline);
|
||||
if (LayerBrush != null)
|
||||
{
|
||||
LayerBrush.BaseProperties?.Update(timeline);
|
||||
LayerBrush.Update(timeline.Delta.TotalSeconds);
|
||||
}
|
||||
LayerBrush?.InternalUpdate(timeline);
|
||||
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
|
||||
{
|
||||
baseLayerEffect.BaseProperties?.Update(timeline);
|
||||
baseLayerEffect.Update(timeline.Delta.TotalSeconds);
|
||||
}
|
||||
baseLayerEffect.InternalUpdate(timeline);
|
||||
}
|
||||
|
||||
private void RenderTimeline(Timeline timeline, SKCanvas canvas, SKPointI basePosition)
|
||||
@@ -477,9 +479,9 @@ namespace Artemis.Core
|
||||
{
|
||||
if (LayerBrush == null)
|
||||
throw new ArtemisCoreException("The layer is not yet ready for rendering");
|
||||
|
||||
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
|
||||
baseLayerEffect.PreProcess(canvas, bounds, layerPaint);
|
||||
baseLayerEffect.InternalPreProcess(canvas, bounds, layerPaint);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -492,7 +494,7 @@ namespace Artemis.Core
|
||||
LayerBrush.InternalRender(canvas, bounds, layerPaint);
|
||||
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => !e.Suspended))
|
||||
baseLayerEffect.PostProcess(canvas, bounds, layerPaint);
|
||||
baseLayerEffect.InternalPostProcess(canvas, bounds, layerPaint);
|
||||
}
|
||||
|
||||
finally
|
||||
@@ -722,16 +724,24 @@ namespace Artemis.Core
|
||||
|
||||
internal void ActivateLayerBrush()
|
||||
{
|
||||
LayerBrushReference? current = General.BrushReference.CurrentValue;
|
||||
if (current == null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
LayerBrushReference? current = General.BrushReference.CurrentValue;
|
||||
if (current == null)
|
||||
return;
|
||||
|
||||
LayerBrushDescriptor? descriptor = current.LayerBrushProviderId != null && current.BrushType != null
|
||||
? LayerBrushStore.Get(current.LayerBrushProviderId, current.BrushType)?.LayerBrushDescriptor
|
||||
: null;
|
||||
descriptor?.CreateInstance(this);
|
||||
LayerBrushDescriptor? descriptor = current.LayerBrushProviderId != null && current.BrushType != null
|
||||
? LayerBrushStore.Get(current.LayerBrushProviderId, current.BrushType)?.LayerBrushDescriptor
|
||||
: null;
|
||||
descriptor?.CreateInstance(this);
|
||||
|
||||
OnLayerBrushUpdated();
|
||||
OnLayerBrushUpdated();
|
||||
ClearBrokenState("Failed to initialize layer brush");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
SetBrokenState("Failed to initialize layer brush", e);
|
||||
}
|
||||
}
|
||||
|
||||
internal void DeactivateLayerBrush()
|
||||
@@ -747,6 +757,19 @@ namespace Artemis.Core
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Overrides of BreakableModel
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<IBreakableModel> GetBrokenHierarchy()
|
||||
{
|
||||
if (LayerBrush?.BrokenState != null)
|
||||
yield return LayerBrush;
|
||||
foreach (BaseLayerEffect baseLayerEffect in LayerEffects.Where(e => e.BrokenState != null))
|
||||
yield return baseLayerEffect;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -27,6 +27,7 @@ namespace Artemis.Core
|
||||
|
||||
UndoStack = new MaxStack<string>(20);
|
||||
RedoStack = new MaxStack<string>(20);
|
||||
Exceptions = new List<Exception>();
|
||||
|
||||
Load();
|
||||
}
|
||||
@@ -77,6 +78,7 @@ namespace Artemis.Core
|
||||
|
||||
internal MaxStack<string> UndoStack { get; set; }
|
||||
internal MaxStack<string> RedoStack { get; set; }
|
||||
internal List<Exception> Exceptions { get; }
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Update(double deltaTime)
|
||||
@@ -113,6 +115,13 @@ namespace Artemis.Core
|
||||
|
||||
foreach (ProfileScript profileScript in Scripts)
|
||||
profileScript.OnProfileRendered(canvas, canvas.LocalClipBounds);
|
||||
|
||||
if (!Exceptions.Any())
|
||||
return;
|
||||
|
||||
List<Exception> exceptions = new(Exceptions);
|
||||
Exceptions.Clear();
|
||||
throw new AggregateException($"One or more exceptions while rendering profile {Name}", exceptions);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,5 +247,18 @@ namespace Artemis.Core
|
||||
ProfileEntity.ScriptConfigurations.Add(scriptConfiguration.Entity);
|
||||
}
|
||||
}
|
||||
|
||||
#region Overrides of BreakableModel
|
||||
|
||||
/// <inheritdoc />
|
||||
public override IEnumerable<IBreakableModel> GetBrokenHierarchy()
|
||||
{
|
||||
foreach (IBreakableModel breakableModel in GetAllFolders().SelectMany(folders => folders.GetBrokenHierarchy()))
|
||||
yield return breakableModel;
|
||||
foreach (IBreakableModel breakableModel in GetAllLayers().SelectMany(layer => layer.GetBrokenHierarchy()))
|
||||
yield return breakableModel;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ namespace Artemis.Core
|
||||
/// <summary>
|
||||
/// Represents an element of a <see cref="Profile" />
|
||||
/// </summary>
|
||||
public abstract class ProfileElement : CorePropertyChanged, IDisposable
|
||||
public abstract class ProfileElement : BreakableModel, IDisposable
|
||||
{
|
||||
private Guid _entityId;
|
||||
private string? _name;
|
||||
@@ -25,7 +25,7 @@ namespace Artemis.Core
|
||||
_profile = profile;
|
||||
ChildrenList = new List<ProfileElement>();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unique ID of this profile element
|
||||
/// </summary>
|
||||
@@ -121,6 +121,13 @@ namespace Artemis.Core
|
||||
return $"{nameof(EntityId)}: {EntityId}, {nameof(Order)}: {Order}, {nameof(Name)}: {Name}";
|
||||
}
|
||||
|
||||
#region Overrides of BreakableModel
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string BrokenDisplayName => Name ?? GetType().Name;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Hierarchy
|
||||
|
||||
/// <summary>
|
||||
@@ -234,7 +241,7 @@ namespace Artemis.Core
|
||||
internal abstract void Save();
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#region IDisposable
|
||||
|
||||
/// <inheritdoc />
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace Artemis.Core.LayerBrushes
|
||||
/// <summary>
|
||||
/// For internal use only, please use <see cref="LayerBrush{T}" /> or <see cref="PerLedLayerBrush{T}" /> or instead
|
||||
/// </summary>
|
||||
public abstract class BaseLayerBrush : CorePropertyChanged, IDisposable
|
||||
public abstract class BaseLayerBrush : BreakableModel, IDisposable
|
||||
{
|
||||
private LayerBrushType _brushType;
|
||||
private ILayerBrushConfigurationDialog? _configurationDialog;
|
||||
@@ -134,6 +134,12 @@ namespace Artemis.Core.LayerBrushes
|
||||
}
|
||||
}
|
||||
|
||||
internal void InternalUpdate(Timeline timeline)
|
||||
{
|
||||
BaseProperties?.Update(timeline);
|
||||
TryOrBreak(() => Update(timeline.Delta.TotalSeconds), "Failed to update");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the layer brush if it isn't already enabled
|
||||
/// </summary>
|
||||
@@ -142,7 +148,9 @@ namespace Artemis.Core.LayerBrushes
|
||||
if (Enabled)
|
||||
return;
|
||||
|
||||
EnableLayerBrush();
|
||||
if (!TryOrBreak(EnableLayerBrush, "Failed to enable"))
|
||||
return;
|
||||
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
@@ -170,6 +178,13 @@ namespace Artemis.Core.LayerBrushes
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
#region Overrides of BreakableModel
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string BrokenDisplayName => Descriptor.DisplayName;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -28,12 +28,12 @@ namespace Artemis.Core.LayerBrushes
|
||||
|
||||
internal override void InternalRender(SKCanvas canvas, SKRect bounds, SKPaint paint)
|
||||
{
|
||||
Render(canvas, bounds, paint);
|
||||
TryOrBreak(() => Render(canvas, bounds, paint), "Failed to render");
|
||||
}
|
||||
|
||||
internal override void Initialize()
|
||||
{
|
||||
InitializeProperties();
|
||||
TryOrBreak(InitializeProperties, "Failed to initialize");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ namespace Artemis.Core.LayerBrushes
|
||||
internal override void InternalRender(SKCanvas canvas, SKRect bounds, SKPaint paint)
|
||||
{
|
||||
// We don't want rotation on this canvas because that'll displace the LEDs, translations are applied to the points of each LED instead
|
||||
if (Layer.General.TransformMode.CurrentValue == LayerTransformMode.Normal && SupportsTransformation)
|
||||
if (Layer.General.TransformMode.CurrentValue == LayerTransformMode.Normal && SupportsTransformation)
|
||||
canvas.SetMatrix(canvas.TotalMatrix.PreConcat(Layer.GetTransformMatrix(true, false, false, true).Invert()));
|
||||
|
||||
using SKPath pointsPath = new();
|
||||
@@ -46,34 +46,38 @@ namespace Artemis.Core.LayerBrushes
|
||||
}
|
||||
|
||||
// Apply the translation to the points of each LED instead
|
||||
if (Layer.General.TransformMode.CurrentValue == LayerTransformMode.Normal && SupportsTransformation)
|
||||
if (Layer.General.TransformMode.CurrentValue == LayerTransformMode.Normal && SupportsTransformation)
|
||||
pointsPath.Transform(Layer.GetTransformMatrix(true, true, true, true).Invert());
|
||||
|
||||
SKPoint[] points = pointsPath.Points;
|
||||
for (int index = 0; index < Layer.Leds.Count; index++)
|
||||
|
||||
TryOrBreak(() =>
|
||||
{
|
||||
ArtemisLed artemisLed = Layer.Leds[index];
|
||||
SKPoint renderPoint = points[index * 2 + 1];
|
||||
if (!float.IsFinite(renderPoint.X) || !float.IsFinite(renderPoint.Y))
|
||||
continue;
|
||||
for (int index = 0; index < Layer.Leds.Count; index++)
|
||||
{
|
||||
ArtemisLed artemisLed = Layer.Leds[index];
|
||||
SKPoint renderPoint = points[index * 2 + 1];
|
||||
if (!float.IsFinite(renderPoint.X) || !float.IsFinite(renderPoint.Y))
|
||||
continue;
|
||||
|
||||
// Let the brush determine the color
|
||||
ledPaint.Color = GetColor(artemisLed, renderPoint);
|
||||
// Let the brush determine the color
|
||||
ledPaint.Color = GetColor(artemisLed, renderPoint);
|
||||
|
||||
SKRect ledRectangle = SKRect.Create(
|
||||
artemisLed.AbsoluteRectangle.Left - Layer.Bounds.Left,
|
||||
artemisLed.AbsoluteRectangle.Top - Layer.Bounds.Top,
|
||||
artemisLed.AbsoluteRectangle.Width,
|
||||
artemisLed.AbsoluteRectangle.Height
|
||||
);
|
||||
SKRect ledRectangle = SKRect.Create(
|
||||
artemisLed.AbsoluteRectangle.Left - Layer.Bounds.Left,
|
||||
artemisLed.AbsoluteRectangle.Top - Layer.Bounds.Top,
|
||||
artemisLed.AbsoluteRectangle.Width,
|
||||
artemisLed.AbsoluteRectangle.Height
|
||||
);
|
||||
|
||||
canvas.DrawRect(ledRectangle, ledPaint);
|
||||
}
|
||||
canvas.DrawRect(ledRectangle, ledPaint);
|
||||
}
|
||||
}, "Failed to render");
|
||||
}
|
||||
|
||||
internal override void Initialize()
|
||||
{
|
||||
InitializeProperties();
|
||||
TryOrBreak(InitializeProperties, "Failed to initialize");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
using System;
|
||||
using Artemis.Core.Services;
|
||||
using SkiaSharp;
|
||||
|
||||
namespace Artemis.Core.LayerEffects
|
||||
@@ -7,7 +6,7 @@ namespace Artemis.Core.LayerEffects
|
||||
/// <summary>
|
||||
/// For internal use only, please use <see cref="LayerEffect{T}" /> instead
|
||||
/// </summary>
|
||||
public abstract class BaseLayerEffect : CorePropertyChanged, IDisposable
|
||||
public abstract class BaseLayerEffect : BreakableModel, IDisposable
|
||||
{
|
||||
private ILayerEffectConfigurationDialog? _configurationDialog;
|
||||
private LayerEffectDescriptor _descriptor;
|
||||
@@ -182,6 +181,22 @@ namespace Artemis.Core.LayerEffects
|
||||
|
||||
internal virtual string GetEffectTypeName() => GetType().Name;
|
||||
|
||||
internal void InternalUpdate(Timeline timeline)
|
||||
{
|
||||
BaseProperties?.Update(timeline);
|
||||
TryOrBreak(() => Update(timeline.Delta.TotalSeconds), "Failed to update");
|
||||
}
|
||||
|
||||
internal void InternalPreProcess(SKCanvas canvas, SKRect renderBounds, SKPaint paint)
|
||||
{
|
||||
TryOrBreak(() => PreProcess(canvas, renderBounds, paint), "Failed to pre-process");
|
||||
}
|
||||
|
||||
internal void InternalPostProcess(SKCanvas canvas, SKRect renderBounds, SKPaint paint)
|
||||
{
|
||||
TryOrBreak(() => PostProcess(canvas, renderBounds, paint), "Failed to post-process");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enables the layer effect if it isn't already enabled
|
||||
/// </summary>
|
||||
@@ -205,5 +220,12 @@ namespace Artemis.Core.LayerEffects
|
||||
DisableLayerEffect();
|
||||
Enabled = false;
|
||||
}
|
||||
|
||||
#region Overrides of BreakableModel
|
||||
|
||||
/// <inheritdoc />
|
||||
public override string BrokenDisplayName => Name;
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user