Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
aa68dfd
Add hit testing demo and tests
wieslawsoltes Jul 13, 2025
6b30300
Fix SKSvg drawing call
wieslawsoltes Jul 13, 2025
550ac50
Fix hit bounds toggle and item binding
wieslawsoltes Jul 13, 2025
513efdd
Refactor hit test handling
wieslawsoltes Jul 13, 2025
39dc54b
Fix SvgElement reference and expose SKSvg hit helpers
wieslawsoltes Jul 13, 2025
a6188ad
Add text hit testing support
wieslawsoltes Jul 13, 2025
0494d71
Implement matrix inversion and adjust text bounds
wieslawsoltes Jul 13, 2025
3575ea6
Fix hit test IDs and adjust build
wieslawsoltes Jul 13, 2025
08ac119
Allow hit tests to return elements lacking IDs
wieslawsoltes Jul 13, 2025
6efd0bd
Update _build.csproj
wieslawsoltes Jul 13, 2025
75ec420
Use net9.0
wieslawsoltes Jul 13, 2025
bebf292
Update SvgService.cs
wieslawsoltes Jul 13, 2025
d9e36d2
Update Svg.Model.csproj
wieslawsoltes Jul 13, 2025
9a1b12f
Update Svg.Skia.csproj
wieslawsoltes Jul 13, 2025
56cdcda
Update HitTestTests.cs
wieslawsoltes Jul 13, 2025
bf3b14f
Update Svg.Model.csproj
wieslawsoltes Jul 13, 2025
1adec7d
Update MainView.axaml
wieslawsoltes Jul 13, 2025
d87581d
Update MainView.axaml.cs
wieslawsoltes Jul 13, 2025
9d40ae0
Update SKSvg.Model.cs
wieslawsoltes Jul 13, 2025
5050355
Split
wieslawsoltes Jul 13, 2025
fb61ec2
Add ShimSkiaSharp unit tests
wieslawsoltes Jul 13, 2025
92e77ad
Merge pull request #312 from wieslawsoltes/codex/add-unit-test-projec…
wieslawsoltes Jul 13, 2025
89d6baf
Update Avalonia.Svg.Skia.UiTests.csproj
wieslawsoltes Jul 13, 2025
bd48d25
Add unit tests for ShimSkiaSharp classes
wieslawsoltes Jul 13, 2025
1153b8a
Add tests for basic geometry structs
wieslawsoltes Jul 13, 2025
010e7fc
Merge pull request #313 from wieslawsoltes/codex/add-unit-tests-for-s…
wieslawsoltes Jul 13, 2025
0ac8997
Merge pull request #314 from wieslawsoltes/codex/add-unit-tests-for-s…
wieslawsoltes Jul 13, 2025
9172d11
Add unit tests for ShimSkiaSharp classes
wieslawsoltes Jul 13, 2025
b39940b
Update Avalonia.Svg.Skia.UiTests.sln
wieslawsoltes Jul 13, 2025
dd5b43f
Merge pull request #315 from wieslawsoltes/codex/add-unit-tests-for-s…
wieslawsoltes Jul 13, 2025
e84cb63
Fix
wieslawsoltes Jul 13, 2025
eb6cdeb
Update SvgToPng.csproj
wieslawsoltes Jul 13, 2025
5339aa4
Update Svg.Skia.sln
wieslawsoltes Jul 13, 2025
06ef844
Add OnDraw event to SKSvg and handle drawing hit bounds in TestApp
wieslawsoltes Jul 13, 2025
d0c8928
Update MainView.axaml.cs
wieslawsoltes Jul 13, 2025
b1d444e
Update SKSvgDrawEventArgs.cs
wieslawsoltes Jul 13, 2025
832fbc0
Merge pull request #316 from wieslawsoltes/codex/refactor-drawing-log…
wieslawsoltes Jul 13, 2025
cbec70e
remove hit test props from settings
wieslawsoltes Jul 13, 2025
c0e8cc1
Merge pull request #317 from wieslawsoltes/codex/remove-hittest-prope…
wieslawsoltes Jul 13, 2025
1b56e33
Update MainView.axaml.cs
wieslawsoltes Jul 13, 2025
4f36d23
Use actual text metrics
wieslawsoltes Jul 14, 2025
1f97dd1
Add font metrics support via asset loader
wieslawsoltes Jul 14, 2025
25f090c
Implement text measurement stubs for ImageSharp
wieslawsoltes Jul 14, 2025
86a74d7
Fallback text metrics for unsupported loaders
wieslawsoltes Jul 14, 2025
ca767b4
Merge pull request #318 from wieslawsoltes/codex/remove-text-length-e…
wieslawsoltes Jul 14, 2025
897267b
Update SKSvg.Model.cs
wieslawsoltes Jul 14, 2025
f4a2111
Improve path bounds and line hit testing
wieslawsoltes Jul 14, 2025
fec23fe
Add hit tests for path commands
wieslawsoltes Jul 14, 2025
1dea18e
Use System.Math for line distance
wieslawsoltes Jul 14, 2025
9fe800c
Refactor path bounds math to helper
wieslawsoltes Jul 14, 2025
264b901
Merge pull request #319 from wieslawsoltes/codex/improve-precision-of…
wieslawsoltes Jul 14, 2025
1d328a3
Fix arc hit test
wieslawsoltes Jul 14, 2025
6c9fa56
Merge pull request #322 from wieslawsoltes/codex/fix-assert.contains-…
wieslawsoltes Jul 14, 2025
6926844
Update HitTestService.cs
wieslawsoltes Jul 14, 2025
73a7600
Update SKSvgDrawEventArgs.cs
wieslawsoltes Jul 14, 2025
9e262b3
Update SKSvgSettings.cs
wieslawsoltes Jul 14, 2025
f67d29d
Improve arc bounds and thread-safety
wieslawsoltes Jul 14, 2025
671fc54
Merge pull request #323 from wieslawsoltes/codex/implement-potential-…
wieslawsoltes Jul 14, 2025
bd50c59
Avoid recursive filter application
wieslawsoltes Jul 14, 2025
55d4afb
Remove unnecessary metrics fallback
wieslawsoltes Jul 14, 2025
ded0a95
Merge pull request #324 from wieslawsoltes/codex/fix-svg-rendering-cr…
wieslawsoltes Jul 14, 2025
93661c2
Update resvgTests.cs
wieslawsoltes Jul 14, 2025
6c866db
docs: add hit testing section
wieslawsoltes Jul 14, 2025
be2edef
Merge pull request #325 from wieslawsoltes/codex/add-hit-testing-sect…
wieslawsoltes Jul 14, 2025
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
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,42 @@ using (var svg = new SKSvg())
}
```

### Hit Testing

#### SKSvg

The `SKSvg` class provides helpers for retrieving elements or drawables at a
given point. The hit-testing methods expect coordinates in picture space:

```C#
using SkiaSharp;
using Svg.Skia;

