From d9d828ab21d4d1c7cbc55d9db9ee63689b67760b Mon Sep 17 00:00:00 2001 From: Darth Affe Date: Sat, 14 Jan 2017 17:45:41 +0100 Subject: [PATCH] Fixed brush-save and adjusted render-resolution --- .../AngularBrushPropertiesViewModel.cs | 20 +--------------- .../Types/AngularBrush/AngularBrushType.cs | 24 +++++++++++++++++-- .../AngularBrush/Drawing/GradientDrawer.cs | 2 +- 3 files changed, 24 insertions(+), 22 deletions(-) diff --git a/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/AngularBrushPropertiesViewModel.cs b/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/AngularBrushPropertiesViewModel.cs index 0b4b792d7..e964b72fc 100644 --- a/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/AngularBrushPropertiesViewModel.cs +++ b/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/AngularBrushPropertiesViewModel.cs @@ -63,28 +63,10 @@ namespace Artemis.Profiles.Layers.Types.AngularBrush WidthProperties.Apply(LayerModel); OpacityProperties.Apply(LayerModel); - ((AngularBrushPropertiesModel)LayerModel.Properties).GradientStops = GetGradientStops().Select(x => new Tuple(x.Offset, x.Color)).ToList(); - + LayerModel.Properties.Brush = Brush; LayerModel.LayerAnimation = SelectedLayerAnimation; } - private GradientStopCollection GetGradientStops() - { - LinearGradientBrush linearBrush = Brush as LinearGradientBrush; - if (linearBrush != null) - return linearBrush.GradientStops; - - RadialGradientBrush radialBrush = Brush as RadialGradientBrush; - if (radialBrush != null) - return radialBrush.GradientStops; - - SolidColorBrush solidBrush = Brush as SolidColorBrush; - if (solidBrush != null) - return new GradientStopCollection(new[] { new GradientStop(solidBrush.Color, 0), new GradientStop(solidBrush.Color, 1) }); - - return null; - } - #endregion } } diff --git a/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/AngularBrushType.cs b/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/AngularBrushType.cs index 6fc65b2ca..0bdf2775e 100644 --- a/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/AngularBrushType.cs +++ b/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/AngularBrushType.cs @@ -1,4 +1,6 @@ -using System.Windows; +using System; +using System.Linq; +using System.Windows; using System.Windows.Media; using Artemis.Modules.Abstract; using Artemis.Profiles.Layers.Abstract; @@ -51,7 +53,8 @@ namespace Artemis.Profiles.Layers.Types.AngularBrush Brush origBrush = layerModel.Brush; - _gradientDrawer.GradientStops = properties.GradientStops; + //TODO DarthAffe 14.01.2017: Check if an update is needed + _gradientDrawer.GradientStops = GetGradientStops(layerModel.Brush).Select(x => new Tuple(x.Offset, x.Color)).ToList(); _gradientDrawer.Update(); layerModel.Brush = _gradientDrawer.Brush.Clone(); @@ -105,6 +108,23 @@ namespace Artemis.Profiles.Layers.Types.AngularBrush return (layerPropertiesViewModel as AngularBrushPropertiesViewModel) ?? new AngularBrushPropertiesViewModel(layerEditorViewModel); } + private GradientStopCollection GetGradientStops(Brush brush) + { + LinearGradientBrush linearBrush = brush as LinearGradientBrush; + if (linearBrush != null) + return linearBrush.GradientStops; + + RadialGradientBrush radialBrush = brush as RadialGradientBrush; + if (radialBrush != null) + return radialBrush.GradientStops; + + SolidColorBrush solidBrush = brush as SolidColorBrush; + if (solidBrush != null) + return new GradientStopCollection(new[] { new GradientStop(solidBrush.Color, 0), new GradientStop(solidBrush.Color, 1) }); + + return null; + } + #endregion } } diff --git a/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/Drawing/GradientDrawer.cs b/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/Drawing/GradientDrawer.cs index 42dd4df72..fd3d7e8c2 100644 --- a/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/Drawing/GradientDrawer.cs +++ b/Artemis/Artemis/Profiles/Layers/Types/AngularBrush/Drawing/GradientDrawer.cs @@ -65,7 +65,7 @@ namespace Artemis.Profiles.Layers.Types.AngularBrush.Drawing private void CreateBrush() { - _bitmap = new WriteableBitmap(10, 10, 96, 96, PixelFormats.Bgra32, null); + _bitmap = new WriteableBitmap(100, 100, 96, 96, PixelFormats.Bgra32, null); Brush = new ImageBrush(_bitmap) { Stretch = Stretch.UniformToFill }; }