StepLabelContainer enhancements and addition of text color field.

Added a text color field to the TextContainer, SpeechBubbleContainer and StepLabelContainer. Added shadow field to StepLabelContainer. Added drawing of an outline around StepLabelContainers.
This commit is contained in:
Don McComb 2018-03-12 09:23:13 +11:00
commit c374cd91d3
9 changed files with 659 additions and 613 deletions

View file

@ -35,6 +35,7 @@ namespace Greenshot.Drawing.Fields
public static readonly IFieldType BLUR_RADIUS = new FieldType("BLUR_RADIUS");
public static readonly IFieldType BRIGHTNESS = new FieldType("BRIGHTNESS");
public static readonly IFieldType FILL_COLOR = new FieldType("FILL_COLOR");
public static readonly IFieldType TEXT_COLOR = new FieldType("TEXT_COLOR");
public static readonly IFieldType FONT_BOLD = new FieldType("FONT_BOLD");
public static readonly IFieldType FONT_FAMILY = new FieldType("FONT_FAMILY");
public static readonly IFieldType FONT_ITALIC = new FieldType("FONT_ITALIC");
@ -57,6 +58,7 @@ namespace Greenshot.Drawing.Fields
BLUR_RADIUS,
BRIGHTNESS,
FILL_COLOR,
TEXT_COLOR,
FONT_BOLD,
FONT_FAMILY,
FONT_ITALIC,

View file

@ -75,6 +75,7 @@ namespace Greenshot.Drawing
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
AddField(GetType(), FieldType.LINE_COLOR, Color.Blue);
AddField(GetType(), FieldType.SHADOW, false);
AddField(GetType(), FieldType.TEXT_COLOR, Color.Blue);
AddField(GetType(), FieldType.FONT_ITALIC, false);
AddField(GetType(), FieldType.FONT_BOLD, true);
AddField(GetType(), FieldType.FILL_COLOR, Color.White);
@ -219,6 +220,7 @@ namespace Greenshot.Drawing
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
Color textColor = GetFieldValueAsColor(FieldType.TEXT_COLOR);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
@ -304,7 +306,7 @@ namespace Greenshot.Drawing
tail.Dispose();
// Draw the text
DrawText(graphics, rect, lineThickness, lineColor, shadow, StringFormat, Text, Font);
DrawText(graphics, rect, lineThickness, textColor, shadow, StringFormat, Text, Font);
}
public override bool Contains(int x, int y) {

View file

@ -142,8 +142,11 @@ namespace Greenshot.Drawing {
/// </summary>
protected override void InitializeFields() {
AddField(GetType(), FieldType.FILL_COLOR, Color.DarkRed);
AddField(GetType(), FieldType.LINE_COLOR, Color.White);
AddField(GetType(), FieldType.LINE_COLOR, Color.Yellow);
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
AddField(GetType(), FieldType.TEXT_COLOR, Color.White);
AddField(GetType(), FieldType.FLAGS, FieldFlag.COUNTER);
AddField(GetType(), FieldType.SHADOW, false);
}
/// <summary>
@ -206,14 +209,44 @@ namespace Greenshot.Drawing {
Rectangle rect = GuiRectangle.GetGuiRectangle(Left, Top, Width, Height);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
Color textColor = GetFieldValueAsColor(FieldType.TEXT_COLOR);
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
if (shadow)
{
const int basealpha = 100;
Rectangle dropShadowRect = rect;
// Draw glow around step label
dropShadowRect.Inflate(1, 1);
EllipseContainer.DrawEllipse(dropShadowRect, graphics, rm, 0, Color.Transparent, Color.FromArgb(basealpha, 100, 100, 100), false);
// Draw drop shadow
dropShadowRect = rect;
int steps = 4;
int alpha = basealpha;
for (int currentStep = 0; currentStep <= steps; currentStep++)
{
dropShadowRect.Offset(1, 1);
EllipseContainer.DrawEllipse(dropShadowRect, graphics, rm, 0, Color.Transparent, Color.FromArgb(alpha, 100, 100, 100), false);
alpha = alpha - basealpha / steps;
}
}
if (_drawAsRectangle) {
RectangleContainer.DrawRectangle(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
} else {
if (lineThickness > 0)
{
EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, lineColor, false);
rect.Inflate(lineThickness * -2, lineThickness * -2);
}
EllipseContainer.DrawEllipse(rect, graphics, rm, 0, Color.Transparent, fillColor, false);
}
using (FontFamily fam = new FontFamily(FontFamily.GenericSansSerif.Name)) {
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, textColor, false, _stringFormat, text, font);
}
}
}

