Skip to content

Commit a69ddd3

Browse files
committed
Removed ASP.NET dependency of SVG.NET library.
1 parent a4121a7 commit a69ddd3

File tree

10 files changed

+238
-158
lines changed

10 files changed

+238
-158
lines changed
Binary file not shown.
Binary file not shown.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SVG elements can be rendered as a flat image file or each on a separate layer.
1313

1414
The plugin is a tiny wrapper around the [SVG.NET Library](https://github.com/vvvv/SVG) which does the actual SVG reading.
1515

16-
Tested on paint.net 4.2.13.
16+
Tested on paint.net 4.2.16 stable & 4.3 alpha (4.300.7881.3082) releases.
1717

1818
To install the plugin perform the following steps:
1919
* Put the DLL in the `<Paint.NET>\FileTypes` directory (default location is `C:\Program Files\paint.net\FileTypes`)

SvgFileType.sln

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio 15
4-
VisualStudioVersion = 15.0.27130.2027
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31424.327
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgFileTypePlugin", "SvgFileType\SvgFileTypePlugin.csproj", "{C32235C8-90B3-4C43-B589-B821C84839E9}"
77
EndProject

SvgFileType/FodyWeavers.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
2+
<Costura CreateTemporaryAssemblies="false" ExcludeRuntimeAssemblies="true" IncludeDebugSymbols="false" PreloadOrder="Fizzler|Svg">
3+
<IncludeAssemblies>
4+
Svg
5+
Fizzler
6+
</IncludeAssemblies>
7+
</Costura>
8+
</Weavers>

SvgFileType/FodyWeavers.xsd

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3+
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
4+
<xs:element name="Weavers">
5+
<xs:complexType>
6+
<xs:all>
7+
<xs:element name="Costura" minOccurs="0" maxOccurs="1">
8+
<xs:complexType>
9+
<xs:all>
10+
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
11+
<xs:annotation>
12+
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
13+
</xs:annotation>
14+
</xs:element>
15+
<xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
16+
<xs:annotation>
17+
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
18+
</xs:annotation>
19+
</xs:element>
20+
<xs:element minOccurs="0" maxOccurs="1" name="ExcludeRuntimeAssemblies" type="xs:string">
21+
<xs:annotation>
22+
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
23+
</xs:annotation>
24+
</xs:element>
25+
<xs:element minOccurs="0" maxOccurs="1" name="IncludeRuntimeAssemblies" type="xs:string">
26+
<xs:annotation>
27+
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
28+
</xs:annotation>
29+
</xs:element>
30+
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
31+
<xs:annotation>
32+
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
33+
</xs:annotation>
34+
</xs:element>
35+
<xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
36+
<xs:annotation>
37+
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
38+
</xs:annotation>
39+
</xs:element>
40+
<xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
41+
<xs:annotation>
42+
<xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
43+
</xs:annotation>
44+
</xs:element>
45+
</xs:all>
46+
<xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
47+
<xs:annotation>
48+
<xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
49+
</xs:annotation>
50+
</xs:attribute>
51+
<xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
52+
<xs:annotation>
53+
<xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
54+
</xs:annotation>
55+
</xs:attribute>
56+
<xs:attribute name="IncludeRuntimeReferences" type="xs:boolean">
57+
<xs:annotation>
58+
<xs:documentation>Controls if runtime assemblies are also embedded.</xs:documentation>
59+
</xs:annotation>
60+
</xs:attribute>
61+
<xs:attribute name="UseRuntimeReferencePaths" type="xs:boolean">
62+
<xs:annotation>
63+
<xs:documentation>Controls whether the runtime assemblies are embedded with their full path or only with their assembly name.</xs:documentation>
64+
</xs:annotation>
65+
</xs:attribute>
66+
<xs:attribute name="DisableCompression" type="xs:boolean">
67+
<xs:annotation>
68+
<xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
69+
</xs:annotation>
70+
</xs:attribute>
71+
<xs:attribute name="DisableCleanup" type="xs:boolean">
72+
<xs:annotation>
73+
<xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
74+
</xs:annotation>
75+
</xs:attribute>
76+
<xs:attribute name="LoadAtModuleInit" type="xs:boolean">
77+
<xs:annotation>
78+
<xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
79+
</xs:annotation>
80+
</xs:attribute>
81+
<xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
82+
<xs:annotation>
83+
<xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
84+
</xs:annotation>
85+
</xs:attribute>
86+
<xs:attribute name="ExcludeAssemblies" type="xs:string">
87+
<xs:annotation>
88+
<xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
89+
</xs:annotation>
90+
</xs:attribute>
91+
<xs:attribute name="IncludeAssemblies" type="xs:string">
92+
<xs:annotation>
93+
<xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
94+
</xs:annotation>
95+
</xs:attribute>
96+
<xs:attribute name="ExcludeRuntimeAssemblies" type="xs:string">
97+
<xs:annotation>
98+
<xs:documentation>A list of runtime assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
99+
</xs:annotation>
100+
</xs:attribute>
101+
<xs:attribute name="IncludeRuntimeAssemblies" type="xs:string">
102+
<xs:annotation>
103+
<xs:documentation>A list of runtime assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
104+
</xs:annotation>
105+
</xs:attribute>
106+
<xs:attribute name="Unmanaged32Assemblies" type="xs:string">
107+
<xs:annotation>
108+
<xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
109+
</xs:annotation>
110+
</xs:attribute>
111+
<xs:attribute name="Unmanaged64Assemblies" type="xs:string">
112+
<xs:annotation>
113+
<xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
114+
</xs:annotation>
115+
</xs:attribute>
116+
<xs:attribute name="PreloadOrder" type="xs:string">
117+
<xs:annotation>
118+
<xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
119+
</xs:annotation>
120+
</xs:attribute>
121+
</xs:complexType>
122+
</xs:element>
123+
</xs:all>
124+
<xs:attribute name="VerifyAssembly" type="xs:boolean">
125+
<xs:annotation>
126+
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
127+
</xs:annotation>
128+
</xs:attribute>
129+
<xs:attribute name="VerifyIgnoreCodes" type="xs:string">
130+
<xs:annotation>
131+
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
132+
</xs:annotation>
133+
</xs:attribute>
134+
<xs:attribute name="GenerateXsd" type="xs:boolean">
135+
<xs:annotation>
136+
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
137+
</xs:annotation>
138+
</xs:attribute>
139+
</xs:complexType>
140+
</xs:element>
141+
</xs:schema>

SvgFileType/Properties/AssemblyInfo.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
using System.Reflection;
22
using System.Runtime.InteropServices;
3+
using System.Runtime.Versioning;
34

45
// General Information about an assembly is controlled through the following
56
// set of attributes. Change these attribute values to modify the information
67
// associated with an assembly.
7-
[assembly: AssemblyTitle("SvgFileType")]
8+
[assembly: AssemblyTitle("SVG (Scalable Vector Graphics) Import Plug-in for Paint.NET")]
89
[assembly: AssemblyDescription("SVG (Scalable Vector Graphics) Import Plug-in for Paint.NET")]
910
[assembly: AssemblyConfiguration("")]
1011
[assembly: AssemblyCompany("")]
1112
[assembly: AssemblyProduct("SvgFileType")]
12-
[assembly: AssemblyCopyright("Copyright © 2020")]
13+
[assembly: AssemblyCopyright("Copyright © 2021")]
1314
[assembly: AssemblyTrademark("")]
1415
[assembly: AssemblyCulture("")]
16+
#if NETCORE
17+
[assembly: SupportedOSPlatform("windows")]
18+
#endif
1519

1620
// Setting ComVisible to false makes the types in this assembly not visible
1721
// to COM components. If you need to access a type in this assembly from
@@ -31,5 +35,6 @@
3135
// You can specify all the values or you can default the Build and Revision Numbers
3236
// by using the '*' as shown below:
3337
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.0.0.0")]
35-
[assembly: AssemblyFileVersion("1.0.0.0")]
38+
[assembly: AssemblyVersion(SvgFileTypePlugin.SvgFileType.Version)]
39+
[assembly: AssemblyFileVersion(SvgFileTypePlugin.SvgFileType.Version)]
40+
[assembly: AssemblyInformationalVersion(SvgFileTypePlugin.SvgFileType.Version)]

SvgFileType/SvgFileType.cs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ namespace SvgFileTypePlugin
1313
{
1414
public class SvgFileType : FileType
1515
{
16+
// https://forums.getpaint.net/topic/117086-scalable-vector-graphics-filetype-alternative-plugin-svg-svgz
17+
18+
public const string Version = "1.0.3";
19+
1620
public SvgFileType() : base("Scalable Vector Graphics",
1721
new FileTypeOptions
1822
{
@@ -23,10 +27,11 @@ public SvgFileType() : base("Scalable Vector Graphics",
2327
{
2428
}
2529

26-
private const string WindowTitle = "SVG Import Plug-in v1.0.2";
30+
private const string WindowTitle = "SVG Import Plug-in v" + Version;
2731

2832
// Don't change this text! It's used by a PSD import plugin to keep Photoshop's folder structure.
2933
// https://forums.getpaint.net/topic/113742-photoshop-psd-file-plugin-with-layers-support/
34+
3035
public const string LayerGroupBegin = "Layer Group: {0}";
3136
public const string LayerGroupEnd = "End Layer Group: {0}";
3237

@@ -274,7 +279,7 @@ private void AfterImport(Task p)
274279
{
275280
if (p.Exception.InnerExceptions.Any(exception => exception is OutOfMemoryException))
276281
{
277-
dialog.Invoke((Action) (() =>
282+
dialog.Invoke((MethodInvoker) (() =>
278283
{
279284
MessageBoxEx.Show(dialog, "Not enough memory to complete this operation.",
280285
"Out of Memory", MessageBoxButtons.OK, MessageBoxIcon.Error);
@@ -283,7 +288,7 @@ private void AfterImport(Task p)
283288
else
284289
{
285290
var innerExpection = p.Exception?.InnerException?.Message;
286-
dialog.Invoke((Action) (() =>
291+
dialog.Invoke((MethodInvoker) (() =>
287292
{
288293
MessageBoxEx.Show(dialog, p.Exception.Message + "\r\nMessage: " + innerExpection,
289294
"Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
@@ -302,13 +307,12 @@ private void AfterImport(Task p)
302307

303308
#region Render Elements
304309

305-
private static int GetLayerCountToRender(IReadOnlyCollection<SvgVisualElement> elements,
306-
bool importHiddenLayers)
310+
private static int GetLayerCountToRender(IReadOnlyCollection<SvgVisualElement> elements, bool importHiddenLayers)
307311
{
308312
return importHiddenLayers ? elements.Count : elements.Count(IsVisibleOriginally);
309313
}
310314

311-
private Document RenderElements(IReadOnlyCollection<SvgVisualElement> elements, bool setOpacityForLayer,
315+
private Document RenderElements(IReadOnlyCollection<SvgVisualElement> elements, bool setOpacityForLayer,
312316
bool importHiddenLayers, Action<int> progress, CancellationToken token)
313317
{
314318
// I had problems to render each element directly while parent transformation can affect child.
@@ -390,8 +394,7 @@ private Document RenderElements(IReadOnlyCollection<SvgVisualElement> elements,
390394
return pdnDocument;
391395
}
392396

393-
private void RenderElement(SvgElement element, bool setOpacityForLayer,
394-
bool importHiddenLayers)
397+
private void RenderElement(SvgElement element, bool setOpacityForLayer, bool importHiddenLayers)
395398
{
396399
float opacity = element.Opacity;
397400
var visible = true;
@@ -501,7 +504,7 @@ private static string GetLayerTitle(SvgElement element, int maxLength = 32)
501504
{
502505
// Get child title tag
503506
SvgTitle title = element.Children.OfType<SvgTitle>().FirstOrDefault();
504-
if (title != null && !string.IsNullOrEmpty(title.Content))
507+
if (!String.IsNullOrEmpty(title?.Content))
505508
{
506509
layerName = title.Content;
507510
}
@@ -542,8 +545,7 @@ private static string GetLayerTitle(SvgElement element, int maxLength = 32)
542545
return layerName == null ? elementName : String.Join(": ", elementName, layerName);
543546
}
544547

545-
private static IEnumerable<SvgElement> PrepareFlatElements(SvgElementCollection collection,
546-
string groupName = null)
548+
private static IEnumerable<SvgElement> PrepareFlatElements(SvgElementCollection collection, string groupName = null)
547549
{
548550
if (collection == null)
549551
{

0 commit comments

Comments
 (0)