diff --git a/src/SvgToXaml.Base/ViewModels/MainWindowViewModel.cs b/src/SvgToXaml.Base/ViewModels/MainWindowViewModel.cs index 5ea5585..0e206da 100644 --- a/src/SvgToXaml.Base/ViewModels/MainWindowViewModel.cs +++ b/src/SvgToXaml.Base/ViewModels/MainWindowViewModel.cs @@ -96,12 +96,6 @@ public class MainWindowViewModel : ViewModelBase await Reload(); }); - // ReSharper disable once AsyncVoidLambda - this.WhenAnyValue(x => x.Project.Settings.UseBrushTransform).Subscribe(async _ => - { - await Reload(); - }); - // ReSharper disable once AsyncVoidLambda this.WhenAnyValue(x => x.Project.Settings.IgnoreOpacity).Subscribe(async _ => { @@ -410,7 +404,6 @@ public class MainWindowViewModel : ViewModelBase var converter = new SvgToXamlConverter.SvgToXamlConverter() { UseCompatMode = Project.Settings.UseCompatMode, - UseBrushTransform = Project.Settings.UseBrushTransform, ReuseExistingResources = Project.Settings.ReuseExistingResources, Resources = Project.Settings.UseResources ? new ResourceDictionary() : null }; @@ -423,7 +416,6 @@ public class MainWindowViewModel : ViewModelBase var converter = new SvgToXamlConverter.SvgToXamlConverter() { UseCompatMode = Project.Settings.UseCompatMode, - UseBrushTransform = Project.Settings.UseBrushTransform, ReuseExistingResources = Project.Settings.ReuseExistingResources, Resources = Project.Settings.UseResources ? new ResourceDictionary() : null }; @@ -497,7 +489,6 @@ public class MainWindowViewModel : ViewModelBase var converter = new SvgToXamlConverter.SvgToXamlConverter() { UseCompatMode = Project.Settings.UseCompatMode, - UseBrushTransform = Project.Settings.UseBrushTransform, AddTransparentBackground = Project.Settings.AddTransparentBackground, ReuseExistingResources = Project.Settings.ReuseExistingResources, Resources = Project.Settings.UseResources ? new ResourceDictionary() : null @@ -511,7 +502,6 @@ public class MainWindowViewModel : ViewModelBase var converter = new SvgToXamlConverter.SvgToXamlConverter() { UseCompatMode = Project.Settings.UseCompatMode, - UseBrushTransform = Project.Settings.UseBrushTransform, AddTransparentBackground = Project.Settings.AddTransparentBackground, ReuseExistingResources = Project.Settings.ReuseExistingResources, Resources = Project.Settings.UseResources ? new ResourceDictionary() : null @@ -533,7 +523,6 @@ public class MainWindowViewModel : ViewModelBase var converter = new SvgToXamlConverter.SvgToXamlConverter() { UseCompatMode = Project.Settings.UseCompatMode, - UseBrushTransform = Project.Settings.UseBrushTransform, ReuseExistingResources = Project.Settings.ReuseExistingResources, Resources = Project.Settings.UseResources ? new ResourceDictionary() : null }; @@ -592,7 +581,6 @@ public class MainWindowViewModel : ViewModelBase var converter = new SvgToXamlConverter.SvgToXamlConverter() { UseCompatMode = Project.Settings.UseCompatMode, - UseBrushTransform = Project.Settings.UseBrushTransform, ReuseExistingResources = Project.Settings.ReuseExistingResources, Resources = Project.Settings.UseResources ? new ResourceDictionary() : null }; diff --git a/src/SvgToXaml.Base/ViewModels/ProjectViewModel.cs b/src/SvgToXaml.Base/ViewModels/ProjectViewModel.cs index 941fa2a..a020bbe 100644 --- a/src/SvgToXaml.Base/ViewModels/ProjectViewModel.cs +++ b/src/SvgToXaml.Base/ViewModels/ProjectViewModel.cs @@ -44,7 +44,6 @@ public class ProjectViewModel : ViewModelBase UseResources = true, ReuseExistingResources = true, UseCompatMode = false, - UseBrushTransform = false, AddTransparentBackground = true, IgnoreOpacity = false, IgnoreFilter = false, diff --git a/src/SvgToXaml.Base/ViewModels/SettingsViewModel.cs b/src/SvgToXaml.Base/ViewModels/SettingsViewModel.cs index bc4eddd..42052fc 100644 --- a/src/SvgToXaml.Base/ViewModels/SettingsViewModel.cs +++ b/src/SvgToXaml.Base/ViewModels/SettingsViewModel.cs @@ -10,7 +10,6 @@ public class SettingsViewModel : ViewModelBase private bool _useResources; private bool _reuseExistingResources; private bool _useCompatMode; - private bool _useBrushTransform; private bool _addTransparentBackground; private bool _ignoreOpacity; private bool _ignoreFilter; @@ -52,13 +51,6 @@ public class SettingsViewModel : ViewModelBase set => this.RaiseAndSetIfChanged(ref _useCompatMode, value); } - [JsonInclude] - public bool UseBrushTransform - { - get => _useBrushTransform; - set => this.RaiseAndSetIfChanged(ref _useBrushTransform, value); - } - [JsonInclude] public bool AddTransparentBackground { diff --git a/src/SvgToXaml.Base/Views/MainView.axaml b/src/SvgToXaml.Base/Views/MainView.axaml index 9321aca..e3b70e5 100644 --- a/src/SvgToXaml.Base/Views/MainView.axaml +++ b/src/SvgToXaml.Base/Views/MainView.axaml @@ -355,12 +355,6 @@ HorizontalContentAlignment="Stretch" Margin="0" Padding="6"/> - {context.NewLine}"); - if (context.UseBrushTransform) + if (linearGradientBrush.LocalMatrix is { }) { - if (linearGradientBrush.LocalMatrix is { }) - { - // TODO: Missing Transform property on LinearGradientBrush - var localMatrix = linearGradientBrush.LocalMatrix.Value; + var localMatrix = linearGradientBrush.LocalMatrix.Value; - if (!context.UseCompatMode) - { - localMatrix = linearGradientBrush.WithTransXY(localMatrix, linearGradientBrush.Bounds.Location.X, linearGradientBrush.Bounds.Location.Y); - } - - sb.Append($" {context.NewLine}"); - sb.Append($" {context.NewLine}"); - sb.Append($" {context.NewLine}"); - } + sb.Append($" {context.NewLine}"); + sb.Append($" {context.NewLine}"); + sb.Append($" {context.NewLine}"); } if (linearGradientBrush.GradientStops.Count > 0) @@ -268,43 +226,6 @@ public class XamlGenerator : GeneratorBase var center = radialGradientBrush.Center; var gradientOrigin = radialGradientBrush.Center; - if (!context.UseBrushTransform) - { - if (radialGradientBrush.LocalMatrix is { }) - { - var localMatrix = radialGradientBrush.LocalMatrix.Value; - - localMatrix.TransX = Math.Max(0f, localMatrix.TransX - radialGradientBrush.Bounds.Location.X); - localMatrix.TransY = Math.Max(0f, localMatrix.TransY - radialGradientBrush.Bounds.Location.Y); - - center = localMatrix.MapPoint(center); - gradientOrigin = localMatrix.MapPoint(gradientOrigin); - - var radiusMapped = localMatrix.MapVector(new SkiaSharp.SKPoint(radius, 0)); - radius = radiusMapped.X; - } - else - { - center.X = Math.Max(0f, center.X - radialGradientBrush.Bounds.Location.X); - center.Y = Math.Max(0f, center.Y - radialGradientBrush.Bounds.Location.Y); - gradientOrigin.X = Math.Max(0f, gradientOrigin.X - radialGradientBrush.Bounds.Location.X); - gradientOrigin.Y = Math.Max(0f, gradientOrigin.Y - radialGradientBrush.Bounds.Location.Y); - } - } - else - { - if (!context.UseCompatMode) - { - if (radialGradientBrush.LocalMatrix is null) - { - center.X = Math.Max(0f, center.X - radialGradientBrush.Bounds.Location.X); - center.Y = Math.Max(0f, center.Y - radialGradientBrush.Bounds.Location.Y); - gradientOrigin.X = Math.Max(0f, gradientOrigin.X - radialGradientBrush.Bounds.Location.X); - gradientOrigin.Y = Math.Max(0f, gradientOrigin.Y - radialGradientBrush.Bounds.Location.Y); - } - } - } - if (!context.UseCompatMode) { radius = radius / radialGradientBrush.Bounds.Width; @@ -337,22 +258,13 @@ public class XamlGenerator : GeneratorBase sb.Append($">{context.NewLine}"); - if (context.UseBrushTransform) + if (radialGradientBrush.LocalMatrix is { }) { - if (radialGradientBrush.LocalMatrix is { }) - { - // TODO: Missing Transform property on RadialGradientBrush - var localMatrix = radialGradientBrush.LocalMatrix.Value; + var localMatrix = radialGradientBrush.LocalMatrix.Value; - if (!context.UseCompatMode) - { - localMatrix = radialGradientBrush.WithTransXY(localMatrix, radialGradientBrush.Bounds.Location.X, radialGradientBrush.Bounds.Location.Y); - } - - sb.Append($" {context.NewLine}"); - sb.Append($" {context.NewLine}"); - sb.Append($" {context.NewLine}"); - } + sb.Append($" {context.NewLine}"); + sb.Append($" {context.NewLine}"); + sb.Append($" {context.NewLine}"); } if (radialGradientBrush.GradientStops.Count > 0) @@ -389,43 +301,6 @@ public class XamlGenerator : GeneratorBase var center = twoPointConicalGradientBrush.End; var gradientOrigin = twoPointConicalGradientBrush.Start; - if (!context.UseBrushTransform) - { - if (twoPointConicalGradientBrush.LocalMatrix is { }) - { - var localMatrix = twoPointConicalGradientBrush.LocalMatrix.Value; - - localMatrix.TransX = Math.Max(0f, localMatrix.TransX - twoPointConicalGradientBrush.Bounds.Location.X); - localMatrix.TransY = Math.Max(0f, localMatrix.TransY - twoPointConicalGradientBrush.Bounds.Location.Y); - - center = localMatrix.MapPoint(center); - gradientOrigin = localMatrix.MapPoint(gradientOrigin); - - var radiusMapped = localMatrix.MapVector(new SkiaSharp.SKPoint(endRadius, 0)); - endRadius = radiusMapped.X; - } - else - { - center.X = Math.Max(0f, center.X - twoPointConicalGradientBrush.Bounds.Location.X); - center.Y = Math.Max(0f, center.Y - twoPointConicalGradientBrush.Bounds.Location.Y); - gradientOrigin.X = Math.Max(0f, gradientOrigin.X - twoPointConicalGradientBrush.Bounds.Location.X); - gradientOrigin.Y = Math.Max(0f, gradientOrigin.Y - twoPointConicalGradientBrush.Bounds.Location.Y); - } - } - else - { - if (!context.UseCompatMode) - { - if (twoPointConicalGradientBrush.LocalMatrix is null) - { - center.X = Math.Max(0f, center.X - twoPointConicalGradientBrush.Bounds.Location.X); - center.Y = Math.Max(0f, center.Y - twoPointConicalGradientBrush.Bounds.Location.Y); - gradientOrigin.X = Math.Max(0f, gradientOrigin.X - twoPointConicalGradientBrush.Bounds.Location.X); - gradientOrigin.Y = Math.Max(0f, gradientOrigin.Y - twoPointConicalGradientBrush.Bounds.Location.Y); - } - } - } - if (!context.UseCompatMode) { endRadius = endRadius / twoPointConicalGradientBrush.Bounds.Width; @@ -458,22 +333,13 @@ public class XamlGenerator : GeneratorBase sb.Append($">{context.NewLine}"); - if (context.UseBrushTransform) + if (twoPointConicalGradientBrush.LocalMatrix is { }) { - if (twoPointConicalGradientBrush.LocalMatrix is { }) - { - // TODO: Missing Transform property on RadialGradientBrush - var localMatrix = twoPointConicalGradientBrush.LocalMatrix.Value; + var localMatrix = twoPointConicalGradientBrush.LocalMatrix.Value; - if (!context.UseCompatMode) - { - localMatrix = twoPointConicalGradientBrush.WithTransXY(localMatrix, twoPointConicalGradientBrush.Bounds.Location.X, twoPointConicalGradientBrush.Bounds.Location.Y); - } - - sb.Append($" {context.NewLine}"); - sb.Append($" {context.NewLine}"); - sb.Append($" {context.NewLine}"); - } + sb.Append($" {context.NewLine}"); + sb.Append($" {context.NewLine}"); + sb.Append($" {context.NewLine}"); } if (twoPointConicalGradientBrush.GradientStops.Count > 0) @@ -504,23 +370,6 @@ public class XamlGenerator : GeneratorBase var sb = new StringBuilder(); - if (!context.UseBrushTransform) - { - if (pictureBrush.LocalMatrix is { }) - { - var localMatrix = pictureBrush.LocalMatrix.Value; - - if (!localMatrix.IsIdentity) - { - // TODO: LocalMatrix - } - } - else - { - // TODO: Adjust using Bounds.Location ? - } - } - var sourceRect = pictureBrush.CullRect; var destinationRect = pictureBrush.Tile; @@ -559,22 +408,13 @@ public class XamlGenerator : GeneratorBase sb.Append($">{context.NewLine}"); - if (context.UseBrushTransform) + if (pictureBrush.LocalMatrix is { }) { - if (pictureBrush.LocalMatrix is { }) - { - // TODO: Missing Transform property on VisualBrush - var localMatrix = pictureBrush.LocalMatrix.Value; + var localMatrix = pictureBrush.LocalMatrix.Value; - if (!context.UseCompatMode) - { - localMatrix = pictureBrush.WithTransXY(localMatrix, pictureBrush.Bounds.Location.X, pictureBrush.Bounds.Location.Y); - } - - sb.Append($" {context.NewLine}"); - sb.Append($" {context.NewLine}"); - sb.Append($" {context.NewLine}"); - } + sb.Append($" {context.NewLine}"); + sb.Append($" {context.NewLine}"); + sb.Append($" {context.NewLine}"); } if (pictureBrush.Picture is not null) diff --git a/src/SvgToXamlConverter/SvgToXamlConverter.cs b/src/SvgToXamlConverter/SvgToXamlConverter.cs index c860bd3..fb5639a 100644 --- a/src/SvgToXamlConverter/SvgToXamlConverter.cs +++ b/src/SvgToXamlConverter/SvgToXamlConverter.cs @@ -17,8 +17,6 @@ public class SvgToXamlConverter public bool UseCompatMode { get; set; } - public bool UseBrushTransform { get; set; } - public bool AddTransparentBackground { get; set; } public bool ReuseExistingResources { get; set; } @@ -33,7 +31,6 @@ public class SvgToXamlConverter { NewLine = NewLine, UseCompatMode = UseCompatMode, - UseBrushTransform = UseBrushTransform, AddTransparentBackground = AddTransparentBackground, ReuseExistingResources = ReuseExistingResources, WriteResources = false, @@ -53,7 +50,6 @@ public class SvgToXamlConverter { NewLine = NewLine, UseCompatMode = UseCompatMode, - UseBrushTransform = UseBrushTransform, AddTransparentBackground = AddTransparentBackground, ReuseExistingResources = ReuseExistingResources, WriteResources = true, @@ -105,7 +101,6 @@ public class SvgToXamlConverter { NewLine = NewLine, UseCompatMode = UseCompatMode, - UseBrushTransform = UseBrushTransform, AddTransparentBackground = AddTransparentBackground, ReuseExistingResources = ReuseExistingResources, WriteResources = false, diff --git a/src/svgxaml/Program.cs b/src/svgxaml/Program.cs index 48ea22a..f132522 100644 --- a/src/svgxaml/Program.cs +++ b/src/svgxaml/Program.cs @@ -58,7 +58,6 @@ class Program var converter = new SvgToXamlConverter.SvgToXamlConverter() { UseCompatMode = false, - UseBrushTransform = false, ReuseExistingResources = false, Resources = null }; @@ -82,7 +81,6 @@ class Program var converter = new SvgToXamlConverter.SvgToXamlConverter() { UseCompatMode = false, - UseBrushTransform = false, ReuseExistingResources = false, Resources = null }; @@ -111,4 +109,4 @@ class Program Console.WriteLine($"{ex.StackTrace}"); } } -} \ No newline at end of file +}