mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-02 13:10:22 +12:00
Created AnnotationOptions class
This commit is contained in:
parent
55c3087892
commit
9e35ee9591
45
ShareX.ScreenCaptureLib/AnnotationOptions.cs
Normal file
45
ShareX.ScreenCaptureLib/AnnotationOptions.cs
Normal file
|
@ -0,0 +1,45 @@
|
|||
#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.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace ShareX.ScreenCaptureLib
|
||||
{
|
||||
public class AnnotationOptions
|
||||
{
|
||||
public Color BorderColor { get; set; } = Color.Red;
|
||||
public int BorderSize { get; set; } = 2;
|
||||
public Color FillColor { get; set; } = Color.FromArgb(0, 0, 0, 0);
|
||||
public int RoundedRectangleRadius { get; set; } = 15;
|
||||
public TextDrawingOptions TextOptions { get; set; } = new TextDrawingOptions();
|
||||
public int BlurRadius { get; set; } = 15;
|
||||
public int PixelateSize { get; set; } = 7;
|
||||
public Color HighlightColor { get; set; } = Color.Yellow;
|
||||
}
|
||||
}
|
|
@ -63,7 +63,6 @@ public ShapeType CurrentShapeType
|
|||
private set
|
||||
{
|
||||
currentShapeType = value;
|
||||
Config.CurrentShapeType = currentShapeType;
|
||||
DeselectShape();
|
||||
OnCurrentShapeTypeChanged(currentShapeType);
|
||||
}
|
||||
|
@ -165,6 +164,14 @@ public bool IsResizing
|
|||
|
||||
public SurfaceOptions Config { get; private set; }
|
||||
|
||||
public AnnotationOptions AnnotationOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
return Config.AnnotationOptions;
|
||||
}
|
||||
}
|
||||
|
||||
public event Action<BaseShape> CurrentShapeChanged;
|
||||
public event Action<ShapeType> CurrentShapeTypeChanged;
|
||||
|
||||
|
@ -191,7 +198,7 @@ public ShapeManager(RectangleRegionForm form)
|
|||
}
|
||||
|
||||
CurrentShape = null;
|
||||
CurrentShapeType = ShapeType.RegionRectangle; //config.CurrentShapeType;
|
||||
CurrentShapeType = ShapeType.RegionRectangle;
|
||||
}
|
||||
|
||||
private void CreateContextMenu()
|
||||
|
@ -289,30 +296,30 @@ private void CreateContextMenu()
|
|||
{
|
||||
PauseForm();
|
||||
|
||||
using (ColorPickerForm dialogColor = new ColorPickerForm(Config.ShapeBorderColor))
|
||||
using (ColorPickerForm dialogColor = new ColorPickerForm(AnnotationOptions.BorderColor))
|
||||
{
|
||||
if (dialogColor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Config.ShapeBorderColor = dialogColor.NewColor;
|
||||
AnnotationOptions.BorderColor = dialogColor.NewColor;
|
||||
if (tsmiBorderColor.Image != null) tsmiBorderColor.Image.Dispose();
|
||||
tsmiBorderColor.Image = ImageHelpers.CreateColorPickerIcon(Config.ShapeBorderColor, new Rectangle(0, 0, 16, 16));
|
||||
tsmiBorderColor.Image = ImageHelpers.CreateColorPickerIcon(AnnotationOptions.BorderColor, new Rectangle(0, 0, 16, 16));
|
||||
UpdateCurrentShape();
|
||||
}
|
||||
}
|
||||
|
||||
ResumeForm();
|
||||
};
|
||||
tsmiBorderColor.Image = ImageHelpers.CreateColorPickerIcon(Config.ShapeBorderColor, new Rectangle(0, 0, 16, 16));
|
||||
tsmiBorderColor.Image = ImageHelpers.CreateColorPickerIcon(AnnotationOptions.BorderColor, new Rectangle(0, 0, 16, 16));
|
||||
cmsContextMenu.Items.Add(tsmiBorderColor);
|
||||
|
||||
ToolStripLabeledNumericUpDown tslnudBorderSize = new ToolStripLabeledNumericUpDown();
|
||||
tslnudBorderSize.LabeledNumericUpDownControl.Text = "Border size:";
|
||||
tslnudBorderSize.LabeledNumericUpDownControl.Minimum = 0;
|
||||
tslnudBorderSize.LabeledNumericUpDownControl.Maximum = 20;
|
||||
tslnudBorderSize.LabeledNumericUpDownControl.Value = Config.ShapeBorderSize;
|
||||
tslnudBorderSize.LabeledNumericUpDownControl.Value = AnnotationOptions.BorderSize;
|
||||
tslnudBorderSize.LabeledNumericUpDownControl.ValueChanged = (sender, e) =>
|
||||
{
|
||||
Config.ShapeBorderSize = (int)tslnudBorderSize.LabeledNumericUpDownControl.Value;
|
||||
AnnotationOptions.BorderSize = (int)tslnudBorderSize.LabeledNumericUpDownControl.Value;
|
||||
UpdateCurrentShape();
|
||||
};
|
||||
cmsContextMenu.Items.Add(tslnudBorderSize);
|
||||
|
@ -322,20 +329,20 @@ private void CreateContextMenu()
|
|||
{
|
||||
PauseForm();
|
||||
|
||||
using (ColorPickerForm dialogColor = new ColorPickerForm(Config.ShapeFillColor))
|
||||
using (ColorPickerForm dialogColor = new ColorPickerForm(AnnotationOptions.FillColor))
|
||||
{
|
||||
if (dialogColor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Config.ShapeFillColor = dialogColor.NewColor;
|
||||
AnnotationOptions.FillColor = dialogColor.NewColor;
|
||||
if (tsmiFillColor.Image != null) tsmiFillColor.Image.Dispose();
|
||||
tsmiFillColor.Image = ImageHelpers.CreateColorPickerIcon(Config.ShapeFillColor, new Rectangle(0, 0, 16, 16));
|
||||
tsmiFillColor.Image = ImageHelpers.CreateColorPickerIcon(AnnotationOptions.FillColor, new Rectangle(0, 0, 16, 16));
|
||||
UpdateCurrentShape();
|
||||
}
|
||||
}
|
||||
|
||||
ResumeForm();
|
||||
};
|
||||
tsmiFillColor.Image = ImageHelpers.CreateColorPickerIcon(Config.ShapeFillColor, new Rectangle(0, 0, 16, 16));
|
||||
tsmiFillColor.Image = ImageHelpers.CreateColorPickerIcon(AnnotationOptions.FillColor, new Rectangle(0, 0, 16, 16));
|
||||
cmsContextMenu.Items.Add(tsmiFillColor);
|
||||
|
||||
ToolStripLabeledNumericUpDown tslnudRoundedRectangleRadius = new ToolStripLabeledNumericUpDown();
|
||||
|
@ -343,10 +350,10 @@ private void CreateContextMenu()
|
|||
tslnudRoundedRectangleRadius.LabeledNumericUpDownControl.Minimum = 0;
|
||||
tslnudRoundedRectangleRadius.LabeledNumericUpDownControl.Maximum = 150;
|
||||
tslnudRoundedRectangleRadius.LabeledNumericUpDownControl.Increment = 3;
|
||||
tslnudRoundedRectangleRadius.LabeledNumericUpDownControl.Value = Config.ShapeRoundedRectangleRadius;
|
||||
tslnudRoundedRectangleRadius.LabeledNumericUpDownControl.Value = AnnotationOptions.RoundedRectangleRadius;
|
||||
tslnudRoundedRectangleRadius.LabeledNumericUpDownControl.ValueChanged = (sender, e) =>
|
||||
{
|
||||
Config.ShapeRoundedRectangleRadius = (int)tslnudRoundedRectangleRadius.LabeledNumericUpDownControl.Value;
|
||||
AnnotationOptions.RoundedRectangleRadius = (int)tslnudRoundedRectangleRadius.LabeledNumericUpDownControl.Value;
|
||||
UpdateCurrentShape();
|
||||
};
|
||||
cmsContextMenu.Items.Add(tslnudRoundedRectangleRadius);
|
||||
|
@ -355,10 +362,10 @@ private void CreateContextMenu()
|
|||
tslnudBlurRadius.LabeledNumericUpDownControl.Text = "Blur radius:";
|
||||
tslnudBlurRadius.LabeledNumericUpDownControl.Minimum = 2;
|
||||
tslnudBlurRadius.LabeledNumericUpDownControl.Maximum = 100;
|
||||
tslnudBlurRadius.LabeledNumericUpDownControl.Value = Config.ShapeBlurRadius;
|
||||
tslnudBlurRadius.LabeledNumericUpDownControl.Value = AnnotationOptions.BlurRadius;
|
||||
tslnudBlurRadius.LabeledNumericUpDownControl.ValueChanged = (sender, e) =>
|
||||
{
|
||||
Config.ShapeBlurRadius = (int)tslnudBlurRadius.LabeledNumericUpDownControl.Value;
|
||||
AnnotationOptions.BlurRadius = (int)tslnudBlurRadius.LabeledNumericUpDownControl.Value;
|
||||
UpdateCurrentShape();
|
||||
};
|
||||
cmsContextMenu.Items.Add(tslnudBlurRadius);
|
||||
|
@ -367,10 +374,10 @@ private void CreateContextMenu()
|
|||
tslnudPixelateSize.LabeledNumericUpDownControl.Text = "Pixel size:";
|
||||
tslnudPixelateSize.LabeledNumericUpDownControl.Minimum = 2;
|
||||
tslnudPixelateSize.LabeledNumericUpDownControl.Maximum = 100;
|
||||
tslnudPixelateSize.LabeledNumericUpDownControl.Value = Config.ShapeRoundedRectangleRadius;
|
||||
tslnudPixelateSize.LabeledNumericUpDownControl.Value = AnnotationOptions.RoundedRectangleRadius;
|
||||
tslnudPixelateSize.LabeledNumericUpDownControl.ValueChanged = (sender, e) =>
|
||||
{
|
||||
Config.ShapePixelateSize = (int)tslnudPixelateSize.LabeledNumericUpDownControl.Value;
|
||||
AnnotationOptions.PixelateSize = (int)tslnudPixelateSize.LabeledNumericUpDownControl.Value;
|
||||
UpdateCurrentShape();
|
||||
};
|
||||
cmsContextMenu.Items.Add(tslnudPixelateSize);
|
||||
|
@ -380,20 +387,20 @@ private void CreateContextMenu()
|
|||
{
|
||||
PauseForm();
|
||||
|
||||
using (ColorPickerForm dialogColor = new ColorPickerForm(Config.ShapeHighlightColor))
|
||||
using (ColorPickerForm dialogColor = new ColorPickerForm(AnnotationOptions.HighlightColor))
|
||||
{
|
||||
if (dialogColor.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
Config.ShapeHighlightColor = dialogColor.NewColor;
|
||||
AnnotationOptions.HighlightColor = dialogColor.NewColor;
|
||||
if (tsmiHighlightColor.Image != null) tsmiHighlightColor.Image.Dispose();
|
||||
tsmiHighlightColor.Image = ImageHelpers.CreateColorPickerIcon(Config.ShapeHighlightColor, new Rectangle(0, 0, 16, 16));
|
||||
tsmiHighlightColor.Image = ImageHelpers.CreateColorPickerIcon(AnnotationOptions.HighlightColor, new Rectangle(0, 0, 16, 16));
|
||||
UpdateCurrentShape();
|
||||
}
|
||||
}
|
||||
|
||||
ResumeForm();
|
||||
};
|
||||
tsmiHighlightColor.Image = ImageHelpers.CreateColorPickerIcon(Config.ShapeHighlightColor, new Rectangle(0, 0, 16, 16));
|
||||
tsmiHighlightColor.Image = ImageHelpers.CreateColorPickerIcon(AnnotationOptions.HighlightColor, new Rectangle(0, 0, 16, 16));
|
||||
cmsContextMenu.Items.Add(tsmiHighlightColor);
|
||||
|
||||
cmsContextMenu.Items.Add(new ToolStripSeparator());
|
||||
|
|
|
@ -39,11 +39,11 @@ public abstract class BaseShape
|
|||
|
||||
public ShapeManager Manager { get; set; }
|
||||
|
||||
protected SurfaceOptions Config
|
||||
protected AnnotationOptions AnnotationOptions
|
||||
{
|
||||
get
|
||||
{
|
||||
return Manager.Config;
|
||||
return Manager.Config.AnnotationOptions;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -41,9 +41,9 @@ public abstract class BaseDrawingShape : BaseShape
|
|||
|
||||
public override void UpdateShapeConfig()
|
||||
{
|
||||
BorderColor = Config.ShapeBorderColor;
|
||||
BorderSize = Config.ShapeBorderSize;
|
||||
FillColor = Config.ShapeFillColor;
|
||||
BorderColor = AnnotationOptions.BorderColor;
|
||||
BorderSize = AnnotationOptions.BorderSize;
|
||||
FillColor = AnnotationOptions.FillColor;
|
||||
}
|
||||
|
||||
public virtual void Draw(Graphics g)
|
||||
|
|
|
@ -41,7 +41,7 @@ public class RoundedRectangleDrawingShape : BaseDrawingShape
|
|||
|
||||
public override void UpdateShapeConfig()
|
||||
{
|
||||
Radius = Config.ShapeRoundedRectangleRadius;
|
||||
Radius = AnnotationOptions.RoundedRectangleRadius;
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
|
|
|
@ -44,7 +44,7 @@ public class TextDrawingShape : BaseDrawingShape
|
|||
|
||||
public override void UpdateShapeConfig()
|
||||
{
|
||||
Options = Config.ShapeTextOptions.Copy();
|
||||
Options = AnnotationOptions.TextOptions.Copy();
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
|
@ -82,7 +82,7 @@ private void UpdateText()
|
|||
{
|
||||
inputBox.ShowDialog();
|
||||
Text = inputBox.InputText;
|
||||
Config.ShapeTextOptions = Options;
|
||||
AnnotationOptions.TextOptions = Options;
|
||||
}
|
||||
|
||||
Manager.ResumeForm();
|
||||
|
|
|
@ -42,7 +42,7 @@ public class BlurEffectShape : BaseEffectShape
|
|||
|
||||
public override void UpdateShapeConfig()
|
||||
{
|
||||
BlurRadius = Config.ShapeBlurRadius;
|
||||
BlurRadius = AnnotationOptions.BlurRadius;
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
|
|
|
@ -42,7 +42,7 @@ public class HighlightEffectShape : BaseEffectShape
|
|||
|
||||
public override void UpdateShapeConfig()
|
||||
{
|
||||
HighlightColor = Config.ShapeHighlightColor;
|
||||
HighlightColor = AnnotationOptions.HighlightColor;
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
|
|
|
@ -42,7 +42,7 @@ public class PixelateEffectShape : BaseEffectShape
|
|||
|
||||
public override void UpdateShapeConfig()
|
||||
{
|
||||
PixelSize = Config.ShapePixelateSize;
|
||||
PixelSize = AnnotationOptions.PixelateSize;
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
|
|
|
@ -41,7 +41,7 @@ public class RoundedRectangleRegionShape : BaseRegionShape
|
|||
|
||||
public override void UpdateShapeConfig()
|
||||
{
|
||||
Radius = Config.ShapeRoundedRectangleRadius;
|
||||
Radius = AnnotationOptions.RoundedRectangleRadius;
|
||||
}
|
||||
|
||||
public override void AddShapePath(GraphicsPath gp, Rectangle rect)
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="AnnotationOptions.cs" />
|
||||
<Compile Include="Enums.cs" />
|
||||
<Compile Include="Forms\RectangleRegionAnnotateForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
|
|
@ -100,15 +100,7 @@ public class SurfaceOptions
|
|||
|
||||
public bool ShowMenuTip = true;
|
||||
|
||||
public ShapeType CurrentShapeType = ShapeType.RegionRectangle;
|
||||
public Color ShapeBorderColor = Color.Red;
|
||||
public int ShapeBorderSize = 2;
|
||||
public Color ShapeFillColor = Color.FromArgb(0, 0, 0, 0);
|
||||
public int ShapeRoundedRectangleRadius = 15;
|
||||
public TextDrawingOptions ShapeTextOptions = new TextDrawingOptions();
|
||||
public int ShapeBlurRadius = 15;
|
||||
public int ShapePixelateSize = 7;
|
||||
public Color ShapeHighlightColor = Color.Yellow;
|
||||
public AnnotationOptions AnnotationOptions = new AnnotationOptions();
|
||||
|
||||
public SurfaceOptions()
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue