Skip to content

Commit

Permalink
v3.5.0 - Use SearchValues from .NET8 and up
Browse files Browse the repository at this point in the history
Some hacks to deal with non-standard namespaces
Build for .NET 9 too
  • Loading branch information
monoman committed Nov 22, 2024
1 parent 42809bb commit c4e12a4
Show file tree
Hide file tree
Showing 11 changed files with 242 additions and 152 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A fork of the SvgNet & SvgGdi bridge (http://www.codeproject.com/KB/cs/svgnet.as

__SvgNet is now available as a Nuget:__ [SvgNet](https://www.nuget.org/packages/SvgNet/).

__Latest version 3.4.0 is .NET Standard 2.0 and 2.1 and also .NET 8.0 (base and Windows) compatible and works with .NET Core 2.x and 3.x and .NET 5.0/6.0/7.0/8.0, but now requires .NET Framework 4.6.2 or higher__
__Latest version 3.5.0 is .NET Standard 2.0 and 2.1 and also .NET 8.0 (base and Windows) compatible and works with .NET Core 2.x and 3.x and .NET 5.0/6.0/7.0/8.0, but now requires .NET Framework 4.6.2 or higher__

To build this version properly you need .NET 8.0.403+ SDK installed

Expand Down
221 changes: 140 additions & 81 deletions SvgDocTest/DocForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 8 additions & 12 deletions SvgDocTest/DocForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ public partial class DocForm : Form {
[STAThread]
private static void Main() => Application.Run(new DocForm());

private static void RefreshBrowserFrom(WebBrowser browser, string filename) {
browser.Navigate(new Uri(filename));
browser.Refresh(WebBrowserRefreshOption.Completely);
}

private void Button1_Click(object sender, EventArgs e) {
using (var dlg = new OpenFileDialog {
AutoUpgradeEnabled = true,
Expand Down Expand Up @@ -96,18 +91,18 @@ private void Button2_Click(object sender, EventArgs e) {
root.AddChild(grp2);

//output

SvgFactory.ResetNamespaces();
string s = root.WriteSVGString(true);

tbIn.Text = s;
tbOut.Text = s;

string tempFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "foo.svg");

using (var tw = new StreamWriter(tempFile, false))
tw.Write(s);

svgOut.Navigate(new Uri(tempFile));
svgOut.Refresh(WebBrowserRefreshOption.Completely);
panelTop.Text = $"Input: {tempFile}";
svgOut.RefreshFrom(tempFile);
svgIn.RefreshFrom(tempFile);
}

private void Button3_Click(object sender, EventArgs e) {
Expand All @@ -131,11 +126,12 @@ private void Button3_Click(object sender, EventArgs e) {
_ = MessageBox.Show("Tests completed Ok");
}
private void ProcessSvgFile(string svgFileName) {
panelTop.Text = $"Input: {svgFileName}";
tbIn.Text = svgFileName.LoadText();
RefreshBrowserFrom(svgIn, svgFileName);
tbOut.Text = SvgFactory.LoadFromXML(svgFileName.LoadXml(), null).WriteSVGString(true);
File.WriteAllText(_tempFileName, tbOut.Text);
RefreshBrowserFrom(svgOut, _tempFileName);
svgIn.RefreshFrom(svgFileName);
svgOut.RefreshFrom(_tempFileName);
}
}
}
11 changes: 11 additions & 0 deletions SvgDocTest/Extensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using System;
using System.Windows.Forms;

namespace SvgDocTest {
public static class Extensions {
public static void RefreshFrom(this WebBrowser browser, string filename) {
browser.Navigate(new Uri(filename));
browser.Refresh(WebBrowserRefreshOption.Completely);
}
}
}
2 changes: 1 addition & 1 deletion SvgDotNetCoreTest/SvgDotNetCoreTest.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<LangVersion>12</LangVersion>
<TargetFrameworks>net8.0-windows</TargetFrameworks>
<TargetFrameworks>net8.0-windows;net9.0-windows</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\TestShared\TestShared.cs" Link="TestShared.cs" />
Expand Down
Loading

0 comments on commit c4e12a4

Please sign in to comment.