mirror of
https://github.com/greenshot/greenshot
synced 2025-08-20 13:33:27 -07:00
Improvement for #220, the size of the font is calculated according to the size of the counter
This commit is contained in:
parent
90d1e114e0
commit
80c262d47f
1 changed files with 9 additions and 30 deletions
|
@ -40,9 +40,7 @@ namespace Greenshot.Drawing {
|
||||||
|
|
||||||
private readonly bool _drawAsRectangle = false;
|
private readonly bool _drawAsRectangle = false;
|
||||||
|
|
||||||
private float fontSize = 16;
|
public StepLabelContainer(Surface parent) : base(parent) {
|
||||||
|
|
||||||
public StepLabelContainer(Surface parent) : base(parent) {
|
|
||||||
parent.AddStepLabel(this);
|
parent.AddStepLabel(this);
|
||||||
InitContent();
|
InitContent();
|
||||||
Init();
|
Init();
|
||||||
|
@ -168,26 +166,6 @@ namespace Greenshot.Drawing {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Make sure the size of the font is scaled
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="matrix"></param>
|
|
||||||
public override void Transform(Matrix matrix) {
|
|
||||||
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
|
||||||
int widthBefore = rect.Width;
|
|
||||||
int heightBefore = rect.Height;
|
|
||||||
|
|
||||||
// Transform this container
|
|
||||||
base.Transform(matrix);
|
|
||||||
rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
|
|
||||||
|
|
||||||
int widthAfter = rect.Width;
|
|
||||||
int heightAfter = rect.Height;
|
|
||||||
float factor = ((float)widthAfter / widthBefore + (float)heightAfter / heightBefore) / 2;
|
|
||||||
|
|
||||||
fontSize *= factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Override the parent, calculate the label number, than draw
|
/// Override the parent, calculate the label number, than draw
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -209,6 +187,7 @@ namespace Greenshot.Drawing {
|
||||||
EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
|
EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float fontSize = Math.Min(Width,Height) / 1.4f;
|
||||||
using FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name);
|
using FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name);
|
||||||
using Font font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel);
|
using Font font = new Font(fam, fontSize, FontStyle.Bold, GraphicsUnit.Pixel);
|
||||||
TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, font);
|
TextContainer.DrawText(graphics, rect, 0, lineColor, false, _stringFormat, text, font);
|
||||||
|
@ -219,9 +198,9 @@ namespace Greenshot.Drawing {
|
||||||
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
|
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
|
||||||
if (_drawAsRectangle) {
|
if (_drawAsRectangle) {
|
||||||
return RectangleContainer.RectangleClickableAt(rect, 0, fillColor, x, y);
|
return RectangleContainer.RectangleClickableAt(rect, 0, fillColor, x, y);
|
||||||
} else {
|
|
||||||
return EllipseContainer.EllipseClickableAt(rect, 0, fillColor, x, y);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
return EllipseContainer.EllipseClickableAt(rect, 0, fillColor, x, y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue