├── .editorconfig
├── .gitattributes
├── .gitignore
├── Doc
├── DetailView.PNG
├── DetailViewXaml.PNG
├── Icons in WPF.docx
├── MainView.PNG
└── SvgToXaml.docx
├── IconResources
├── BrushProps.cs
├── IconResources.csproj
├── Images
│ ├── Icons.cs
│ ├── Icons.tt
│ ├── Icons.xaml
│ └── Svg
│ │ ├── 3d-view-icon.svg
│ │ ├── Icons.html
│ │ ├── JOG.svg
│ │ ├── Update.cmd
│ │ ├── cloud-3-icon.svg
│ │ └── images.html
├── Properties
│ └── AssemblyInfo.cs
└── Themes
│ └── Generic.xaml
├── Licence.txt
├── README.md
├── SvgConverter
├── CmdLineHandler.cs
├── CmdLineTarget.cs
├── ConvertedSvgData.cs
├── ConverterLogic.cs
├── FileUtils.cs
├── Properties
│ └── AssemblyInfo.cs
├── ResKeyInfo.cs
├── SvgConverter.csproj
├── app.config
└── packages.config
├── SvgConverterTest
├── CommandLineTests.cs
├── ConverterTests.cs
├── FileUtilsTests.cs
├── Properties
│ └── AssemblyInfo.cs
├── SvgConverterTest.csproj
├── SvgzTest.cs
├── T4Methods.cs
├── TestFiles
│ ├── 3d-view-icon.svg
│ ├── Expected
│ │ ├── ConvertFileToDrawingGroup2.xaml
│ │ ├── ConvertFileToDrawingGroupWithRuntime_JOG.svg.xaml
│ │ ├── ConvertFileToDrawingGroupWithRuntime_cloud-3-icon.svg.xaml
│ │ ├── ConvertFileToDrawingGroup_3d-view-icon.svg.xaml
│ │ ├── ConvertFileToDrawingGroup_JOG.svg.xaml
│ │ ├── ConvertFileToDrawingGroup_cloud-3-icon.svg.xaml
│ │ ├── ConvertFileToDrawingImage_3d-view-icon.svg.xaml
│ │ ├── ConvertFileToDrawingImage_JOG.svg.xaml
│ │ ├── ConvertFileToDrawingImage_cloud-3-icon.svg.xaml
│ │ ├── Handwheel.xaml
│ │ ├── Handwheel1.xaml
│ │ ├── Handwheel2.xaml
│ │ ├── Handwheel3.xaml
│ │ ├── SvgDirToXamlTest_withNamePrefix.xaml
│ │ ├── SvgDirToXamlTest_withUseCompResKey.xaml
│ │ └── SvgDirToXaml_with_defaultSettingsTest.xaml
│ ├── Handwheel.svg
│ ├── Images.html
│ ├── JOG.svg
│ ├── Readme.txt
│ ├── Subfolder1
│ │ ├── 3d-view-b-icon.svg
│ │ ├── Handwheel.svg
│ │ ├── Subfolder2
│ │ │ └── cloud-3-a-icon.svg
│ │ └── images.html
│ ├── cloud-3-icon.svg
│ ├── example.svgz
│ └── xamlUntidy.xaml
├── app.config
└── packages.config
├── SvgToXaml.sln
├── SvgToXaml.sln.DotSettings
├── SvgToXaml
├── App.xaml
├── App.xaml.cs
├── Command
│ ├── DelegateCommand.cs
│ ├── DelegateCommandBase.cs
│ ├── IActiveAware.cs
│ └── WeakEventHandlerManager.cs
├── CustomDefined.targets
├── DetailWindow.xaml
├── DetailWindow.xaml.cs
├── Explorer
│ ├── FolderTree.xaml
│ ├── FolderTree.xaml.cs
│ ├── Images
│ │ ├── diskdrive.png
│ │ └── folder.png
│ └── TreeViewItemProps.cs
├── Images
│ ├── icon.ico
│ ├── icon.png
│ ├── icon.svg
│ └── icon16.png
├── Infrastructure
│ ├── DispatcherExtensions.cs
│ ├── HConsoleHelper.cs
│ ├── InvertableBooleanToVisibilityConverter.cs
│ └── ObservableCollectionSafe.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Payload
│ └── T4Template.tt
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── SvgToXaml.csproj
├── SvgToXaml.csproj.DotSettings
├── TestBatch.cmd
├── TextViewer
│ └── XmlViewer.cs
├── ViewModels
│ ├── BindableBase.cs
│ ├── GraphicImageViewModel.cs
│ ├── ImageBaseViewModel.cs
│ ├── SvgImageViewModel.cs
│ ├── SvgImagesViewModel.cs
│ └── ViewModelBase.cs
├── WrapPanel
│ └── VirtualizingWrapPanel.cs
├── app.config
├── icon.ico
└── packages.config
├── WpfDemoApp
├── App.xaml
├── App.xaml.cs
├── MainWindow.xaml
├── MainWindow.xaml.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── WpfDemoApp.csproj
└── app.config
└── packages
├── AvalonEdit.5.0.2
├── AvalonEdit.5.0.2.nupkg
└── lib
│ ├── .gitignore
│ └── Net40
│ ├── ICSharpCode.AvalonEdit.dll
│ └── ICSharpCode.AvalonEdit.xml
├── BKEDV.CommandLineParser.1.0.4.0
├── BKEDV.CommandLineParser.1.0.4.0.nupkg
└── lib
│ └── net40
│ └── CommandLineParser.dll
├── FluentAssertions.3.3.0
├── FluentAssertions.3.3.0.nupkg
└── lib
│ ├── net40
│ ├── FluentAssertions.Core.dll
│ ├── FluentAssertions.Core.xml
│ ├── FluentAssertions.dll
│ └── FluentAssertions.xml
│ ├── net45
│ ├── FluentAssertions.Core.dll
│ ├── FluentAssertions.Core.xml
│ ├── FluentAssertions.dll
│ └── FluentAssertions.xml
│ ├── portable-monotouch+monoandroid+xamarin.ios
│ ├── FluentAssertions.Core.dll
│ └── FluentAssertions.Core.xml
│ ├── portable-net40+sl5+win8+wp8+wpa81
│ ├── FluentAssertions.Core.dll
│ ├── FluentAssertions.Core.xml
│ ├── FluentAssertions.XML
│ └── FluentAssertions.dll
│ ├── portable-win81+wpa81
│ ├── FluentAssertions.Core.dll
│ ├── FluentAssertions.Core.xml
│ ├── FluentAssertions.dll
│ └── FluentAssertions.xml
│ ├── sl5
│ ├── FluentAssertions.Core.dll
│ ├── FluentAssertions.Core.xml
│ ├── FluentAssertions.dll
│ ├── FluentAssertions.xml
│ ├── Microsoft.CSharp.dll
│ ├── Microsoft.CSharp.xml
│ ├── Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.dll
│ ├── Microsoft.VisualStudio.QualityTools.UnitTesting.Silverlight.xml
│ ├── System.Xml.Linq.dll
│ ├── System.Xml.Linq.xml
│ ├── de
│ │ ├── Microsoft.CSharp.resources.dll
│ │ └── System.Xml.Linq.resources.dll
│ ├── es
│ │ ├── Microsoft.CSharp.resources.dll
│ │ └── System.Xml.Linq.resources.dll
│ ├── fr
│ │ ├── Microsoft.CSharp.resources.dll
│ │ └── System.Xml.Linq.resources.dll
│ ├── it
│ │ ├── Microsoft.CSharp.resources.dll
│ │ └── System.Xml.Linq.resources.dll
│ ├── ja
│ │ ├── Microsoft.CSharp.resources.dll
│ │ └── System.Xml.Linq.resources.dll
│ ├── ko
│ │ ├── Microsoft.CSharp.resources.dll
│ │ └── System.Xml.Linq.resources.dll
│ ├── ru
│ │ ├── Microsoft.CSharp.resources.dll
│ │ └── System.Xml.Linq.resources.dll
│ ├── zh-Hans
│ │ ├── Microsoft.CSharp.resources.dll
│ │ └── System.Xml.Linq.resources.dll
│ └── zh-Hant
│ │ ├── Microsoft.CSharp.resources.dll
│ │ └── System.Xml.Linq.resources.dll
│ ├── win8
│ ├── FluentAssertions.Core.dll
│ ├── FluentAssertions.Core.xml
│ ├── FluentAssertions.XML
│ └── FluentAssertions.dll
│ └── wp8
│ ├── FluentAssertions.Core.dll
│ ├── FluentAssertions.Core.xml
│ ├── FluentAssertions.dll
│ └── FluentAssertions.xml
├── NUnit.2.6.4
├── NUnit.2.6.4.nupkg
├── lib
│ ├── nunit.framework.dll
│ └── nunit.framework.xml
└── license.txt
├── SharpVectors.Reloaded.1.2.0
├── .signature.p7s
├── SharpVectors.Reloaded.1.2.0.nupkg
└── lib
│ └── net40
│ ├── SharpVectors.Converters.Wpf.dll
│ ├── SharpVectors.Converters.Wpf.xml
│ ├── SharpVectors.Core.dll
│ ├── SharpVectors.Core.xml
│ ├── SharpVectors.Css.dll
│ ├── SharpVectors.Css.xml
│ ├── SharpVectors.Dom.dll
│ ├── SharpVectors.Dom.xml
│ ├── SharpVectors.Model.dll
│ ├── SharpVectors.Model.xml
│ ├── SharpVectors.Rendering.Gdi.dll
│ ├── SharpVectors.Rendering.Gdi.xml
│ ├── SharpVectors.Rendering.Wpf.dll
│ ├── SharpVectors.Rendering.Wpf.xml
│ ├── SharpVectors.Runtime.Wpf.dll
│ └── SharpVectors.Runtime.Wpf.xml
└── repositories.config
/.editorconfig:
--------------------------------------------------------------------------------
1 | # EditorConfig is awesome: http://EditorConfig.org
2 |
3 | # top-most EditorConfig file
4 | root = true
5 |
6 | # 4 space indentation
7 | [*.cs]
8 | indent_style = space
9 | indent_size = 4
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to DISABLE normalizing line endings.
3 | # No matter which setting the core.autocrlf on each machine has. (BK)
4 | ###############################################################################
5 | * -text
6 |
7 |
8 |
9 |
10 | ###############################################################################
11 | # Set default behavior for command prompt diff.
12 | #
13 | # This is need for earlier builds of msysgit that does not have it on by
14 | # default for csharp files.
15 | # Note: This is only used by command line
16 | ###############################################################################
17 | #*.cs diff=csharp
18 |
19 | ###############################################################################
20 | # Set the merge driver for project and solution files
21 | #
22 | # Merging from the command prompt will add diff markers to the files if there
23 | # are conflicts (Merging from VS is not affected by the settings below, in VS
24 | # the diff markers are never inserted). Diff markers may cause the following
25 | # file extensions to fail to load in VS. An alternative would be to treat
26 | # these files as binary and thus will always conflict and require user
27 | # intervention with every merge. To do so, just uncomment the entries below
28 | ###############################################################################
29 | #*.sln merge=binary
30 | #*.csproj merge=binary
31 | #*.vbproj merge=binary
32 | #*.vcxproj merge=binary
33 | #*.vcproj merge=binary
34 | #*.dbproj merge=binary
35 | #*.fsproj merge=binary
36 | #*.lsproj merge=binary
37 | #*.wixproj merge=binary
38 | #*.modelproj merge=binary
39 | #*.sqlproj merge=binary
40 | #*.wwaproj merge=binary
41 |
42 | ###############################################################################
43 | # behavior for image files
44 | #
45 | # image files are treated as binary by default.
46 | ###############################################################################
47 | #*.jpg binary
48 | #*.png binary
49 | #*.gif binary
50 |
51 | ###############################################################################
52 | # diff behavior for common document formats
53 | #
54 | # Convert binary document formats to text before diffing them. This feature
55 | # is only available from the command line. Turn it on by uncommenting the
56 | # entries below.
57 | ###############################################################################
58 | #*.doc diff=astextplain
59 | #*.DOC diff=astextplain
60 | #*.docx diff=astextplain
61 | #*.DOCX diff=astextplain
62 | #*.dot diff=astextplain
63 | #*.DOT diff=astextplain
64 | #*.pdf diff=astextplain
65 | #*.PDF diff=astextplain
66 | #*.rtf diff=astextplain
67 | #*.RTF diff=astextplain
68 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BerndK/SvgToXaml/87e6fcc39012620e759f83257a3900faf11e87d9/.gitignore
--------------------------------------------------------------------------------
/Doc/DetailView.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BerndK/SvgToXaml/87e6fcc39012620e759f83257a3900faf11e87d9/Doc/DetailView.PNG
--------------------------------------------------------------------------------
/Doc/DetailViewXaml.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BerndK/SvgToXaml/87e6fcc39012620e759f83257a3900faf11e87d9/Doc/DetailViewXaml.PNG
--------------------------------------------------------------------------------
/Doc/Icons in WPF.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BerndK/SvgToXaml/87e6fcc39012620e759f83257a3900faf11e87d9/Doc/Icons in WPF.docx
--------------------------------------------------------------------------------
/Doc/MainView.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BerndK/SvgToXaml/87e6fcc39012620e759f83257a3900faf11e87d9/Doc/MainView.PNG
--------------------------------------------------------------------------------
/IconResources/IconResources.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {618E080B-86D8-4F12-B141-EFFE222D6E9F}
8 | Library
9 | Properties
10 | IconResources
11 | IconResources
12 | v4.5
13 | 512
14 |
15 |
16 | true
17 | full
18 | false
19 | bin\Debug\
20 | DEBUG;TRACE
21 | prompt
22 | 4
23 |
24 |
25 | pdbonly
26 | true
27 | bin\Release\
28 | TRACE
29 | prompt
30 | 4
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 | True
50 | True
51 | Icons.tt
52 |
53 |
54 |
55 |
56 |
57 | TextTemplatingFileGenerator
58 | Icons.cs
59 |
60 |
61 |
62 |
63 | MSBuild:Compile
64 | Designer
65 |
66 |
67 | MSBuild:Compile
68 | Designer
69 |
70 |
71 |
72 |
73 |
74 |
75 |
82 |
--------------------------------------------------------------------------------
/IconResources/Images/Icons.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics.CodeAnalysis;
3 | using System.Windows;
4 |
5 | namespace IconResources.Images
6 | {
7 | [SuppressMessage("ReSharper", "InconsistentNaming")]
8 | public static class Icons
9 | {
10 | private static readonly ComponentResourceKey cloud_3_iconGeometryKeyCompResKey = MakeKey("Icons.cloud_3_iconGeometryKey");
11 | public static ResourceKey cloud_3_iconGeometryKey => cloud_3_iconGeometryKeyCompResKey;
12 |
13 | private static readonly ComponentResourceKey cloud_3_iconDrawingGroupKeyCompResKey = MakeKey("Icons.cloud_3_iconDrawingGroupKey");
14 | public static ResourceKey cloud_3_iconDrawingGroupKey => cloud_3_iconDrawingGroupKeyCompResKey;
15 |
16 | private static readonly ComponentResourceKey cloud_3_iconDrawingImageKeyCompResKey = MakeKey("Icons.cloud_3_iconDrawingImageKey");
17 | public static ResourceKey cloud_3_iconDrawingImageKey => cloud_3_iconDrawingImageKeyCompResKey;
18 |
19 | private static readonly ComponentResourceKey _3d_view_iconGeometryKeyCompResKey = MakeKey("Icons._3d_view_iconGeometryKey");
20 | public static ResourceKey _3d_view_iconGeometryKey => _3d_view_iconGeometryKeyCompResKey;
21 |
22 | private static readonly ComponentResourceKey _3d_view_iconDrawingGroupKeyCompResKey = MakeKey("Icons._3d_view_iconDrawingGroupKey");
23 | public static ResourceKey _3d_view_iconDrawingGroupKey => _3d_view_iconDrawingGroupKeyCompResKey;
24 |
25 | private static readonly ComponentResourceKey _3d_view_iconDrawingImageKeyCompResKey = MakeKey("Icons._3d_view_iconDrawingImageKey");
26 | public static ResourceKey _3d_view_iconDrawingImageKey => _3d_view_iconDrawingImageKeyCompResKey;
27 |
28 | private static readonly ComponentResourceKey JOGGeometry1KeyCompResKey = MakeKey("Icons.JOGGeometry1Key");
29 | public static ResourceKey JOGGeometry1Key => JOGGeometry1KeyCompResKey;
30 |
31 | private static readonly ComponentResourceKey JOGGeometry2KeyCompResKey = MakeKey("Icons.JOGGeometry2Key");
32 | public static ResourceKey JOGGeometry2Key => JOGGeometry2KeyCompResKey;
33 |
34 | private static readonly ComponentResourceKey JOGDrawingGroupKeyCompResKey = MakeKey("Icons.JOGDrawingGroupKey");
35 | public static ResourceKey JOGDrawingGroupKey => JOGDrawingGroupKeyCompResKey;
36 |
37 | private static readonly ComponentResourceKey JOGDrawingImageKeyCompResKey = MakeKey("Icons.JOGDrawingImageKey");
38 | public static ResourceKey JOGDrawingImageKey => JOGDrawingImageKeyCompResKey;
39 |
40 | private static ComponentResourceKey MakeKey(object id)
41 | {
42 | return new ComponentResourceKey(typeof(Icons), id);
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/IconResources/Images/Icons.tt:
--------------------------------------------------------------------------------
1 | <#@ template debug="true" hostSpecific="true" #>
2 | <#@ output extension=".cs" #>
3 | <#@ Assembly Name="System.Core.dll" #>
4 | <#@ Assembly Name="System.Xml.dll" #>
5 | <#@ Assembly Name="System.Xml.Linq.dll" #>
6 | <#@ Assembly Name="System.Windows.Forms.dll" #>
7 | <#@ import namespace="System" #>
8 | <#@ import namespace="System.IO" #>
9 | <#@ import namespace="System.Diagnostics" #>
10 | <#@ import namespace="System.Linq" #>
11 | <#@ import namespace="System.Xml.Linq" #>
12 | <#@ import namespace="System.Collections" #>
13 | <#@ import namespace="System.Collections.Generic" #><#
14 | string xamlFile = Path.ChangeExtension(this.Host.TemplateFile, ".xaml");
15 | string nameSpace;
16 | string prefix;
17 | var keyNames = KeysFromXaml(xamlFile, out nameSpace, out prefix);
18 |
19 | #>using System.Diagnostics.CodeAnalysis;
20 | using System.Windows;
21 |
22 | namespace <#= nameSpace #>
23 | {
24 | [SuppressMessage("ReSharper", "InconsistentNaming")]
25 | public static class <#= prefix #>
26 | {
27 | <# BuildComponentKeys(keyNames, prefix);
28 | #>
29 | private static ComponentResourceKey MakeKey(object id)
30 | {
31 | return new ComponentResourceKey(typeof(<#= prefix #>), id);
32 | }
33 | }
34 | }
35 | <#+
36 | void BuildComponentKeys(IEnumerable keyNames, string prefix)
37 | {
38 | foreach (var name in keyNames)
39 | {
40 | #> private static readonly ComponentResourceKey <#= name #>CompResKey = MakeKey("<#= prefix #>.<#= name #>");
41 | public static ResourceKey <#= name #> => <#= name #>CompResKey;
42 |
43 | <#+ }
44 | }
45 |
46 | public static IEnumerable KeysFromXaml(string fileName, out string nameSpace, out string prefix)
47 | {
48 | var doc = XDocument.Load(fileName);
49 | XNamespace xamlNs = "http://schemas.microsoft.com/winfx/2006/xaml";
50 |
51 | nameSpace = doc.Root.LastAttribute.Value;
52 | nameSpace = nameSpace.Remove(0, "clr-namespace:".Length);
53 |
54 | var keys = doc.Root.Elements().Attributes(xamlNs + "Key").Select(a => a.Value).ToArray();
55 | //keys have this form: { x: Static NameSpaceName:XamlName.Color1}
56 |
57 | //get Prefix
58 | prefix = "unknownPrefix";
59 | var first = keys.FirstOrDefault();
60 | if (first != null)
61 | {
62 | var p1 = first.LastIndexOf(":");
63 | var p2 = first.LastIndexOf("}");
64 | if (p1 < p2)
65 | prefix = first.Substring(p1 + 1, p2 - p1 - 1).Split('.').FirstOrDefault();
66 | }
67 |
68 | //keynames
69 | return keys.Select(key =>
70 | {
71 | var p1 = key.LastIndexOf(".");
72 | var p2 = key.LastIndexOf("}");
73 | if (p1 < p2)
74 | return key.Substring(p1 + 1, p2 - p1 - 1);
75 | else
76 | return key;
77 | }).ToArray();
78 | }
79 |
80 | #>
--------------------------------------------------------------------------------
/IconResources/Images/Svg/3d-view-icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
19 |
20 |
--------------------------------------------------------------------------------
/IconResources/Images/Svg/Icons.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Browse svg images
5 |
6 | Images in file: .\Icons


7 |
--------------------------------------------------------------------------------
/IconResources/Images/Svg/Update.cmd:
--------------------------------------------------------------------------------
1 | ..\..\..\SvgToXaml\bin\Debug\SvgToXaml.exe BuildDict /inputdir "." /outputdir ".." /outputname Icons /useComponentResKeys=true /compResKeyNSName=nsImages /compResKeyNS=IconResources.Images /filterPixelsPerDip=true
2 | pause
--------------------------------------------------------------------------------
/IconResources/Images/Svg/cloud-3-icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
16 |
--------------------------------------------------------------------------------
/IconResources/Images/Svg/images.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Browse svg images
5 |
6 | Images in file: .\images


7 |
--------------------------------------------------------------------------------
/IconResources/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using System.Windows;
5 |
6 | // General Information about an assembly is controlled through the following
7 | // set of attributes. Change these attribute values to modify the information
8 | // associated with an assembly.
9 | [assembly: AssemblyTitle("IconResources")]
10 | [assembly: AssemblyDescription("")]
11 | [assembly: AssemblyConfiguration("")]
12 | [assembly: AssemblyCompany("")]
13 | [assembly: AssemblyProduct("IconResources")]
14 | [assembly: AssemblyCopyright("Copyright © 2017")]
15 | [assembly: AssemblyTrademark("")]
16 | [assembly: AssemblyCulture("")]
17 |
18 | // Setting ComVisible to false makes the types in this assembly not visible
19 | // to COM components. If you need to access a type in this assembly from
20 | // COM, set the ComVisible attribute to true on that type.
21 | [assembly: ComVisible(false)]
22 |
23 | // The following GUID is for the ID of the typelib if this project is exposed to COM
24 | [assembly: Guid("618e080b-86d8-4f12-b141-effe222d6e9f")]
25 |
26 | // Version information for an assembly consists of the following four values:
27 | //
28 | // Major Version
29 | // Minor Version
30 | // Build Number
31 | // Revision
32 | //
33 | // You can specify all the values or you can default the Build and Revision Numbers
34 | // by using the '*' as shown below:
35 | // [assembly: AssemblyVersion("1.0.*")]
36 | [assembly: AssemblyVersion("1.0.0.0")]
37 | [assembly: AssemblyFileVersion("1.0.0.0")]
38 |
39 | [assembly: ThemeInfo(ResourceDictionaryLocation.None, ResourceDictionaryLocation.SourceAssembly)]
--------------------------------------------------------------------------------
/IconResources/Themes/Generic.xaml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Licence.txt:
--------------------------------------------------------------------------------
1 | Copyright (c) 2015, Bernd Klaiber, bk@bkedv.de
2 |
3 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
4 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
5 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
6 | PURPOSE ARE DISCLAIMED.
7 | IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY
8 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
9 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
10 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
11 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
13 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SvgToXaml
2 | Smart tool to view svg-files and convert them to xaml for use in .NET
3 | There are 3 major use cases:
4 | View many svg-files, examine single files closer (see additional Info, svg sources, xaml code)
5 | Convert svg-file to xaml
6 | Batch conversion of many svg-files
7 | # View
8 | Just start SvgToXaml and drag a folder into the view, this folder will open and you'll see a list of all the svgs located in that folder. Sure there is a button to open also a "open folder" dialog. Double click a icon see the detail view.
9 |
10 | 
11 |
12 | Just drag a file into the view and the detail view will open.
13 |
14 | 
15 |
16 | # Convert
17 | You can open the detail view by double-clicking an icon. Here you can inspect the icon closer and can also see the converted xaml-code.
18 |
19 | 
20 | # Batch conversion
21 | The idea is that you collect some svgs and want to use them in your .net app. So just put them in a folder and use SvgToXaml to batch convert them into one xaml-file.
22 | The SvgToXaml exe file is designed as a "hybrid" app. Just call it without params and it will start as a WPF app, when you specify params, it will change to a console app. Provide "/?" to see the help, there is only one command rigth now: "BuildDict"
23 | ```
24 | >SvgToXaml.exe /? BuildDict
25 | SvgToXaml - Tool to convert SVGs to a Dictionary
26 | (c) 2015 Bernd Klaiber
27 | BuildDict Creates a ResourceDictionary with the svg-Images of a folder
28 | Needed Arguments:
29 | /inputdir: specify folder of the graphic files to process
30 | /outputname: Name for the xaml outputfile
31 | Optional Params:
32 | /outputdir: folder for the xaml-Output, optional, default: folder of svgs
33 | /buildhtmlfile: Builds a htmlfile to browse the svgs, optional,default true
34 | ```
35 | Example:
36 | `..\..\SvgToXaml\bin\Debug\SvgToXaml.exe BuildDict /inputdir:.\svg /outputname:images /outputdir:.`
37 | This is the content of the cmd file included in the sample app. It will produce a xaml file named "images.xaml" in the current folder, including all svg-files from folder ".\svg".
38 | That's it, after that, include the file "images.xaml" into your app, merge it into resourcedictionaries in the app.xaml and you can use the icons in e.g. a button like this:
39 | ```
40 |
43 | ```
44 | after adding more new icons, just run the command again and the new icons will appear in the updated xaml-file.
45 | For each Icon the colors, paths, a drawingimage are created (with resource-keys) so you can use them as you like.
46 | You can change the color of all icons at once (like theming your app) or you can change all the color of the icons separately (see the sample app included in the sources).
47 |
--------------------------------------------------------------------------------
/SvgConverter/CmdLineHandler.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using BKLib.CommandLineParser;
3 |
4 | namespace SvgConverter
5 | {
6 | public static class CmdLineHandler
7 | {
8 | public static int HandleCommandLine(string arg)
9 | {
10 | string[] args = arg != null ? arg.Split(' ') : new string[0];
11 | return HandleCommandLine(args);
12 | }
13 | public static int HandleCommandLine(string[] args)
14 | {
15 | var clp = new CommandLineParser { SkipCommandsWhenHelpRequested = true };
16 |
17 | clp.Target = new CmdLineTarget();
18 | clp.Header = "SvgToXaml - Tool to convert SVGs to a Dictionary\r\n(c) 2015 Bernd Klaiber";
19 | clp.LogErrorsToConsole = true;
20 | try
21 | {
22 | return clp.ParseArgs(args, true);
23 | }
24 | catch (Exception)
25 | {
26 | //nothing to do, the errors are hopefully already reported via CommandLineParser
27 | Console.WriteLine("Error while handling Commandline.");
28 | return -1;
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/SvgConverter/CmdLineTarget.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Windows;
6 | using System.Xml.Linq;
7 | using BKLib.CommandLineParser;
8 |
9 | namespace SvgConverter
10 | {
11 | public class CmdLineTarget : SimpleBaseTarget
12 | {
13 | [ArgumentCommand(LongDesc = "Creates a ResourceDictionary with the svg-Images of a folder")]
14 | public int BuildDict(
15 | [ArgumentParam(Aliases = "i", Desc = "dir to the SVGs", LongDesc = "specify folder of the graphic files to process")]
16 | string inputdir,
17 | [ArgumentParam(Aliases = "o", LongDesc = "Name for the xaml outputfile")]
18 | string outputname,
19 | [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "folder for the xaml-Output, optional, default: folder of svgs")]
20 | string outputdir = null,
21 | [ArgumentParam(LongDesc = "Builds a htmlfile to browse the svgs, optional, default true")]
22 | bool buildhtmlfile = true,
23 | [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "Prefix to name all items of this file, optional, default: no prefix")]
24 | string nameprefix = null,
25 | [ArgumentParam(DefaultValue = false, ExplicitNeeded = false, LongDesc = "If true, es explicit ResourceKey File is created, default: false", ExplicitWantedArguments = "resKeyNS,resKeyNSName")]
26 | bool useComponentResKeys = false,
27 | [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "Namespace to use with UseResKey")]
28 | string compResKeyNS = null,
29 | [ArgumentParam(DefaultValue = null, ExplicitNeeded = false, LongDesc = "name of Namespace to use with UseResKey" )]
30 | string compResKeyNSName = null,
31 | [ArgumentParam(DefaultValue = false, ExplicitNeeded = false, LongDesc = "If true, PixelsPerDip is filtered to ensure compatibility for < 4.6.2, default: false")]
32 | bool filterPixelsPerDip = false,
33 | [ArgumentParam(DefaultValue = false, ExplicitNeeded = false, LongDesc = "Recursive goes through inputdir subfolders")]
34 | bool handleSubFolders = false
35 | )
36 | {
37 | Console.WriteLine("Building resource dictionary...");
38 | var outFileName = Path.Combine(outputdir ?? inputdir, outputname);
39 | if (!Path.HasExtension(outFileName))
40 | outFileName = Path.ChangeExtension(outFileName, ".xaml");
41 |
42 | var resKeyInfo = new ResKeyInfo
43 | {
44 | Name = null,
45 | XamlName = Path.GetFileNameWithoutExtension(outputname),
46 | Prefix = nameprefix,
47 | UseComponentResKeys = useComponentResKeys,
48 | NameSpace = compResKeyNS,
49 | NameSpaceName = compResKeyNSName,
50 | };
51 |
52 | File.WriteAllText(outFileName, ConverterLogic.SvgDirToXaml(inputdir, resKeyInfo, null, filterPixelsPerDip, handleSubFolders));
53 | Console.WriteLine("xaml written to: {0}", Path.GetFullPath(outFileName));
54 |
55 | if (buildhtmlfile)
56 | {
57 | var htmlFilePath = Path.Combine(inputdir,
58 | Path.GetFileNameWithoutExtension(outputname));
59 | var files = ConverterLogic.SvgFilesFromFolder(inputdir);
60 | BuildHtmlBrowseFile(files, htmlFilePath);
61 | }
62 | return 0; //no Error
63 | }
64 |
65 | private static void BuildHtmlBrowseFile(IEnumerable files, string outputFilename, int size = 128)
66 | {
67 | //
68 | //
69 | // Browse Images
70 | //
71 | //
72 | // Images in file xyz
73 | //
74 | //
75 | //
76 | //
77 | //
78 | //
79 | //
80 | //
81 | //
82 | //
83 | var doc = new XDocument(
84 | new XElement("html",
85 | new XElement("head",
86 | new XElement("title", "Browse svg images")),
87 | new XElement("body", $"Images in file: {outputFilename}",
88 | new XElement("br"),
89 | files.Select(
90 | f => new XElement("img",
91 | new XAttribute("src", Path.GetFileName(f) ?? ""),
92 | new XAttribute("title", Path.GetFileNameWithoutExtension(f) ?? ""),
93 | new XAttribute("height", size),
94 | new XAttribute("width", size)
95 | )
96 | )
97 | )
98 | ));
99 | var filename = Path.ChangeExtension(outputFilename, ".html");
100 | doc.Save(filename);
101 | Console.WriteLine("Html overview written to {0}", filename);
102 | }
103 | }
104 | }
105 |
--------------------------------------------------------------------------------
/SvgConverter/ConvertedSvgData.cs:
--------------------------------------------------------------------------------
1 | using System.IO;
2 | using System.Windows;
3 |
4 | namespace SvgConverter
5 | {
6 | public class ConvertedSvgData
7 | {
8 | private string _filepath;
9 | private string _xaml;
10 | private string _svg;
11 | private string _objectName;
12 | private DependencyObject _convertedObj;
13 |
14 | public string Filepath
15 | {
16 | get { return _filepath; }
17 | set { _filepath = value; }
18 | }
19 |
20 | public string Xaml
21 | {
22 | get { return _xaml ?? (_xaml = ConverterLogic.SvgObjectToXaml(ConvertedObj, false, _objectName, false)); }
23 | set { _xaml = value; }
24 | }
25 |
26 | public string Svg
27 | {
28 | get { return _svg ?? (_svg = File.ReadAllText(_filepath)); }
29 | set { _svg = value; }
30 | }
31 |
32 | public DependencyObject ConvertedObj
33 | {
34 | get
35 | {
36 | if (_convertedObj == null)
37 | {
38 | _convertedObj = ConverterLogic.ConvertSvgToObject(_filepath, ResultMode.DrawingImage, null, out _objectName, new ResKeyInfo()) as DependencyObject;
39 | }
40 | return _convertedObj;
41 | }
42 | set { _convertedObj = value; }
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/SvgConverter/FileUtils.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.IO;
3 |
4 | namespace SvgConverter
5 | {
6 | public enum PathIs
7 | {
8 | Folder,
9 | File
10 | }
11 |
12 | public static class FileUtils
13 | {
14 | ///
15 | /// Creates a relative path from one file or folder to another.
16 | ///
17 | /// Contains the directory that defines the start of the relative path.
18 | /// Is the fromPath a File or a Folder
19 | /// Contains the path that defines the endpoint of the relative path.
20 | /// Is the toPath a File or a Folder
21 | /// The relative path from the start directory to the end path or toPath if the paths are not related.
22 | ///
23 | ///
24 | ///
25 | public static string MakeRelativePath(string fromPath, PathIs fromIs, string toPath, PathIs toIs)
26 | {
27 | if (string.IsNullOrEmpty(fromPath)) throw new ArgumentNullException(nameof(fromPath));
28 | if (string.IsNullOrEmpty(toPath)) throw new ArgumentNullException(nameof(toPath));
29 |
30 | //Slash am Ende anfügen, damit Uri damit klarkommt und weiß, was ein Folder ist, und was nicht
31 | if (!fromPath.EndsWith(Path.DirectorySeparatorChar.ToString()) &&
32 | !fromPath.EndsWith(Path.AltDirectorySeparatorChar.ToString()) &&
33 | fromIs == PathIs.Folder)
34 | fromPath += Path.DirectorySeparatorChar;
35 | if (!toPath.EndsWith(Path.DirectorySeparatorChar.ToString()) &&
36 | !toPath.EndsWith(Path.AltDirectorySeparatorChar.ToString()) &&
37 | toIs == PathIs.Folder)
38 | toPath += Path.DirectorySeparatorChar;
39 |
40 | Uri fromUri = new Uri(fromPath);
41 | Uri toUri = new Uri(toPath);
42 |
43 | if (fromUri.Scheme != toUri.Scheme) { return toPath; } // path can't be made relative.
44 |
45 | Uri relativeUri = fromUri.MakeRelativeUri(toUri);
46 | string relativePath = Uri.UnescapeDataString(relativeUri.ToString());
47 |
48 | if (toUri.Scheme.ToUpperInvariant() == "FILE")
49 | {
50 | relativePath = relativePath.Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);
51 | }
52 | if (relativePath == string.Empty)
53 | relativePath = ".\\";
54 | //ein \ am Ende entfernen, dies macht Probleme, insbesondere in CommandLine wenn quoted
55 | //zudem scheint der .Net - Standard zu sein, kein \ am Ende zu haben vgl. Path.GetDirectoryname()
56 | return relativePath.TrimEnd(Path.DirectorySeparatorChar);
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/SvgConverter/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SvgConverter")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SvgConverter")]
13 | [assembly: AssemblyCopyright("Copyright © 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("c86f2400-f443-489c-ac68-3c48f70cff02")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.2.0.0")]
36 | [assembly: AssemblyFileVersion("1.2.0.0")]
37 |
38 | [assembly: InternalsVisibleTo("SvgConverterTest")]
--------------------------------------------------------------------------------
/SvgConverter/ResKeyInfo.cs:
--------------------------------------------------------------------------------
1 | namespace SvgConverter
2 | {
3 | public class ResKeyInfo
4 | {
5 | public string Name { get; set; }
6 | public string XamlName { get; set; }
7 | public string Prefix { get; set; }
8 | public bool UseComponentResKeys { get; set; }
9 | public string NameSpace { get; set; }
10 | public string NameSpaceName { get; set; }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/SvgConverter/SvgConverter.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {D1B291FE-A21B-4C27-930D-39CC2C963E13}
8 | Library
9 | Properties
10 | SvgConverter
11 | SvgConverter
12 | v4.6.2
13 | 512
14 |
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | false
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 | false
34 |
35 |
36 |
37 | ..\packages\BKEDV.CommandLineParser.1.0.4.0\lib\net40\CommandLineParser.dll
38 |
39 |
40 |
41 |
42 | ..\packages\SharpVectors.Reloaded.1.2.0\lib\net40\SharpVectors.Converters.Wpf.dll
43 |
44 |
45 | ..\packages\SharpVectors.Reloaded.1.2.0\lib\net40\SharpVectors.Core.dll
46 |
47 |
48 | ..\packages\SharpVectors.Reloaded.1.2.0\lib\net40\SharpVectors.Css.dll
49 |
50 |
51 | ..\packages\SharpVectors.Reloaded.1.2.0\lib\net40\SharpVectors.Dom.dll
52 |
53 |
54 | ..\packages\SharpVectors.Reloaded.1.2.0\lib\net40\SharpVectors.Model.dll
55 |
56 |
57 | ..\packages\SharpVectors.Reloaded.1.2.0\lib\net40\SharpVectors.Rendering.Gdi.dll
58 |
59 |
60 | ..\packages\SharpVectors.Reloaded.1.2.0\lib\net40\SharpVectors.Rendering.Wpf.dll
61 |
62 |
63 | ..\packages\SharpVectors.Reloaded.1.2.0\lib\net40\SharpVectors.Runtime.Wpf.dll
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
96 |
--------------------------------------------------------------------------------
/SvgConverter/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/SvgConverter/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/SvgConverterTest/CommandLineTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using FluentAssertions;
7 | using NUnit.Framework;
8 | using SvgConverter;
9 |
10 | namespace SvgConverterTest
11 | {
12 | [TestFixture]
13 | public class CommandLineTests
14 | {
15 | [Test]
16 | public void EmptyArgsTest1()
17 | {
18 | string arg = null;
19 | CmdLineHandler.HandleCommandLine(arg).Should().Be(0);
20 | }
21 | [Test]
22 | public void EmptyArgsTest2()
23 | {
24 | CmdLineHandler.HandleCommandLine("").Should().NotBe(0);
25 | }
26 | [Test]
27 | public void HelpTest()
28 | {
29 | CmdLineHandler.HandleCommandLine("-H").Should().Be(0);
30 | }
31 |
32 | [Test]
33 | public void DirTest()
34 | {
35 | var resultFile = ".\\images.xaml";
36 | if (File.Exists(resultFile))
37 | File.Delete(resultFile);
38 | CmdLineHandler.HandleCommandLine("BuildDict /inputdir:\"..\\..\\TestFiles\\\" /outputname:images /outputdir:.").Should().Be(0);
39 | File.Exists(resultFile).Should().BeTrue();
40 | }
41 |
42 | [Test]
43 | public void SubDirTest()
44 | {
45 | var resultFile = ".\\images.xaml";
46 | if (File.Exists(resultFile))
47 | File.Delete(resultFile);
48 | CmdLineHandler.HandleCommandLine("BuildDict /inputdir:\"..\\..\\TestFiles\\Subfolder1\\\" /handleSubFolders:true /outputname:images /outputdir:.").Should().Be(0);
49 | File.Exists(resultFile).Should().BeTrue();
50 | }
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/SvgConverterTest/FileUtilsTests.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using FluentAssertions;
6 | using NUnit.Framework;
7 | using SvgConverter;
8 |
9 | namespace SvgConverterTest
10 | {
11 | public class FileUtilsTests
12 | {
13 | [TestCase(@"C:\Temp\", PathIs.Folder, @"C:\Temp\Sub", PathIs.Folder, @"Sub")]
14 | [TestCase(@"C:\Temp", PathIs.Folder, @"C:\Temp\Sub", PathIs.Folder, @"Sub")]
15 | [TestCase(@"C:\Temp", PathIs.Folder, @"C:\Temp\", PathIs.Folder, @".")]
16 | [TestCase(@"C:\Temp", PathIs.Folder, @"C:\", PathIs.Folder, @"..")]
17 | [TestCase(@"D:\Projects\SvgToXaml\WpfDemoApp\ImagesC\Svg", PathIs.Folder, @"D:\Projects\SvgToXaml\WpfDemoApp\ImagesC", PathIs.Folder, @"..")]
18 | [TestCase(@"C:\Temp\", PathIs.Folder, @"C:\Temp\Sub", PathIs.File, @"Sub")]
19 | [TestCase(@"C:\Temp", PathIs.File, @"C:\Temp\Sub", PathIs.Folder, @"Temp\Sub")]
20 | [TestCase(@"C:\Temp\Sub", PathIs.Folder, @"C:\Temp\file", PathIs.File, @"..\file")]
21 | [TestCase(@"C:\Temp", PathIs.File, @"C:\Temp", PathIs.File, @".")]
22 | [TestCase(@"C:\Temp", PathIs.Folder, @"C:\Temp", PathIs.Folder, @".")]
23 | public void MakeRelativePath(string fromPath, PathIs fromIs, string toPath, PathIs toIs, string result)
24 | {
25 | FileUtils.MakeRelativePath(fromPath, fromIs, toPath, toIs).Should().Be(result);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/SvgConverterTest/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("SvgConverterTest")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("SvgConverterTest")]
13 | [assembly: AssemblyCopyright("Copyright © 2013")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("0fa9b914-9eea-4b68-a56c-6692e6c745ae")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/SvgConverterTest/SvgzTest.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.IO.Compression;
5 | using System.Linq;
6 | using System.Net;
7 | using System.Text;
8 | using System.Threading.Tasks;
9 | using NUnit.Framework;
10 |
11 | namespace SvgConverterTest
12 | {
13 | public class SvgzTest
14 | {
15 | [Test]
16 | public void TestUnzip()
17 | {
18 | var fs = File.OpenRead(@".\TestFiles\example.svgz");
19 | var stream = new System.IO.Compression.GZipStream(fs, CompressionMode.Decompress);
20 | var destination = File.OpenWrite(@".\TestFiles\example.svg");
21 | stream.CopyTo(destination);
22 |
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/SvgConverterTest/T4Methods.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Xml.Linq;
6 | using NUnit.Framework;
7 |
8 | namespace SvgConverterTest
9 | {
10 | public class T4Methods
11 | {
12 | [Test]
13 | public void Test_KeysFromXaml()
14 | {
15 | string nameSpaceName;
16 | string prefix;
17 | var keys = KeysFromXaml(@"TestFiles\Expected\SvgDirToXamlTest_withUseCompResKey.xaml", out nameSpaceName, out prefix);
18 | Console.WriteLine($"NS:{nameSpaceName}, Prefix:{prefix}");
19 | foreach (var key in keys)
20 | {
21 | Console.WriteLine(key);
22 | }
23 | }
24 |
25 | public static IEnumerable KeysFromXaml(string fileName, out string nameSpace, out string prefix)
26 | {
27 | var doc = XDocument.Load(fileName);
28 | //var allElems = doc.Root.Elements(); //doc.Descendants(); das wären alle samt SubNodes
29 | XNamespace xamlNs = "http://schemas.microsoft.com/winfx/2006/xaml";
30 | //var keyAttrs = allElems.Attributes(xamlNs+"Key");
31 |
32 |
33 | //Console.WriteLine(keyAttrs.Count());
34 | //foreach (var attr in keyAttrs)
35 | //{
36 | // Console.WriteLine(attr.Name);
37 | //}
38 | nameSpace = doc.Root.LastAttribute.Value; //hoffentlich ist es immer das letzte, aber nach Namen suchen is nich, und andere ausschließen ist auch nicht besser
39 | var keys = doc.Root.Elements().Attributes(xamlNs + "Key").Select(a => a.Value).ToArray();
40 | //keys liegen in dieser Form vor: { x: Static NameSpaceName:XamlName.Color1}
41 |
42 | prefix = "unknownPrefix";
43 | var first = keys.FirstOrDefault();
44 | if (first != null)
45 | {
46 | var p1 = first.LastIndexOf(":");
47 | var p2 = first.LastIndexOf("}");
48 | if (p1 < p2)
49 | prefix = first.Substring(p1 + 1, p2 - p1 - 1).Split('.').FirstOrDefault();
50 | }
51 |
52 | var names = keys.Select(key =>
53 | {
54 | var p1 = key.LastIndexOf(".");
55 | var p2 = key.LastIndexOf("}");
56 | if (p1 < p2)
57 | return key.Substring(p1 + 1, p2 - p1 - 1);
58 | else
59 | return key;
60 | }).ToArray();
61 |
62 |
63 | return names;
64 | }
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/3d-view-icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
19 |
20 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/ConvertFileToDrawingGroup2.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/ConvertFileToDrawingGroupWithRuntime_JOG.svg.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/ConvertFileToDrawingGroupWithRuntime_cloud-3-icon.svg.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/ConvertFileToDrawingGroup_3d-view-icon.svg.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/ConvertFileToDrawingGroup_JOG.svg.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/ConvertFileToDrawingGroup_cloud-3-icon.svg.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/ConvertFileToDrawingImage_3d-view-icon.svg.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/ConvertFileToDrawingImage_JOG.svg.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/ConvertFileToDrawingImage_cloud-3-icon.svg.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/Handwheel.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/Handwheel1.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/Handwheel2.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Expected/Handwheel3.xaml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Images.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Browse svg images
5 |
6 | Images in file: ..\..\TestFiles\images





7 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Readme.txt:
--------------------------------------------------------------------------------
1 | some of these icons are copyrighted by iconmonstr.com
2 | Please respect copyright!
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Subfolder1/3d-view-b-icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
6 |
7 |
8 |
9 |
10 |
19 |
20 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Subfolder1/Subfolder2/cloud-3-a-icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
16 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/Subfolder1/images.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Browse svg images
5 |
6 | Images in file: ..\..\TestFiles\Subfolder1\images

7 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/cloud-3-icon.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
5 |
6 |
7 |
16 |
--------------------------------------------------------------------------------
/SvgConverterTest/TestFiles/example.svgz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BerndK/SvgToXaml/87e6fcc39012620e759f83257a3900faf11e87d9/SvgConverterTest/TestFiles/example.svgz
--------------------------------------------------------------------------------
/SvgConverterTest/app.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/SvgConverterTest/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/SvgToXaml.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25123.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgConverter", "SvgConverter\SvgConverter.csproj", "{D1B291FE-A21B-4C27-930D-39CC2C963E13}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgConverterTest", "SvgConverterTest\SvgConverterTest.csproj", "{B4508A49-AE03-4427-980F-15FAF7B0CC8F}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgToXaml", "SvgToXaml\SvgToXaml.csproj", "{0CAF3717-683D-45D3-94A1-CFA4828EF67B}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IconResources", "IconResources\IconResources.csproj", "{618E080B-86D8-4F12-B141-EFFE222D6E9F}"
13 | EndProject
14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDemoApp", "WpfDemoApp\WpfDemoApp.csproj", "{1582B923-7D2E-446E-9871-F7E1DB8D911F}"
15 | EndProject
16 | Global
17 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
18 | Debug|Any CPU = Debug|Any CPU
19 | Release|Any CPU = Release|Any CPU
20 | EndGlobalSection
21 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
22 | {D1B291FE-A21B-4C27-930D-39CC2C963E13}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23 | {D1B291FE-A21B-4C27-930D-39CC2C963E13}.Debug|Any CPU.Build.0 = Debug|Any CPU
24 | {D1B291FE-A21B-4C27-930D-39CC2C963E13}.Release|Any CPU.ActiveCfg = Release|Any CPU
25 | {D1B291FE-A21B-4C27-930D-39CC2C963E13}.Release|Any CPU.Build.0 = Release|Any CPU
26 | {B4508A49-AE03-4427-980F-15FAF7B0CC8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
27 | {B4508A49-AE03-4427-980F-15FAF7B0CC8F}.Debug|Any CPU.Build.0 = Debug|Any CPU
28 | {B4508A49-AE03-4427-980F-15FAF7B0CC8F}.Release|Any CPU.ActiveCfg = Release|Any CPU
29 | {B4508A49-AE03-4427-980F-15FAF7B0CC8F}.Release|Any CPU.Build.0 = Release|Any CPU
30 | {0CAF3717-683D-45D3-94A1-CFA4828EF67B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
31 | {0CAF3717-683D-45D3-94A1-CFA4828EF67B}.Debug|Any CPU.Build.0 = Debug|Any CPU
32 | {0CAF3717-683D-45D3-94A1-CFA4828EF67B}.Release|Any CPU.ActiveCfg = Release|Any CPU
33 | {0CAF3717-683D-45D3-94A1-CFA4828EF67B}.Release|Any CPU.Build.0 = Release|Any CPU
34 | {618E080B-86D8-4F12-B141-EFFE222D6E9F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
35 | {618E080B-86D8-4F12-B141-EFFE222D6E9F}.Debug|Any CPU.Build.0 = Debug|Any CPU
36 | {618E080B-86D8-4F12-B141-EFFE222D6E9F}.Release|Any CPU.ActiveCfg = Release|Any CPU
37 | {618E080B-86D8-4F12-B141-EFFE222D6E9F}.Release|Any CPU.Build.0 = Release|Any CPU
38 | {1582B923-7D2E-446E-9871-F7E1DB8D911F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
39 | {1582B923-7D2E-446E-9871-F7E1DB8D911F}.Debug|Any CPU.Build.0 = Debug|Any CPU
40 | {1582B923-7D2E-446E-9871-F7E1DB8D911F}.Release|Any CPU.ActiveCfg = Release|Any CPU
41 | {1582B923-7D2E-446E-9871-F7E1DB8D911F}.Release|Any CPU.Build.0 = Release|Any CPU
42 | EndGlobalSection
43 | GlobalSection(SolutionProperties) = preSolution
44 | HideSolutionNode = FALSE
45 | EndGlobalSection
46 | EndGlobal
47 |
--------------------------------------------------------------------------------
/SvgToXaml.sln.DotSettings:
--------------------------------------------------------------------------------
1 |
2 | NS
3 | False
4 | False
--------------------------------------------------------------------------------
/SvgToXaml/App.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/SvgToXaml/App.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace SvgToXaml
2 | {
3 | ///
4 | /// Interaction logic for App.xaml
5 | ///
6 | public partial class App
7 | {
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/SvgToXaml/Command/IActiveAware.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace SvgToXaml.Command
4 | {
5 | ///
6 | /// Interface that defines if the object instance is active
7 | /// and notifies when the activity changes.
8 | ///
9 | ///
10 | public interface IActiveAware
11 | {
12 | ///
13 | /// Gets or sets a value indicating whether the object is active.
14 | ///
15 | ///
16 | ///
17 | ///
18 | /// if the object is active; otherwise .
19 | ///
20 | bool IsActive { get; set; }
21 |
22 | ///
23 | /// Notifies that the value for property has changed.
24 | ///
25 | ///
26 | event EventHandler IsActiveChanged;
27 | }
28 | }
--------------------------------------------------------------------------------
/SvgToXaml/Command/WeakEventHandlerManager.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Threading;
4 |
5 | namespace SvgToXaml.Command
6 | {
7 | ///
8 | /// Handles management and dispatching of EventHandlers in a weak way.
9 | ///
10 | ///
11 | public static class WeakEventHandlerManager
12 | {
13 | private static readonly SynchronizationContext SyncContext = SynchronizationContext.Current;
14 |
15 | ///
16 | /// Invokes the handlers
17 | ///
18 | ///
19 | ///
20 | public static void CallWeakReferenceHandlers(object sender, List handlers)
21 | {
22 | if (handlers == null)
23 | return;
24 | EventHandler[] callees = new EventHandler[handlers.Count];
25 | int count = 0;
26 | int num = CleanupOldHandlers(handlers, callees, count);
27 | for (int index = 0; index < num; ++index)
28 | CallHandler(sender, callees[index]);
29 | }
30 |
31 | private static void CallHandler(object sender, EventHandler eventHandler)
32 | {
33 | if (eventHandler == null)
34 | return;
35 | if (SyncContext != null)
36 | SyncContext.Post(o => eventHandler(sender, EventArgs.Empty), null);
37 | else
38 | eventHandler(sender, EventArgs.Empty);
39 | }
40 |
41 | private static int CleanupOldHandlers(List handlers, EventHandler[] callees, int count)
42 | {
43 | for (int index = handlers.Count - 1; index >= 0; --index)
44 | {
45 | EventHandler eventHandler = handlers[index].Target as EventHandler;
46 | if (eventHandler == null)
47 | {
48 | handlers.RemoveAt(index);
49 | }
50 | else
51 | {
52 | callees[count] = eventHandler;
53 | ++count;
54 | }
55 | }
56 | return count;
57 | }
58 |
59 | ///
60 | /// Adds a handler to the supplied list in a weak way.
61 | ///
62 | ///
63 | /// Existing handler list. It will be created if null.Handler to add.Default list size.
64 | public static void AddWeakReferenceHandler(ref List handlers, EventHandler handler, int defaultListSize)
65 | {
66 | if (handlers == null)
67 | handlers = defaultListSize > 0 ? new List(defaultListSize) : new List();
68 | handlers.Add(new WeakReference(handler));
69 | }
70 |
71 | ///
72 | /// Removes an event handler from the reference list.
73 | ///
74 | ///
75 | /// Handler list to remove reference from.Handler to remove.
76 | public static void RemoveWeakReferenceHandler(List handlers, EventHandler handler)
77 | {
78 | if (handlers == null)
79 | return;
80 | for (int index = handlers.Count - 1; index >= 0; --index)
81 | {
82 | EventHandler eventHandler = handlers[index].Target as EventHandler;
83 | if (eventHandler == null || eventHandler == handler)
84 | handlers.RemoveAt(index);
85 | }
86 | }
87 | }
88 | }
--------------------------------------------------------------------------------
/SvgToXaml/CustomDefined.targets:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | %(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/SvgToXaml/DetailWindow.xaml:
--------------------------------------------------------------------------------
1 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/SvgToXaml/DetailWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 | using System.Windows;
4 | using System.Windows.Input;
5 | using System.Windows.Media;
6 |
7 | namespace SvgToXaml
8 | {
9 | ///
10 | /// Interaction logic for DetailWindow.xaml
11 | ///
12 | public partial class DetailWindow
13 | {
14 | public DetailWindow()
15 | {
16 | InitializeComponent();
17 | }
18 |
19 | private void CopyToClipboardClick(object sender, RoutedEventArgs e)
20 | {
21 | Clipboard.SetText(XmlViewer.Text);
22 | }
23 |
24 | private void ToggleStretchClicked(object sender, MouseButtonEventArgs e)
25 | {
26 | var values = Enum.GetValues(typeof(Stretch)).OfType().ToList();
27 | var idx = values.IndexOf(Image.Stretch);
28 | idx = (idx + 1) % values.Count;
29 | Image.Stretch = values[idx];
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/SvgToXaml/Explorer/FolderTree.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/SvgToXaml/Explorer/FolderTree.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Collections.ObjectModel;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Windows;
7 | using System.Windows.Controls;
8 | using System.Windows.Input;
9 |
10 | namespace SvgToXaml.Explorer
11 | {
12 | ///
13 | /// Interaction logic for FolderTree.xaml
14 | ///
15 | public partial class FolderTree
16 | {
17 | public static readonly DependencyProperty CurrentFolderProperty = DependencyProperty.Register(
18 | "CurrentFolder", typeof (string), typeof (FolderTree), new PropertyMetadata(default(string), CurrentFolderChanged));
19 |
20 | private static void CurrentFolderChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs)
21 | {
22 | FolderTree folderTree = (FolderTree)dependencyObject;
23 | var item = folderTree.FindItem(folderTree.FoldersTree, (string)dependencyPropertyChangedEventArgs.NewValue);
24 | if (item!=null)
25 | folderTree.SelectItem(item);
26 | }
27 |
28 | public string CurrentFolder
29 | {
30 | get { return (string) GetValue(CurrentFolderProperty); }
31 | set { SetValue(CurrentFolderProperty, value); }
32 | }
33 | private readonly object _dummyNode = null;
34 |
35 | public FolderTree()
36 | {
37 | InitializeComponent();
38 | FillRootLevel();
39 | FoldersTree.SelectedItemChanged += FoldersTreeOnSelectedItemChanged;
40 | }
41 |
42 | public static readonly DependencyProperty ContextMenuCommandsProperty = DependencyProperty.Register(
43 | "ContextMenuCommands", typeof (ObservableCollection>), typeof (FolderTree), new PropertyMetadata(default(ObservableCollection>)));
44 |
45 | public ObservableCollection> ContextMenuCommands
46 | {
47 | get { return (ObservableCollection>) GetValue(ContextMenuCommandsProperty); }
48 | set { SetValue(ContextMenuCommandsProperty, value); }
49 | }
50 |
51 | private void FoldersTreeOnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs