Add console app
This commit is contained in:
Родитель
92a0c34717
Коммит
d45d376659
|
@ -1,7 +1,10 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
#
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgToXaml", "SvgToXaml\SvgToXaml.csproj", "{F6C225E1-F217-4146-8FC5-536B93B2ED93}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SvgToXamlConverter", "SvgToXamlConverter\SvgToXamlConverter.csproj", "{06BE0887-524B-4119-814D-42AE1DCA4C91}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
|
@ -12,5 +15,9 @@ Global
|
|||
{F6C225E1-F217-4146-8FC5-536B93B2ED93}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{F6C225E1-F217-4146-8FC5-536B93B2ED93}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{F6C225E1-F217-4146-8FC5-536B93B2ED93}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{06BE0887-524B-4119-814D-42AE1DCA4C91}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{06BE0887-524B-4119-814D-42AE1DCA4C91}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{06BE0887-524B-4119-814D-42AE1DCA4C91}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{06BE0887-524B-4119-814D-42AE1DCA4C91}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
@ -14,5 +14,12 @@
|
|||
<PackageReference Include="Avalonia.ReactiveUI" Version="0.10.999-cibuild0015120-beta" />
|
||||
<PackageReference Include="Avalonia.Controls.Skia" Version="0.10.6.2" />
|
||||
<PackageReference Include="Svg.Skia" Version="0.5.6.2" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.0-preview.61" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.0-preview.61" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="..\SvgToXamlConverter\SvgConverter.cs">
|
||||
<Link>SvgConverter.cs</Link>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Windows.Input;
|
||||
using ReactiveUI;
|
||||
using SkiaSharp;
|
||||
using Svg.Skia;
|
||||
|
||||
namespace SvgToXaml.ViewModels
|
||||
|
@ -11,7 +10,7 @@ namespace SvgToXaml.ViewModels
|
|||
private string _name;
|
||||
private string _path;
|
||||
private SKSvg? _svg;
|
||||
private SKPicture? _picture;
|
||||
private SkiaSharp.SKPicture? _picture;
|
||||
|
||||
public string Name
|
||||
{
|
||||
|
@ -31,7 +30,7 @@ namespace SvgToXaml.ViewModels
|
|||
private set => this.RaiseAndSetIfChanged(ref _svg, value);
|
||||
}
|
||||
|
||||
public SKPicture? Picture
|
||||
public SkiaSharp.SKPicture? Picture
|
||||
{
|
||||
get => _picture;
|
||||
private set => this.RaiseAndSetIfChanged(ref _picture, value);
|
||||
|
|
|
@ -10,6 +10,7 @@ using Avalonia.Controls.ApplicationLifetimes;
|
|||
using Avalonia.Threading;
|
||||
using ReactiveUI;
|
||||
using Svg.Skia;
|
||||
using SvgToXamlConverter;
|
||||
|
||||
namespace SvgToXaml.ViewModels
|
||||
{
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using Svg.Skia;
|
||||
|
||||
namespace SvgToXamlConverter
|
||||
{
|
||||
class Program
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
if (args.Length == 1 || args.Length == 2)
|
||||
{
|
||||
try
|
||||
{
|
||||
var inputPath = args[0];
|
||||
var svg = new SKSvg();
|
||||
var picture = svg.Load(inputPath);
|
||||
var xaml = SvgConverter.ToXaml(svg.Model);
|
||||
|
||||
if (args.Length == 1)
|
||||
{
|
||||
Console.WriteLine(xaml);
|
||||
}
|
||||
|
||||
if (args.Length == 2)
|
||||
{
|
||||
var outputPath = args[1];
|
||||
File.WriteAllText(outputPath, xaml);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"{ex.Message}");
|
||||
Console.WriteLine($"{ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,11 +4,11 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using ShimSkiaSharp;
|
||||
|
||||
namespace SvgToXaml
|
||||
namespace SvgToXamlConverter
|
||||
{
|
||||
public static class SvgConverter
|
||||
{
|
||||
public static char[] NewLine = { '\r', '\n' };
|
||||
public static string NewLine = "\r\n";
|
||||
|
||||
public static string ToString(double value)
|
||||
{
|
|
@ -0,0 +1,12 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net5.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Svg.Skia" Version="0.5.6.2" />
|
||||
<PackageReference Include="SkiaSharp" Version="2.88.0-preview.61" />
|
||||
<PackageReference Include="SkiaSharp.NativeAssets.Linux" Version="2.88.0-preview.61" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Загрузка…
Ссылка в новой задаче