Greenshot image editor merge

This commit is contained in:
Jaex 2014-10-31 03:47:59 +02:00
parent d1cd3eb07c
commit 3c31f3f606
3 changed files with 31 additions and 49 deletions

View file

@ -63,7 +63,7 @@ private void SetValuesOnSerializing(StreamingContext context)
[OnDeserialized]
private void SetValuesOnDeserialized(StreamingContext context)
{
InitTargetGripper(Color.Green, _storedTargetGripperLocation);
InitTargetGripper(Color.Yellow, _storedTargetGripperLocation);
}
#endregion TargetGripper serializing code
@ -128,7 +128,7 @@ public override void Draw(Graphics graphics, RenderMode renderMode)
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
@ -147,21 +147,22 @@ public override void Draw(Graphics graphics, RenderMode renderMode)
int tailWidth = (Math.Abs(rect.Width) + Math.Abs(rect.Height)) / 20;
GraphicsPath bubble = new GraphicsPath();
Rectangle bubbleRect = GuiRectangle.GetGuiRectangle(0, 0, rect.Width, rect.Height);
// adapt corner radius to small rectangle dimensions
int smallerSideLength = Math.Min(rect.Width, rect.Height);
int cornerRadius = smallerSideLength > 60 ? 30 : smallerSideLength / 2;
if (cornerRadius > 5)
int smallerSideLength = Math.Min(bubbleRect.Width, bubbleRect.Height);
int cornerRadius = Math.Min(30, smallerSideLength / 2 - lineThickness);
if (cornerRadius > 0)
{
Rectangle bubbleRect = GuiRectangle.GetGuiRectangle(0, 0, rect.Width, rect.Height);
bubbleRect = Rectangle.Inflate(bubbleRect, -lineThickness, -lineThickness);
bubble.AddArc(bubbleRect.X, bubbleRect.Y, cornerRadius, cornerRadius, 180, 90);
bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y, cornerRadius, cornerRadius, 270, 90);
bubble.AddArc(bubbleRect.X + bubbleRect.Width - cornerRadius, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 0, 90);
bubble.AddArc(bubbleRect.X, bubbleRect.Y + bubbleRect.Height - cornerRadius, cornerRadius, cornerRadius, 90, 90);
}
//bubble.AddRectangle(GuiRectangle.GetGuiRectangle(0, 0, rect.Width, rect.Height));
//bubble.AddEllipse(0, 0, Math.Abs(rect.Width), Math.Abs(rect.Height));
else
{
bubble.AddRectangle(bubbleRect);
}
bubble.CloseAllFigures();
GraphicsPath tail = new GraphicsPath();
@ -239,10 +240,10 @@ public override void Draw(Graphics graphics, RenderMode renderMode)
// Draw the text
UpdateFormat();
DrawText(graphics, rect, lineThickness, ControlPaint.Dark(lineColor, 0.1f), false, StringFormat, Text, Font);
DrawText(graphics, rect, lineThickness, lineColor, false, StringFormat, Text, Font);
}
public override bool Contains(int x, int y)
/*public override bool Contains(int x, int y)
{
double xDistanceFromCenter = x - (Left + Width / 2);
double yDistanceFromCenter = y - (Top + Height / 2);
@ -282,6 +283,6 @@ public override bool ClickableAt(int x, int y)
{
return false;
}
}
}*/
}
}

View file

@ -209,7 +209,8 @@ public override void Draw(Graphics graphics, RenderMode rm)
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
string text = ((Surface)Parent).CountStepLabels(this).ToString();
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);

View file

@ -152,6 +152,15 @@ private void Init()
FieldChanged += TextContainer_FieldChanged;
}
public override void Invalidate()
{
base.Invalidate();
if (_textBox != null && _textBox.Visible)
{
_textBox.Invalidate();
}
}
public void FitToText()
{
UpdateFormat();
@ -171,12 +180,10 @@ private void TextContainer_PropertyChanged(object sender, PropertyChangedEventAr
}
else if (Selected && Status == EditStatus.DRAWING)
{
UpdateTextBoxPosition();
UpdateTextBoxFormat();
ShowTextBox();
}
}
else if (_textBox.Visible)
if (_textBox.Visible)
{
UpdateTextBoxPosition();
UpdateTextBoxFormat();
@ -364,35 +371,8 @@ private void UpdateTextBoxFormat()
{
UpdateFormat();
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
_textBox.ForeColor = ControlPaint.Dark(lineColor, 0.1f);
_textBox.ForeColor = lineColor;
_textBox.Font = _font;
StringAlignment horizontalAlignment = (StringAlignment)GetFieldValue(FieldType.TEXT_HORIZONTAL_ALIGNMENT);
switch (horizontalAlignment)
{
case StringAlignment.Center:
_textBox.TextAlign = HorizontalAlignment.Center;
break;
case StringAlignment.Far:
if (_textBox.RightToLeft != RightToLeft.Yes)
{
_textBox.TextAlign = HorizontalAlignment.Right;
}
else
{
_textBox.TextAlign = HorizontalAlignment.Left;
}
break;
case StringAlignment.Near:
if (_textBox.RightToLeft != RightToLeft.Yes)
{
_textBox.TextAlign = HorizontalAlignment.Left;
}
else
{
_textBox.TextAlign = HorizontalAlignment.Right;
}
break;
}
}
private void textBox_KeyDown(object sender, KeyEventArgs e)
@ -420,7 +400,7 @@ public override void Draw(Graphics graphics, RenderMode rm)
graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
graphics.CompositingQuality = CompositingQuality.HighQuality;
graphics.PixelOffsetMode = PixelOffsetMode.None;
graphics.TextRenderingHint = TextRenderingHint.AntiAliasGridFit;
graphics.TextRenderingHint = TextRenderingHint.SystemDefault;
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
if (Selected && rm == RenderMode.EDIT)
@ -440,7 +420,7 @@ public override void Draw(Graphics graphics, RenderMode rm)
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
bool drawShadow = shadow && (fillColor == Color.Transparent || fillColor == Color.Empty);
DrawText(graphics, rect, lineThickness, ControlPaint.Dark(lineColor, 0.1f), drawShadow, _stringFormat, text, _font);
DrawText(graphics, rect, lineThickness, lineColor, drawShadow, _stringFormat, text, _font);
}
/// <summary>
@ -497,11 +477,11 @@ public static void DrawText(Graphics graphics, Rectangle drawingRectange, int li
}
}
public override bool ClickableAt(int x, int y)
/*public override bool ClickableAt(int x, int y)
{
Rectangle r = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
r.Inflate(5, 5);
return r.Contains(x, y);
}
}*/
}
}