mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Don't draw text if rectangle is too small
This commit is contained in:
parent
fec6e8429a
commit
67f69559fc
6 changed files with 11 additions and 7 deletions
|
@ -240,6 +240,7 @@ private void InitializeComponent()
|
||||||
this.Name = "TextDrawingInputBox";
|
this.Name = "TextDrawingInputBox";
|
||||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||||
this.TopMost = true;
|
this.TopMost = true;
|
||||||
|
this.Shown += new System.EventHandler(this.TextDrawingInputBox_Shown);
|
||||||
this.flpProperties.ResumeLayout(false);
|
this.flpProperties.ResumeLayout(false);
|
||||||
this.flpProperties.PerformLayout();
|
this.flpProperties.PerformLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nudTextSize)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.nudTextSize)).EndInit();
|
||||||
|
|
|
@ -77,6 +77,11 @@ public TextDrawingInputBox(string text, TextDrawingOptions options)
|
||||||
UpdateVerticalAlignmentImage();
|
UpdateVerticalAlignmentImage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void TextDrawingInputBox_Shown(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.ForceActivate();
|
||||||
|
}
|
||||||
|
|
||||||
private void cbFonts_SelectedIndexChanged(object sender, EventArgs e)
|
private void cbFonts_SelectedIndexChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
Options.Font = cbFonts.SelectedItem as string;
|
Options.Font = cbFonts.SelectedItem as string;
|
||||||
|
|
|
@ -56,7 +56,7 @@ public override void Draw(Graphics g)
|
||||||
|
|
||||||
public override void DrawFinal(Graphics g, Bitmap bmp)
|
public override void DrawFinal(Graphics g, Bitmap bmp)
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(Text))
|
if (!string.IsNullOrEmpty(Text) && Rectangle.Width > 10 && Rectangle.Height > 10)
|
||||||
{
|
{
|
||||||
DrawText(g);
|
DrawText(g);
|
||||||
}
|
}
|
||||||
|
@ -65,14 +65,12 @@ public override void DrawFinal(Graphics g, Bitmap bmp)
|
||||||
private void DrawText(Graphics g)
|
private void DrawText(Graphics g)
|
||||||
{
|
{
|
||||||
using (Font font = new Font(Options.Font, Options.Size, Options.Style))
|
using (Font font = new Font(Options.Font, Options.Size, Options.Style))
|
||||||
|
using (Brush textBrush = new SolidBrush(Options.Color))
|
||||||
using (StringFormat sf = new StringFormat { Alignment = Options.AlignmentHorizontal, LineAlignment = Options.AlignmentVertical })
|
using (StringFormat sf = new StringFormat { Alignment = Options.AlignmentHorizontal, LineAlignment = Options.AlignmentVertical })
|
||||||
{
|
|
||||||
using (Brush textBrush = new SolidBrush(Options.Color))
|
|
||||||
{
|
{
|
||||||
g.DrawString(Text, font, textBrush, Rectangle, sf);
|
g.DrawString(Text, font, textBrush, Rectangle, sf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private void UpdateText()
|
private void UpdateText()
|
||||||
{
|
{
|
||||||
|
|
|
@ -59,7 +59,7 @@
|
||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AnnotationOptions.cs" />
|
<Compile Include="Shapes\AnnotationOptions.cs" />
|
||||||
<Compile Include="Enums.cs" />
|
<Compile Include="Enums.cs" />
|
||||||
<Compile Include="Forms\RectangleRegionAnnotateForm.cs">
|
<Compile Include="Forms\RectangleRegionAnnotateForm.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
|
@ -92,7 +92,7 @@
|
||||||
<Compile Include="Shapes\BaseShape.cs" />
|
<Compile Include="Shapes\BaseShape.cs" />
|
||||||
<Compile Include="Shapes\Drawing\ArrowDrawingShape.cs" />
|
<Compile Include="Shapes\Drawing\ArrowDrawingShape.cs" />
|
||||||
<Compile Include="Shapes\Drawing\BaseDrawingShape.cs" />
|
<Compile Include="Shapes\Drawing\BaseDrawingShape.cs" />
|
||||||
<Compile Include="Shapes\Drawing\TextDrawingOptions.cs" />
|
<Compile Include="Shapes\TextDrawingOptions.cs" />
|
||||||
<Compile Include="Shapes\Drawing\TextDrawingShape.cs" />
|
<Compile Include="Shapes\Drawing\TextDrawingShape.cs" />
|
||||||
<Compile Include="Shapes\Effect\BlurEffectShape.cs" />
|
<Compile Include="Shapes\Effect\BlurEffectShape.cs" />
|
||||||
<Compile Include="Shapes\Drawing\EllipseDrawingShape.cs" />
|
<Compile Include="Shapes\Drawing\EllipseDrawingShape.cs" />
|
||||||
|
|
Loading…
Reference in a new issue