View file

@ -98,6 +98,7 @@ namespace Greenshot.Drawing
AddField(GetType(), FieldType.LINE_THICKNESS, 2);
AddField(GetType(), FieldType.LINE_COLOR, Color.Red);
AddField(GetType(), FieldType.SHADOW, true);
AddField(GetType(), FieldType.TEXT_COLOR, Color.Red);
AddField(GetType(), FieldType.FONT_ITALIC, false);
AddField(GetType(), FieldType.FONT_BOLD, false);
AddField(GetType(), FieldType.FILL_COLOR, Color.Transparent);
@ -288,8 +289,8 @@ namespace Greenshot.Drawing
{
return;
}
Color lc = GetFieldValueAsColor(FieldType.LINE_COLOR);
if (lc.R > 203 && lc.G > 203 && lc.B > 203)
Color tc = GetFieldValueAsColor(FieldType.TEXT_COLOR);
if (tc.R > 203 && tc.G > 203 && tc.B > 203)
{
_textBox.BackColor = Color.FromArgb(51, 51, 51);
}
@ -481,8 +482,8 @@ namespace Greenshot.Drawing
break;
}
var lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
_textBox.ForeColor = lineColor;
var textColor = GetFieldValueAsColor(FieldType.TEXT_COLOR);
_textBox.ForeColor = textColor;
}
private void textBox_KeyDown(object sender, KeyEventArgs e)
@ -549,10 +550,10 @@ namespace Greenshot.Drawing
bool shadow = GetFieldValueAsBool(FieldType.SHADOW);
Color fillColor = GetFieldValueAsColor(FieldType.FILL_COLOR);
int lineThickness = GetFieldValueAsInt(FieldType.LINE_THICKNESS);
Color lineColor = GetFieldValueAsColor(FieldType.LINE_COLOR);
Color textColor = GetFieldValueAsColor(FieldType.TEXT_COLOR);
bool drawShadow = shadow && (fillColor == Color.Transparent || fillColor == Color.Empty);
DrawText(graphics, rect, lineThickness, lineColor, drawShadow, _stringFormat, text, _font);
DrawText(graphics, rect, lineThickness, textColor, drawShadow, _stringFormat, text, _font);
}
/// <summary>

View file

