Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<VersionPrefix>3.3.0</VersionPrefix>
<VersionPrefix>3.4.0</VersionPrefix>
<VersionSuffix></VersionSuffix>
<AvaloniaVersionPrefix>11.3.9</AvaloniaVersionPrefix>
<AvaloniaVersionPrefix>11.3.9.1</AvaloniaVersionPrefix>
<AvaloniaVersionSuffix>$(VersionSuffix)</AvaloniaVersionSuffix>
<Authors>Wiesław Šoltés</Authors>
<Company>Wiesław Šoltés</Company>
Expand Down
2 changes: 1 addition & 1 deletion samples/AvaloniaSvgSample/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
HorizontalAlignment="Stretch">
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,*">
<TextBlock Text="Original" />
<TextBlock Grid.Column="1" Text="Modified" />
<TextBlock Grid.Column="1" Text="Clone (Grayscale)" />
<Image Grid.Row="1" Name="svgModelOriginal" />
<Image Grid.Row="1" Grid.Column="1" Name="svgModelModified" />
</Grid>
Expand Down
12 changes: 8 additions & 4 deletions samples/AvaloniaSvgSample/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
{
e.DragEffects = e.DragEffects & (DragDropEffects.Copy | DragDropEffects.Link);

if (!e.Data.Contains(DataFormats.Files))

Check warning on line 92 in samples/AvaloniaSvgSample/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

'DataFormats.Files' is obsolete: 'Use DataFormat.File instead.'

Check warning on line 92 in samples/AvaloniaSvgSample/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

'DragEventArgs.Data' is obsolete: 'Use DataTransfer instead.'
{
e.DragEffects = DragDropEffects.None;
}
Expand All @@ -97,7 +97,7 @@

private void Drop(object sender, DragEventArgs e)
{
if (e.Data.Contains(DataFormats.Files))

Check warning on line 100 in samples/AvaloniaSvgSample/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

'DragEventArgs.Data' is obsolete: 'Use DataTransfer instead.'
{
var fileName = e.Data.GetFileNames()?.FirstOrDefault();
if (!string.IsNullOrWhiteSpace(fileName))
Expand Down Expand Up @@ -141,11 +141,15 @@
var assemblyName = typeof(MainWindow).Assembly.GetName().Name ?? "AvaloniaSvgSample";
var resourcePath = $"avares://{assemblyName}/Assets/__tiger.svg";
var originalSource = SvgSource.Load(resourcePath, null);
svgModelOriginal.Source = new SvgImage { Source = originalSource };
var originalImage = new SvgImage { Source = originalSource };
svgModelOriginal.Source = originalImage;

var modifiedSource = SvgSource.Load(resourcePath, null);
ApplyGrayscale(modifiedSource);
svgModelModified.Source = new SvgImage { Source = modifiedSource };
var cloneImage = originalImage.Clone();
if (cloneImage.Source is { } cloneSource)
{
ApplyGrayscale(cloneSource);
}
svgModelModified.Source = cloneImage;
}

private static void ApplyGrayscale(SvgSource source)
Expand Down
2 changes: 1 addition & 1 deletion samples/AvaloniaSvgSkiaSample/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
HorizontalAlignment="Stretch">
<Grid ColumnDefinitions="*,*" RowDefinitions="Auto,*">
<TextBlock Text="Original" />
<TextBlock Grid.Column="1" Text="Modified" />
<TextBlock Grid.Column="1" Text="Clone (Grayscale)" />
<Image Grid.Row="1" Name="svgModelOriginal" />
<Image Grid.Row="1" Grid.Column="1" Name="svgModelModified" />
</Grid>
Expand Down
12 changes: 8 additions & 4 deletions samples/AvaloniaSvgSkiaSample/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
{
e.DragEffects = e.DragEffects & (DragDropEffects.Copy | DragDropEffects.Link);

if (!e.Data.Contains(DataFormats.Files))

Check warning on line 92 in samples/AvaloniaSvgSkiaSample/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

'DataFormats.Files' is obsolete: 'Use DataFormat.File instead.'

Check warning on line 92 in samples/AvaloniaSvgSkiaSample/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

'DragEventArgs.Data' is obsolete: 'Use DataTransfer instead.'
{
e.DragEffects = DragDropEffects.None;
}
Expand All @@ -97,9 +97,9 @@

private void Drop(object sender, DragEventArgs e)
{
if (e.Data.Contains(DataFormats.Files))

Check warning on line 100 in samples/AvaloniaSvgSkiaSample/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

'DataFormats.Files' is obsolete: 'Use DataFormat.File instead.'

Check warning on line 100 in samples/AvaloniaSvgSkiaSample/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

'DragEventArgs.Data' is obsolete: 'Use DataTransfer instead.'
{
var fileName = e.Data.GetFileNames()?.FirstOrDefault();

Check warning on line 102 in samples/AvaloniaSvgSkiaSample/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

'DataObjectExtensions.GetFileNames(IDataObject)' is obsolete: 'Use GetFiles, this method is supported only on desktop platforms.'

Check warning on line 102 in samples/AvaloniaSvgSkiaSample/MainWindow.axaml.cs

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

'DragEventArgs.Data' is obsolete: 'Use DataTransfer instead.'
if (!string.IsNullOrWhiteSpace(fileName))
{
if (sender == svgSvgDockPanel)
Expand Down Expand Up @@ -153,11 +153,15 @@
var assemblyName = typeof(MainWindow).Assembly.GetName().Name ?? "AvaloniaSvgSkiaSample";
var resourcePath = $"avares://{assemblyName}/Assets/__tiger.svg";
var originalSource = SvgSource.Load(resourcePath, null);
svgModelOriginal.Source = new SvgImage { Source = originalSource };
var originalImage = new SvgImage { Source = originalSource };
svgModelOriginal.Source = originalImage;

var modifiedSource = SvgSource.Load(resourcePath, null);
ApplyGrayscale(modifiedSource);
svgModelModified.Source = new SvgImage { Source = modifiedSource };
var cloneImage = originalImage.Clone();
if (cloneImage.Source is { } cloneSource)
{
ApplyGrayscale(cloneSource);
}
svgModelModified.Source = cloneImage;
}

private static void ApplyGrayscale(SvgSource source)
Expand Down
1 change: 1 addition & 0 deletions samples/TestApp/TestApp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"Paths":["/Users/wieslawsoltes/Downloads/svg/demos/__AJ_Digital_Camera.svg","/Users/wieslawsoltes/Downloads/svg/demos/__issue-134-01.svg","/Users/wieslawsoltes/Downloads/svg/demos/__issue-227-02.svg","/Users/wieslawsoltes/Downloads/svg/demos/__issue-252-01.svg","/Users/wieslawsoltes/Downloads/svg/demos/__Telefunken_FuBK_test_pattern.svg","/Users/wieslawsoltes/Downloads/svg/demos/__tiger.svg","/Users/wieslawsoltes/Downloads/svg/demos/!opacity.svg","/Users/wieslawsoltes/Downloads/svg/demos/bunny.svg","/Users/wieslawsoltes/Downloads/svg/demos/compuserver_msn_Ford_Focus.svg","/Users/wieslawsoltes/Downloads/svg/demos/Example.svg","/Users/wieslawsoltes/Downloads/svg/demos/ExportFile_16x.svg","/Users/wieslawsoltes/Downloads/svg/demos/feGaussianBlur.svg","/Users/wieslawsoltes/Downloads/svg/demos/gallardo.svg","/Users/wieslawsoltes/Downloads/svg/demos/ios_app_buttons.svg","/Users/wieslawsoltes/Downloads/svg/demos/KOMPAS-Graphic.svg","/Users/wieslawsoltes/Downloads/svg/demos/logo.svg","/Users/wieslawsoltes/Downloads/svg/demos/marker.svg","/Users/wieslawsoltes/Downloads/svg/demos/opacity-groups.svg","/Users/wieslawsoltes/Downloads/svg/demos/pattern.svg","/Users/wieslawsoltes/Downloads/svg/demos/stroke-miterlimit.svg","/Users/wieslawsoltes/Downloads/svg/demos/SVG_logo.svg","/Users/wieslawsoltes/Downloads/svg/demos/svglogo_.svg","/Users/wieslawsoltes/Downloads/svg/demos/svglogo.svg","/Users/wieslawsoltes/Downloads/svg/demos/symbol.svg","/Users/wieslawsoltes/Downloads/svg/demos/tommek_Car.svg","/Users/wieslawsoltes/Downloads/svg/demos/use.svg"],"Query":null}
15 changes: 15 additions & 0 deletions src/Svg.Controls.Avalonia/SvgImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,21 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
}
}

/// <summary>
/// Creates a deep clone of this <see cref="SvgImage"/> with an independent source.
/// </summary>
/// <returns>A new <see cref="SvgImage"/> instance.</returns>
public SvgImage Clone()
{
var clone = new SvgImage();
if (Source is { } source)
{
clone.Source = source.Clone();
}

return clone;
}

/// <summary>
/// Raises the <see cref="Invalidated"/> event.
/// </summary>
Expand Down
12 changes: 12 additions & 0 deletions src/Svg.Controls.Avalonia/SvgSource.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,4 +145,16 @@ public void RebuildFromModel()

Picture = picture.DeepClone();
}

/// <summary>
/// Creates a deep clone of this <see cref="SvgSource"/>.
/// </summary>
/// <returns>A new <see cref="SvgSource"/> instance.</returns>
public SvgSource Clone()
{
return new SvgSource
{
Picture = Picture?.DeepClone()
};
}
}
5 changes: 1 addition & 4 deletions src/Svg.Controls.Skia.Avalonia/SvgCustomDrawOperation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ public void Render(ImmediateDrawingContext context)
return;
}