var svg = new SKSvg();
if (svg.Load("image.svg") is { })
{
var element = svg.HitTestElements(new SKPoint(10, 10)).FirstOrDefault();
if (element is { })
{
Console.WriteLine(element.ID);
}
}
```

When drawing on a transformed canvas you can convert canvas coordinates to
picture coordinates using `TryGetPicturePoint` and then use the hit-testing
methods.

#### Svg control

The `Svg` Avalonia control exposes a `HitTestElements` method that accepts
a point in control coordinates and returns the matching SVG elements:

```C#
var hits = svgControl.HitTestElements(new Point(x, y));
```


### Avalonia

#### Install Package
Expand Down
14 changes: 14 additions & 0 deletions Svg.Skia.sln
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{7863AE7D
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Svg.Skia.UnitTests", "tests\Svg.Skia.UnitTests\Svg.Skia.UnitTests.csproj", "{1BD5FA09-D543-4315-99A6-81E9DD8746EC}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ShimSkiaSharp.UnitTests", "tests\\ShimSkiaSharp.UnitTests\\ShimSkiaSharp.UnitTests.csproj", "{A2367B2B-5371-4ED0-BB9D-9532046F44E8}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{B65D5B3A-77BE-4AFF-B502-A136B9C932F8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Svg.Controls.Skia.Avalonia", "src\Svg.Controls.Skia.Avalonia\Svg.Controls.Skia.Avalonia.csproj", "{8BAAB509-6073-4D68-9F16-EA28986839B1}"
Expand Down Expand Up @@ -113,6 +115,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AvaloniaSvgSkiaStylingSampl
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Svg.Generators", "externals\Svg.Generators\Svg.Generators.csproj", "{A27DF58D-4865-4233-9D1A-476DF155EC8C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgToPng", "samples\SvgToPng\SvgToPng.csproj", "{73BC0285-F170-49CB-ACDF-B5AFCC8F435E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -131,6 +135,10 @@ Global
{1BD5FA09-D543-4315-99A6-81E9DD8746EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1BD5FA09-D543-4315-99A6-81E9DD8746EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1BD5FA09-D543-4315-99A6-81E9DD8746EC}.Release|Any CPU.Build.0 = Release|Any CPU
{A2367B2B-5371-4ED0-BB9D-9532046F44E8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A2367B2B-5371-4ED0-BB9D-9532046F44E8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A2367B2B-5371-4ED0-BB9D-9532046F44E8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A2367B2B-5371-4ED0-BB9D-9532046F44E8}.Release|Any CPU.Build.0 = Release|Any CPU
{8BAAB509-6073-4D68-9F16-EA28986839B1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BAAB509-6073-4D68-9F16-EA28986839B1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BAAB509-6073-4D68-9F16-EA28986839B1}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -207,6 +215,10 @@ Global
{A27DF58D-4865-4233-9D1A-476DF155EC8C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A27DF58D-4865-4233-9D1A-476DF155EC8C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A27DF58D-4865-4233-9D1A-476DF155EC8C}.Release|Any CPU.Build.0 = Release|Any CPU
{73BC0285-F170-49CB-ACDF-B5AFCC8F435E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73BC0285-F170-49CB-ACDF-B5AFCC8F435E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73BC0285-F170-49CB-ACDF-B5AFCC8F435E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{73BC0285-F170-49CB-ACDF-B5AFCC8F435E}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -218,6 +230,7 @@ Global
{D0720395-9892-4CE1-9F25-C6117085B6F8} = {32B4A27D-6FC0-498C-9AD8-5510ACF2C4A1}
{5BFEF4F8-2BA7-4050-8E5B-F03A072C2B17} = {32B4A27D-6FC0-498C-9AD8-5510ACF2C4A1}
{1BD5FA09-D543-4315-99A6-81E9DD8746EC} = {7863AE7D-FF68-45BF-BA68-6FA0E5604CB7}
{A2367B2B-5371-4ED0-BB9D-9532046F44E8} = {7863AE7D-FF68-45BF-BA68-6FA0E5604CB7}
{8BAAB509-6073-4D68-9F16-EA28986839B1} = {4C42912C-9F8C-43D9-A4B5-4427F7EC8F18}
{81724F00-B7C3-4E25-B473-C7433BABDC81} = {B65D5B3A-77BE-4AFF-B502-A136B9C932F8}
{CFA46E73-0050-4C57-85CE-6C5868A2483C} = {C5FFCF4B-86DC-453E-8006-44EE9EEFEE39}
Expand All @@ -238,6 +251,7 @@ Global
{B742F260-0EC6-4805-AE9F-987818CE3CF4} = {4C42912C-9F8C-43D9-A4B5-4427F7EC8F18}
{8A938DC2-1634-4387-BAB3-69F871D54FB5} = {B65D5B3A-77BE-4AFF-B502-A136B9C932F8}
{A27DF58D-4865-4233-9D1A-476DF155EC8C} = {C5FFCF4B-86DC-453E-8006-44EE9EEFEE39}
{73BC0285-F170-49CB-ACDF-B5AFCC8F435E} = {B65D5B3A-77BE-4AFF-B502-A136B9C932F8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {12D5E557-A27B-4FB2-83A3-4AC75B04B22C}
Expand Down
10 changes: 5 additions & 5 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "9.0.100",
"rollForward": "latestMinor",
"allowPrerelease": true
}
"sdk": {
"version": "9.0.100",
"rollForward": "latestMinor",
"allowPrerelease": true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>False</IsPackable>
<Nullable>disable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>False</IsPackable>
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
Expand Down
2 changes: 1 addition & 1 deletion samples/AvaloniaSvgSample/AvaloniaSvgSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>False</IsPackable>
<Nullable>disable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion samples/AvaloniaSvgSkiaSample/AvaloniaSvgSkiaSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>False</IsPackable>
<Nullable>disable</Nullable>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>False</IsPackable>
<Nullable>disable</Nullable>
Expand Down
2 changes: 1 addition & 1 deletion samples/Svg.Skia.Converter/Svg.Skia.Converter.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<EnableDefaultCompileItems>False</EnableDefaultCompileItems>
<EnableDefaultItems>False</EnableDefaultItems>
<NoWarn>CS1591</NoWarn>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<IsPackable>False</IsPackable>
<LangVersion>latest</LangVersion>
<EmitCompilerGeneratedFiles>true</EmitCompilerGeneratedFiles>
Expand Down
5 changes: 3 additions & 2 deletions samples/SvgToPng/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
using System.Windows.Controls;
using System.Windows.Input;
using Svg.Model;
using Svg.Model.Services;
using SvgToPng.ViewModels;

namespace SvgToPng;
Expand All @@ -23,7 +24,7 @@ public MainWindow()
{
InitializeComponent();
#if DEBUG
SvgExtensions.s_systemLanguageOverride = CultureInfo.CreateSpecificCulture("en-US");
SvgService.s_systemLanguageOverride = CultureInfo.CreateSpecificCulture("en-US");
#endif
var vm = MainWindowViewModel.Load<MainWindowViewModel>("VM.json");
if (vm is { })
Expand Down Expand Up @@ -553,4 +554,4 @@ private void OnPaintSurfaceDiff(SkiaSharp.SKCanvas canvas, int width, int height
}
}
}
}
}
3 changes: 2 additions & 1 deletion samples/SvgToPng/SvgToPng.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@

<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows</TargetFramework>
<TargetFramework>net9.0-windows</TargetFramework>
<UseWPF>true</UseWPF>
<UseWindowsForms>true</UseWindowsForms>
<IsPackable>True</IsPackable>
<Nullable>disable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<EnableWindowsTargeting>true</EnableWindowsTargeting>
</PropertyGroup>

<PropertyGroup>
Expand Down
23 changes: 12 additions & 11 deletions samples/SvgToPng/ViewModels/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using Newtonsoft.Json;
using Svg.CodeGen.Skia;
using Svg.Model;
using Svg.Model.Services;
using Svg.Skia;

namespace SvgToPng.ViewModels;
Expand All @@ -18,7 +19,7 @@ public class MainWindowViewModel
{
private readonly SKSvgSettings _settings;
private readonly SkiaModel _skiaModel;
private readonly IAssetLoader _assetLoader;
private readonly ISvgAssetLoader _assetLoader;

[DataMember]
public ObservableCollection<Item> Items { get; set; }
Expand Down Expand Up @@ -51,7 +52,7 @@ public MainWindowViewModel()
{
_settings = new SKSvgSettings();
_skiaModel = new SkiaModel(_settings);
_assetLoader = new SkiaAssetLoader(_skiaModel);
_assetLoader = new SkiaSvgAssetLoader(_skiaModel);
}

public void CreateItemsView()
Expand Down Expand Up @@ -115,7 +116,7 @@ private void LoadSvg(Item item, Action<string> statusOpen, Action<string> status
}

var stopwatchOpen = Stopwatch.StartNew();
item.Document = SvgExtensions.Open(item.SvgPath);
item.Document = SvgService.Open(item.SvgPath);
stopwatchOpen.Stop();
statusOpen?.Invoke($"{Math.Round(stopwatchOpen.Elapsed.TotalMilliseconds, 3)}ms");
Debug.WriteLine($"Open: {Math.Round(stopwatchOpen.Elapsed.TotalMilliseconds, 3)}ms");
Expand All @@ -125,7 +126,7 @@ private void LoadSvg(Item item, Action<string> statusOpen, Action<string> status
var stopwatchToPicture = Stopwatch.StartNew();

var references = new HashSet<Uri> {item.Document.BaseUri};
item.Drawable = SvgExtensions.ToDrawable(item.Document, _assetLoader, references, out var bounds);
item.Drawable = SvgService.ToDrawable(item.Document, _assetLoader, references, out var bounds);
if (item.Drawable is { } && bounds is { })
{
item.Picture = item.Drawable.Snapshot(bounds.Value);
Expand Down Expand Up @@ -257,7 +258,7 @@ public void ExportItem(string svgPath, string outputPath, SkiaSharp.SKColor back

if (string.Compare(extension, ".pdf", StringComparison.OrdinalIgnoreCase) == 0)
{
var svg = SvgExtensions.Open(svgPath);
var svg = SvgService.Open(svgPath);
if (svg is { })
{
using var picture = SKSvg.ToPicture(svg, _skiaModel, _assetLoader);
Expand All @@ -269,7 +270,7 @@ public void ExportItem(string svgPath, string outputPath, SkiaSharp.SKColor back
}
else if (string.Compare(extension, ".xps", StringComparison.OrdinalIgnoreCase) == 0)
{
var svg = SvgExtensions.Open(svgPath);
var svg = SvgService.Open(svgPath);
if (svg is { })
{
using var picture = SKSvg.ToPicture(svg, _skiaModel, _assetLoader);
Expand All @@ -281,7 +282,7 @@ public void ExportItem(string svgPath, string outputPath, SkiaSharp.SKColor back
}
else if (string.Compare(extension, ".svg", StringComparison.OrdinalIgnoreCase) == 0)
{
var svg = SvgExtensions.Open(svgPath);
var svg = SvgService.Open(svgPath);
if (svg is { })
{
using var picture = SKSvg.ToPicture(svg, _skiaModel, _assetLoader);
Expand All @@ -293,7 +294,7 @@ public void ExportItem(string svgPath, string outputPath, SkiaSharp.SKColor back
}
else if (string.Compare(extension, ".jpeg", StringComparison.OrdinalIgnoreCase) == 0)
{
var svg = SvgExtensions.Open(svgPath);
var svg = SvgService.Open(svgPath);
if (svg is { })
{
using var picture = SKSvg.ToPicture(svg, _skiaModel, _assetLoader);
Expand All @@ -307,7 +308,7 @@ public void ExportItem(string svgPath, string outputPath, SkiaSharp.SKColor back
}
else if (string.Compare(extension, ".jpg", StringComparison.OrdinalIgnoreCase) == 0)
{
var svg = SvgExtensions.Open(svgPath);
var svg = SvgService.Open(svgPath);
if (svg is { })
{
using var picture = SKSvg.ToPicture(svg, _skiaModel, _assetLoader);
Expand All @@ -321,7 +322,7 @@ public void ExportItem(string svgPath, string outputPath, SkiaSharp.SKColor back
}
else if (string.Compare(extension, ".png", StringComparison.OrdinalIgnoreCase) == 0)
{
var svg = SvgExtensions.Open(svgPath);
var svg = SvgService.Open(svgPath);
if (svg is { })
{
using var picture = SKSvg.ToPicture(svg, _skiaModel, _assetLoader);
Expand All @@ -335,7 +336,7 @@ public void ExportItem(string svgPath, string outputPath, SkiaSharp.SKColor back
}
else if (string.Compare(extension, ".webp", StringComparison.OrdinalIgnoreCase) == 0)
{
var svg = SvgExtensions.Open(svgPath);
var svg = SvgService.Open(svgPath);
if (svg is { })
{
using var picture = SKSvg.ToPicture(svg, _skiaModel, _assetLoader);
Expand Down
18 changes: 15 additions & 3 deletions samples/TestApp/Views/MainView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<vm:MainWindowViewModel />
</Design.DataContext>

<Grid ColumnDefinitions="300,8,*" RowDefinitions="Auto,*,Auto">
<Grid ColumnDefinitions="300,8,*" RowDefinitions="Auto,*,Auto,Auto">

<TextBox Grid.Column="0"
Grid.Row="0"
Expand All @@ -29,7 +29,8 @@
Grid.Row="1"
Margin="6,0,6,0"
ItemsSource="{Binding FilteredItems}"
SelectedItem="{Binding SelectedItem, Mode=TwoWay}">
SelectedItem="{Binding SelectedItem, Mode=TwoWay}"
SelectionChanged="SelectingItemsControl_OnSelectionChanged">
<ListBox.Styles>
<Style Selector="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
Expand Down Expand Up @@ -137,6 +138,11 @@
OnContent="Cache Enabled"
OffContent="Cache Disabled"
Margin="6,0,6,0" />
<ToggleSwitch Name="ShowHitBoundsToggle"
OnContent="Show Bounds"
OffContent="Hide Bounds"
Margin="6,0,6,0"
Click="ShowHitBoundsToggle_OnToggled" />
<Button Content="Export"
Command="{Binding ExportCommand}"
CommandParameter="{Binding #Svg}"
Expand All @@ -154,10 +160,16 @@
<Svg Name="Svg"
Stretch="{Binding #SvgStretch.SelectedItem}"
Path="{Binding SelectedItem.Path, FallbackValue=''}"
EnableCache="True" />
EnableCache="True"
PointerPressed="Svg_OnPointerPressed" />
</ScrollViewer>
</DockPanel>

<ListBox Grid.Column="2"
Grid.Row="3"
Name="HitResults"
Margin="6" />

</Grid>

</UserControl>
Loading
Loading