Update current shape after shape options changed

This commit is contained in:
Jaex 2016-05-06 14:48:50 +03:00
parent 2b317a2167
commit d763c0475f
7 changed files with 76 additions and 16 deletions

View file

@ -188,7 +188,9 @@ private void CreateContextMenu()
if (dialogColor.ShowDialog() == DialogResult.OK)
{
config.ShapeBorderColor = dialogColor.NewColor;
if (tsmiChangeBorderColor.Image != null) tsmiChangeBorderColor.Image.Dispose();
tsmiChangeBorderColor.Image = ImageHelpers.CreateColorPickerIcon(config.ShapeBorderColor, new Rectangle(0, 0, 16, 16));
UpdateShape();
}
}
@ -202,7 +204,11 @@ private void CreateContextMenu()
tslnudBorderSize.LabeledNumericUpDownControl.Minimum = 1;
tslnudBorderSize.LabeledNumericUpDownControl.Maximum = 20;
tslnudBorderSize.LabeledNumericUpDownControl.Value = config.ShapeBorderSize;
tslnudBorderSize.LabeledNumericUpDownControl.ValueChanged = (sender, e) => config.ShapeBorderSize = (int)tslnudBorderSize.LabeledNumericUpDownControl.Value;
tslnudBorderSize.LabeledNumericUpDownControl.ValueChanged = (sender, e) =>
{
config.ShapeBorderSize = (int)tslnudBorderSize.LabeledNumericUpDownControl.Value;
UpdateShape();
};
cmsContextMenu.Items.Add(tslnudBorderSize);
ToolStripMenuItem tsmiChangeFillColor = new ToolStripMenuItem("Fill color...");
@ -215,7 +221,9 @@ private void CreateContextMenu()
if (dialogColor.ShowDialog() == DialogResult.OK)
{
config.ShapeFillColor = dialogColor.NewColor;
if (tsmiChangeFillColor.Image != null) tsmiChangeFillColor.Image.Dispose();
tsmiChangeFillColor.Image = ImageHelpers.CreateColorPickerIcon(config.ShapeFillColor, new Rectangle(0, 0, 16, 16));
UpdateShape();
}
}
@ -687,17 +695,36 @@ public BaseShape CreateRegionShape(Rectangle rect)
shape.Rectangle = rect;
if (shape is BaseDrawingShape)
{
BaseDrawingShape baseDrawingShape = (BaseDrawingShape)shape;
baseDrawingShape.BorderColor = config.ShapeBorderColor;
baseDrawingShape.BorderSize = config.ShapeBorderSize;
baseDrawingShape.FillColor = config.ShapeFillColor;
}
UpdateShape(shape);
return shape;
}
private void UpdateShape()
{
UpdateShape(CurrentShape);
}
private void UpdateShape(BaseShape shape)
{
if (shape != null)
{
if (shape is BaseDrawingShape)
{
BaseDrawingShape baseDrawingShape = (BaseDrawingShape)shape;
baseDrawingShape.BorderColor = config.ShapeBorderColor;
baseDrawingShape.BorderSize = config.ShapeBorderSize;
baseDrawingShape.FillColor = config.ShapeFillColor;
}
if (shape is IRoundedRectangleShape)
{
IRoundedRectangleShape roundedRectangleShape = (IRoundedRectangleShape)shape;
roundedRectangleShape.Radius = RoundedRectangleRadius;
}
}
}
private void SelectArea()
{
if (!CurrentRectangle.IsEmpty && !config.IsFixedSize)

View file

@ -60,11 +60,6 @@ public override void Draw(Graphics g)
{
Rectangle rect = new Rectangle((int)Rectangle.X, (int)Rectangle.Y, (int)Rectangle.Width - 1, (int)Rectangle.Height - 1);
if (IsMouseHover)
{
rect.Inflate(1, 1);
}
switch (Shape)
{
case NodeShape.Square:

View file

@ -33,7 +33,7 @@ You should have received a copy of the GNU General Public License
namespace ShareX.ScreenCaptureLib
{
public class RoundedRectangleDrawingShape : BaseDrawingShape
public class RoundedRectangleDrawingShape : BaseDrawingShape, IRoundedRectangleShape
{
public override ShapeType ShapeType { get; } = ShapeType.DrawingRoundedRectangle;

View file

@ -0,0 +1,37 @@
#region License Information (GPL v3)
/*
ShareX - A program that allows you to take screenshots and share any file type
Copyright (c) 2007-2016 ShareX Team
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
*/
#endregion License Information (GPL v3)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ShareX.ScreenCaptureLib
{
public interface IRoundedRectangleShape
{
float Radius { get; set; }
}
}

View file

@ -33,7 +33,7 @@ You should have received a copy of the GNU General Public License
namespace ShareX.ScreenCaptureLib
{
public class RoundedRectangleRegionShape : BaseRegionShape
public class RoundedRectangleRegionShape : BaseRegionShape, IRoundedRectangleShape
{
public override ShapeType ShapeType { get; } = ShapeType.RegionRoundedRectangle;

View file

@ -87,6 +87,7 @@
<Compile Include="Shapes\Drawing\LineDrawingShape.cs" />
<Compile Include="Shapes\Drawing\RectangleDrawingShape.cs" />
<Compile Include="Shapes\Drawing\RoundedRectangleDrawingShape.cs" />
<Compile Include="Shapes\IRoundedRectangleShape.cs" />
<Compile Include="Shapes\Region\EllipseRegionShape.cs" />
<Compile Include="Shapes\Region\RectangleRegionShape.cs" />
<Compile Include="Shapes\Region\BaseRegionShape.cs" />

View file

@ -53,7 +53,7 @@ public static ShareXBuild Build
}
}
public static bool IsBeta { get; } = false;
public static bool IsBeta { get; } = true;
public static string Title
{