Remember blur radius and pixel size

This commit is contained in:
Jaex 2016-05-06 20:24:39 +03:00
parent 520e2b85cb
commit da9077b6c1
4 changed files with 26 additions and 19 deletions

View file

@ -425,7 +425,7 @@ private void surface_KeyDown(object sender, KeyEventArgs e)
{ {
case ShapeType.RegionRoundedRectangle: case ShapeType.RegionRoundedRectangle:
case ShapeType.DrawingRoundedRectangle: case ShapeType.DrawingRoundedRectangle:
config.RoundedRectangleRadius += RoundedRectangleRadiusIncrement; config.ShapeRoundedRectangleRadius += RoundedRectangleRadiusIncrement;
UpdateShape(); UpdateShape();
break; break;
} }
@ -435,7 +435,7 @@ private void surface_KeyDown(object sender, KeyEventArgs e)
{ {
case ShapeType.RegionRoundedRectangle: case ShapeType.RegionRoundedRectangle:
case ShapeType.DrawingRoundedRectangle: case ShapeType.DrawingRoundedRectangle:
config.RoundedRectangleRadius = Math.Max(0, config.RoundedRectangleRadius - RoundedRectangleRadiusIncrement); config.ShapeRoundedRectangleRadius = Math.Max(0, config.ShapeRoundedRectangleRadius - RoundedRectangleRadiusIncrement);
UpdateShape(); UpdateShape();
break; break;
} }
@ -728,7 +728,17 @@ private void UpdateShape(BaseShape shape)
if (shape is IRoundedRectangleShape) if (shape is IRoundedRectangleShape)
{ {
IRoundedRectangleShape roundedRectangleShape = (IRoundedRectangleShape)shape; IRoundedRectangleShape roundedRectangleShape = (IRoundedRectangleShape)shape;
roundedRectangleShape.Radius = config.RoundedRectangleRadius; roundedRectangleShape.Radius = config.ShapeRoundedRectangleRadius;
}
else if (shape is BlurDrawingShape)
{
BlurDrawingShape blurDrawingShape = (BlurDrawingShape)shape;
blurDrawingShape.BlurRadius = config.ShapeBlurRadius;
}
else if (shape is PixelateDrawingShape)
{
PixelateDrawingShape pixelateDrawingShape = (PixelateDrawingShape)shape;
pixelateDrawingShape.PixelSize = config.ShapePixelSize;
} }
} }
} }

View file

@ -38,6 +38,8 @@ public class BlurDrawingShape : BaseDrawingShape
{ {
public override ShapeType ShapeType { get; } = ShapeType.DrawingBlur; public override ShapeType ShapeType { get; } = ShapeType.DrawingBlur;
public int BlurRadius { get; set; }
public override void Draw(Graphics g) public override void Draw(Graphics g)
{ {
using (Brush brush = new SolidBrush(Color.FromArgb(200, Color.Black))) using (Brush brush = new SolidBrush(Color.FromArgb(200, Color.Black)))
@ -59,7 +61,7 @@ public override void DrawOutput(Graphics g, Bitmap bmp)
{ {
using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, Rectangle)) using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, Rectangle))
{ {
ImageHelpers.Blur(croppedImage, 20); ImageHelpers.Blur(croppedImage, BlurRadius);
g.DrawImage(croppedImage, Rectangle); g.DrawImage(croppedImage, Rectangle);
} }

View file

@ -38,6 +38,8 @@ public class PixelateDrawingShape : BaseDrawingShape
{ {
public override ShapeType ShapeType { get; } = ShapeType.DrawingBlur; public override ShapeType ShapeType { get; } = ShapeType.DrawingBlur;
public int PixelSize { get; set; }
public override void Draw(Graphics g) public override void Draw(Graphics g)
{ {
using (Brush brush = new SolidBrush(Color.FromArgb(200, Color.Black))) using (Brush brush = new SolidBrush(Color.FromArgb(200, Color.Black)))
@ -58,7 +60,7 @@ public override void Draw(Graphics g)
public override void DrawOutput(Graphics g, Bitmap bmp) public override void DrawOutput(Graphics g, Bitmap bmp)
{ {
using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, Rectangle)) using (Bitmap croppedImage = ImageHelpers.CropBitmap(bmp, Rectangle))
using (Bitmap pixelatedImage = ImageHelpers.Pixelate(croppedImage, 7)) using (Bitmap pixelatedImage = ImageHelpers.Pixelate(croppedImage, PixelSize))
{ {
g.DrawImage(pixelatedImage, Rectangle); g.DrawImage(pixelatedImage, Rectangle);
} }

View file

@ -98,20 +98,13 @@ public class SurfaceOptions
[Description("How close to a snap size you must be for it to snap.")] [Description("How close to a snap size you must be for it to snap.")]
public List<SnapSize> SnapSizes { get; set; } public List<SnapSize> SnapSizes { get; set; }
[DefaultValue(ShapeType.RegionRectangle)] public ShapeType CurrentShapeType = ShapeType.RegionRectangle;
public ShapeType CurrentShapeType { get; set; } = ShapeType.RegionRectangle; public Color ShapeBorderColor = Color.Red;
public int ShapeBorderSize = 2;
[DefaultValue(typeof(Color), "Red")] public Color ShapeFillColor = Color.FromArgb(0, 0, 0, 0);
public Color ShapeBorderColor { get; set; } = Color.Red; public float ShapeRoundedRectangleRadius = 15;
public int ShapeBlurRadius = 15;
[DefaultValue(2)] public int ShapePixelSize = 7;
public int ShapeBorderSize { get; set; } = 2;
[DefaultValue(typeof(Color), "0, 0, 0, 0")]
public Color ShapeFillColor { get; set; } = Color.FromArgb(0, 0, 0, 0);
[DefaultValue(15)]
public float RoundedRectangleRadius { get; set; } = 15;
public SurfaceOptions() public SurfaceOptions()
{ {