Skip to content

Commit

Permalink
Update SvgImage.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
wieslawsoltes committed Mar 14, 2024
1 parent fae8793 commit 001cf40
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/Avalonia.Svg.Skia/SvgImage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Avalonia.Media;
using System;
using Avalonia.Media;
using Avalonia.Metadata;
using Svg.Model;

Expand All @@ -9,6 +10,11 @@ namespace Avalonia.Svg.Skia;
/// </summary>
public class SvgImage : AvaloniaObject, IImage
{
/// <summary>
/// Raised when the resource changes visually.
/// </summary>
public event EventHandler? Invalidated;

/// <summary>
/// Defines the <see cref="Source"/> property.
/// </summary>
Expand Down Expand Up @@ -99,6 +105,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
if (change.Property == SourceProperty)
{
// TODO: Invalidate IImage
RaiseInvalidated(EventArgs.Empty);
}

if (change.Property == CssProperty)
Expand All @@ -108,6 +115,7 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
if (Source?.Css != css)
{
Source?.ReLoad(new SvgParameters(null, css));
RaiseInvalidated(EventArgs.Empty);
}
}

Expand All @@ -118,7 +126,14 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
if (Source?.Css != css)
{
Source?.ReLoad(new SvgParameters(null, css));
RaiseInvalidated(EventArgs.Empty);
}
}
}

/// <summary>
/// Raises the <see cref="Invalidated"/> event.
/// </summary>
/// <param name="e">The event args.</param>
protected void RaiseInvalidated(EventArgs e) => Invalidated?.Invoke(this, e);
}

0 comments on commit 001cf40

Please sign in to comment.