mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added font size option to step tool
This commit is contained in:
parent
c0fda0ab3e
commit
d37fc01726
3 changed files with 41 additions and 33 deletions
|
@ -74,6 +74,7 @@ public class AnnotationOptions
|
|||
public Color StepBorderColor { get; set; } = SecondaryColor;
|
||||
public int StepBorderSize { get; set; } = 0;
|
||||
public Color StepFillColor { get; set; } = PrimaryColor;
|
||||
public int StepFontSize { get; set; } = 22;
|
||||
|
||||
// Blur effect
|
||||
public int BlurRadius { get; set; } = 15;
|
||||
|
|
|
@ -36,6 +36,7 @@ public class StepDrawingShape : EllipseDrawingShape
|
|||
|
||||
public override ShapeType ShapeType { get; } = ShapeType.DrawingStep;
|
||||
|
||||
public int FontSize { get; set; }
|
||||
public int Number { get; set; }
|
||||
|
||||
public StepDrawingShape()
|
||||
|
@ -60,6 +61,7 @@ public override void OnConfigLoad()
|
|||
BorderSize = AnnotationOptions.StepBorderSize;
|
||||
FillColor = AnnotationOptions.StepFillColor;
|
||||
Shadow = AnnotationOptions.Shadow;
|
||||
FontSize = AnnotationOptions.StepFontSize;
|
||||
}
|
||||
|
||||
public override void OnConfigSave()
|
||||
|
@ -68,53 +70,45 @@ public override void OnConfigSave()
|
|||
AnnotationOptions.StepBorderSize = BorderSize;
|
||||
AnnotationOptions.StepFillColor = FillColor;
|
||||
AnnotationOptions.Shadow = Shadow;
|
||||
AnnotationOptions.StepFontSize = FontSize;
|
||||
}
|
||||
|
||||
public override void OnDraw(Graphics g)
|
||||
{
|
||||
DrawEllipse(g);
|
||||
DrawNumber(g);
|
||||
}
|
||||
|
||||
protected void DrawNumber(Graphics g)
|
||||
{
|
||||
if (Shadow)
|
||||
using (Font font = new Font(FontFamily.GenericSansSerif, FontSize, FontStyle.Bold, GraphicsUnit.Pixel))
|
||||
{
|
||||
DrawNumber(g, Number, ShadowColor, Rectangle.LocationOffset(ShadowOffset));
|
||||
}
|
||||
Size textSize = g.MeasureString(Number.ToString(), font).ToSize();
|
||||
int maxSize = Math.Max(textSize.Width, textSize.Height);
|
||||
int padding = 3;
|
||||
|
||||
DrawNumber(g, Number, BorderColor, Rectangle);
|
||||
Point center = Rectangle.Center();
|
||||
Rectangle = new Rectangle(center.X - maxSize / 2 - padding, center.Y - maxSize / 2 - padding, maxSize + padding * 2, maxSize + padding * 2);
|
||||
|
||||
DrawEllipse(g);
|
||||
|
||||
if (Shadow)
|
||||
{
|
||||
DrawNumber(g, Number, font, ShadowColor, Rectangle.LocationOffset(ShadowOffset));
|
||||
}
|
||||
|
||||
DrawNumber(g, Number, font, BorderColor, Rectangle);
|
||||
}
|
||||
}
|
||||
|
||||
protected void DrawNumber(Graphics g, int number, Color textColor, Rectangle rect)
|
||||
protected void DrawNumber(Graphics g, int number, Font font, Color textColor, Rectangle rect)
|
||||
{
|
||||
if (rect.Width > 20 && rect.Height > 20)
|
||||
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
|
||||
using (Brush textBrush = new SolidBrush(textColor))
|
||||
{
|
||||
int offset;
|
||||
|
||||
if (number > 99)
|
||||
{
|
||||
offset = 20;
|
||||
}
|
||||
else if (number > 9)
|
||||
{
|
||||
offset = 15;
|
||||
}
|
||||
else
|
||||
{
|
||||
offset = 10;
|
||||
}
|
||||
|
||||
int fontSize = Math.Min(rect.Width, rect.Height) - offset;
|
||||
|
||||
using (Font font = new Font(FontFamily.GenericSansSerif, fontSize, FontStyle.Bold, GraphicsUnit.Pixel))
|
||||
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
|
||||
using (Brush textBrush = new SolidBrush(textColor))
|
||||
{
|
||||
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
|
||||
g.DrawString(number.ToString(), font, textBrush, rect, sf);
|
||||
g.TextRenderingHint = TextRenderingHint.SystemDefault;
|
||||
}
|
||||
g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
|
||||
rect = rect.LocationOffset(0, 1);
|
||||
g.DrawString(number.ToString(), font, textBrush, rect, sf);
|
||||
g.TextRenderingHint = TextRenderingHint.SystemDefault;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ internal partial class ShapeManager
|
|||
private ToolStripDropDownButton tsddbShapeOptions;
|
||||
private ToolStripMenuItem tsmiArrowHeadsBothSide, tsmiShadow, tsmiUndo, tsmiDelete, tsmiDeleteAll, tsmiMoveTop, tsmiMoveUp, tsmiMoveDown, tsmiMoveBottom,
|
||||
tsmiRegionCapture, tsmiQuickCrop, tsmiTips, tsmiImageEditorBackgroundColor;
|
||||
private ToolStripLabeledNumericUpDown tslnudBorderSize, tslnudCornerRadius, tslnudCenterPoints, tslnudBlurRadius, tslnudPixelateSize;
|
||||
private ToolStripLabeledNumericUpDown tslnudBorderSize, tslnudCornerRadius, tslnudCenterPoints, tslnudBlurRadius, tslnudPixelateSize, tslnudStepFontSize;
|
||||
private ToolStripLabel tslDragLeft, tslDragRight;
|
||||
private ToolStripLabeledComboBox tscbCursorTypes;
|
||||
|
||||
|
@ -529,6 +529,16 @@ internal void CreateToolbar()
|
|||
};
|
||||
tsddbShapeOptions.DropDownItems.Add(tsmiArrowHeadsBothSide);
|
||||
|
||||
tslnudStepFontSize = new ToolStripLabeledNumericUpDown("Font size:");
|
||||
tslnudStepFontSize.Content.Minimum = 10;
|
||||
tslnudStepFontSize.Content.Maximum = 100;
|
||||
tslnudStepFontSize.Content.ValueChanged = (sender, e) =>
|
||||
{
|
||||
AnnotationOptions.StepFontSize = (int)tslnudStepFontSize.Content.Value;
|
||||
UpdateCurrentShape();
|
||||
};
|
||||
tsddbShapeOptions.DropDownItems.Add(tslnudStepFontSize);
|
||||
|
||||
tsmiShadow = new ToolStripMenuItem(Resources.ShapeManager_CreateToolbar_DropShadow);
|
||||
tsmiShadow.Checked = true;
|
||||
tsmiShadow.CheckOnClick = true;
|
||||
|
@ -1188,6 +1198,8 @@ private void UpdateMenu()
|
|||
if (tsbHighlightColor.Image != null) tsbHighlightColor.Image.Dispose();
|
||||
tsbHighlightColor.Image = ImageHelpers.CreateColorPickerIcon(AnnotationOptions.HighlightColor, new Rectangle(0, 0, 16, 16));
|
||||
|
||||
tslnudStepFontSize.Content.Value = AnnotationOptions.StepFontSize;
|
||||
|
||||
tsmiShadow.Checked = AnnotationOptions.Shadow;
|
||||
|
||||
tslnudCenterPoints.Content.Value = AnnotationOptions.LineCenterPointCount;
|
||||
|
@ -1269,6 +1281,7 @@ private void UpdateMenu()
|
|||
|
||||
tslnudCenterPoints.Visible = shapeType == ShapeType.DrawingLine || shapeType == ShapeType.DrawingArrow;
|
||||
tsmiArrowHeadsBothSide.Visible = shapeType == ShapeType.DrawingArrow;
|
||||
tslnudStepFontSize.Visible = shapeType == ShapeType.DrawingStep;
|
||||
tscbCursorTypes.Visible = shapeType == ShapeType.DrawingCursor;
|
||||
tslnudBlurRadius.Visible = shapeType == ShapeType.EffectBlur;
|
||||
tslnudPixelateSize.Visible = shapeType == ShapeType.EffectPixelate;
|
||||
|
|
Loading…
Reference in a new issue