@ -149,6 +149,7 @@ namespace Greenshot {
this.grayscaleHighlightMenuItem = new GreenshotPlugin.Controls.GreenshotToolStripMenuItem();
this.magnifyMenuItem = new GreenshotPlugin.Controls.GreenshotToolStripMenuItem();
this.btnFillColor = new Greenshot.Controls.ToolStripColorButton();
this.btnTextColor = new Greenshot.Controls.ToolStripColorButton();
this.btnLineColor = new Greenshot.Controls.ToolStripColorButton();
this.lineThicknessLabel = new GreenshotPlugin.Controls.GreenshotToolStripLabel();
this.lineThicknessUpDown = new Greenshot.Controls.ToolStripNumericUpDown();
@ -1029,6 +1030,7 @@ namespace Greenshot {
this.obfuscateModeButton,
this.highlightModeButton,
this.btnFillColor,
this.btnTextColor,
this.btnLineColor,
this.lineThicknessLabel,
this.lineThicknessUpDown,
@ -1051,13 +1053,13 @@ namespace Greenshot {
this.pixelSizeUpDown,
this.arrowHeadsLabel,
this.arrowHeadsDropDownButton,
this.counterLabel,
this.counterUpDown,
this.shadowButton,
this.toolStripSeparator,
this.toolStripSeparator10,
this.btnConfirm,
this.btnCancel,
this.counterLabel,
this.counterUpDown});
this.btnCancel});
//
// obfuscateModeButton
//
@ -1138,6 +1140,15 @@ namespace Greenshot {
this.btnFillColor.Name = "btnFillColor";
this.btnFillColor.SelectedColor = System.Drawing.Color.Transparent;
//
// btnTextColor
//
this.btnTextColor.BackColor = System.Drawing.Color.Transparent;
this.btnTextColor.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
this.btnTextColor.Image = ((System.Drawing.Image)(resources.GetObject("btnTextColor.Image")));
this.btnTextColor.LanguageKey = "editor_textcolor";
this.btnTextColor.Name = "btnTextColor";
this.btnTextColor.SelectedColor = System.Drawing.Color.Black;
//
// btnLineColor
//
this.btnLineColor.BackColor = System.Drawing.Color.Transparent;
@ -1790,6 +1801,7 @@ namespace Greenshot {
private Greenshot.Controls.ToolStripEx destinationsToolStrip;
private GreenshotPlugin.Controls.NonJumpingPanel panel1;
private Greenshot.Controls.ToolStripColorButton btnFillColor;
private Greenshot.Controls.ToolStripColorButton btnTextColor;
private Greenshot.Controls.ToolStripColorButton btnLineColor;
private GreenshotPlugin.Controls.GreenshotToolStripMenuItem autoCropToolStripMenuItem;
private System.Windows.Forms.ToolStripSeparator toolStripSeparator17;

View file

@ -1009,6 +1009,7 @@ namespace Greenshot {
private void BindFieldControls() {
// TODO: This is actually risky, if there are no references than the objects may be garbage collected
new BidirectionalBinding(btnFillColor, "SelectedColor", _surface.FieldAggregator.GetField(FieldType.FILL_COLOR), "Value", NotNullValidator.GetInstance());
new BidirectionalBinding(btnTextColor, "SelectedColor", _surface.FieldAggregator.GetField(FieldType.TEXT_COLOR), "Value", NotNullValidator.GetInstance());
new BidirectionalBinding(btnLineColor, "SelectedColor", _surface.FieldAggregator.GetField(FieldType.LINE_COLOR), "Value", NotNullValidator.GetInstance());
new BidirectionalBinding(lineThicknessUpDown, "Value", _surface.FieldAggregator.GetField(FieldType.LINE_THICKNESS), "Value", DecimalIntConverter.GetInstance(), NotNullValidator.GetInstance());
new BidirectionalBinding(blurRadiusUpDown, "Value", _surface.FieldAggregator.GetField(FieldType.BLUR_RADIUS), "Value", DecimalIntConverter.GetInstance(), NotNullValidator.GetInstance());
@ -1036,6 +1037,7 @@ namespace Greenshot {
if(_surface.HasSelectedElements || _surface.DrawingMode != DrawingModes.None) {
FieldAggregator props = _surface.FieldAggregator;
btnFillColor.Visible = props.HasFieldValue(FieldType.FILL_COLOR);
btnTextColor.Visible = props.HasFieldValue(FieldType.TEXT_COLOR);
btnLineColor.Visible = props.HasFieldValue(FieldType.LINE_COLOR);
lineThicknessLabel.Visible = lineThicknessUpDown.Visible = props.HasFieldValue(FieldType.LINE_THICKNESS);
blurRadiusLabel.Visible = blurRadiusUpDown.Visible = props.HasFieldValue(FieldType.BLUR_RADIUS);

File diff suppressed because it is too large Load diff

View file

@ -91,6 +91,7 @@ Also, we would highly appreciate if you checked whether a tracker item already e
<resource name="editor_copyimagetoclipboard">Copy image to clipboard</resource>
<resource name="editor_copypathtoclipboard">Copy path to clipboard</resource>
<resource name="editor_copytoclipboard">Copy</resource>
<resource name="editor_counter_startvalue">Start value</resource>
<resource name="editor_crop">Crop (C)</resource>
<resource name="editor_cursortool">Selection Tool (ESC)</resource>
<resource name="editor_cuttoclipboard">Cut</resource>
@ -148,6 +149,7 @@ Also, we would highly appreciate if you checked whether a tracker item already e
<resource name="editor_senttoprinter">Print job was sent to '{0}'.</resource>
<resource name="editor_shadow">Drop shadow</resource>
<resource name="editor_storedtoclipboard">Image stored to clipboard.</resource>
<resource name="editor_textcolor">Text color</resource>
<resource name="editor_thickness">Line thickness</resource>
<resource name="editor_title">Greenshot image editor</resource>
<resource name="editor_torn_edge">Torn edge</resource>

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B