lock (_svg.Sync)
{
_svg.Draw(canvas);
}
_svg.Draw(canvas);
}
}
22 changes: 18 additions & 4 deletions src/Svg.Controls.Skia.Avalonia/SvgImage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
{
var css = string.Concat(change.GetNewValue<string>(), ' ', CurrentCss);

if (Source?.Css != css)
if (Source is { } source && source.Css != css)
{
Source?.ReLoad(new SvgParameters(null, css));
source.ReLoad(new SvgParameters(source.Parameters?.Entities, css));
RaiseInvalidated(EventArgs.Empty);
}
}
Expand All @@ -125,14 +125,28 @@ protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs chang
{
var css = string.Concat(Css, ' ', change.GetNewValue<string>());

if (Source?.Css != css)
if (Source is { } source && source.Css != css)
{
Source?.ReLoad(new SvgParameters(null, css));
source.ReLoad(new SvgParameters(source.Parameters?.Entities, css));
RaiseInvalidated(EventArgs.Empty);
}
}
}

/// <summary>
/// Creates a deep clone of this <see cref="SvgImage"/> with an independent source.
/// </summary>
/// <returns>A new <see cref="SvgImage"/> instance.</returns>
public SvgImage Clone()
{
return new SvgImage
{
Source = Source?.Clone(),
Css = Css,
CurrentCss = CurrentCss
};
}

/// <summary>
/// Raises the <see cref="Invalidated"/> event.
/// </summary>
Expand Down
Loading
Loading