mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Info text improvement
This commit is contained in:
parent
8adfe5342e
commit
8b16323151
4 changed files with 25 additions and 85 deletions
|
@ -357,23 +357,21 @@ protected override void OnPaint(PaintEventArgs e)
|
|||
g.DrawImage(backgroundImage, ScreenRectangle0Based);
|
||||
g.CompositingMode = CompositingMode.SourceOver;
|
||||
|
||||
if (!isMouseDown)
|
||||
{
|
||||
if (Mode == RegionAnnotateMode.Pen)
|
||||
{
|
||||
DrawDot(g);
|
||||
DrawDot(g, true);
|
||||
}
|
||||
else if (Mode == RegionAnnotateMode.Rectangle)
|
||||
{
|
||||
g.SmoothingMode = SmoothingMode.HighSpeed;
|
||||
if (isMouseDown)
|
||||
{
|
||||
DrawRectangle(g);
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawRectangleMarker(g);
|
||||
}
|
||||
}
|
||||
else if (Mode == RegionAnnotateMode.Rectangle)
|
||||
{
|
||||
g.SmoothingMode = SmoothingMode.HighSpeed;
|
||||
DrawRectangle(g);
|
||||
}
|
||||
|
||||
if (Options.ShowTips)
|
||||
{
|
||||
|
@ -457,46 +455,6 @@ protected virtual void WriteTips(StringBuilder sb)
|
|||
sb.AppendLine(Resources.RectangleRegion_WriteTips__Space__Fullscreen_capture);
|
||||
}
|
||||
|
||||
private void DrawTips(Graphics g)
|
||||
{
|
||||
int offset = 10;
|
||||
int padding = 3;
|
||||
|
||||
string tipText;
|
||||
|
||||
if (IsDrawingMode)
|
||||
{
|
||||
// TODO: Delete resources
|
||||
tipText = Resources.RectangleAnnotate_DrawTips_Drawing_mode_on;
|
||||
}
|
||||
else
|
||||
{
|
||||
tipText = Resources.RectangleAnnotate_DrawTips_Drawing_mode_off;
|
||||
}
|
||||
|
||||
Size textSize = g.MeasureString(tipText, tipFont).ToSize();
|
||||
int rectWidth = textSize.Width + padding * 2;
|
||||
int rectHeight = textSize.Height + padding * 2;
|
||||
Rectangle primaryScreenBounds = CaptureHelpers.GetPrimaryScreenBounds0Based();
|
||||
Rectangle textRectangle = new Rectangle(primaryScreenBounds.X + (primaryScreenBounds.Width / 2) - (rectWidth / 2), primaryScreenBounds.Y + offset, rectWidth, rectHeight);
|
||||
|
||||
if (textRectangle.Offset(10).Contains(CurrentMousePosition0Based))
|
||||
{
|
||||
textRectangle.Y = primaryScreenBounds.Height - rectHeight - offset;
|
||||
}
|
||||
|
||||
using (Brush brush = new SolidBrush(Color.FromArgb(175, Color.White)))
|
||||
using (Pen pen = new Pen(Color.FromArgb(175, Color.Black)))
|
||||
{
|
||||
g.DrawRoundedRectangle(brush, pen, textRectangle, 5);
|
||||
}
|
||||
|
||||
using (StringFormat sf = new StringFormat { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center })
|
||||
{
|
||||
g.DrawString(tipText, tipFont, Brushes.Black, textRectangle, sf);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawInfo(Graphics g)
|
||||
{
|
||||
string infoText;
|
||||
|
@ -510,10 +468,10 @@ private void DrawInfo(Graphics g)
|
|||
infoText = string.Format("X: {0} Y: {1}", CurrentMousePosition.X, CurrentMousePosition.Y);
|
||||
}
|
||||
|
||||
int offset = 10;
|
||||
Point position = new Point(CurrentMousePosition0Based.X + offset, CurrentMousePosition0Based.Y + offset);
|
||||
|
||||
ImageHelpers.DrawTextWithShadow(g, infoText, position, infoFont, Color.White, Color.Black);
|
||||
int offset = 10, padding = 3;
|
||||
Point pos = CurrentMousePosition0Based;
|
||||
Size textSize = g.MeasureString(infoText, infoFont).ToSize();
|
||||
DrawInfoText(g, infoText, new Rectangle(pos.X + offset, pos.Y + offset, textSize.Width + padding * 2, textSize.Height + padding * 2), padding);
|
||||
}
|
||||
|
||||
private void DrawLine(Graphics g)
|
||||
|
@ -548,13 +506,19 @@ private void AddRectangle()
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawDot(Graphics g)
|
||||
private void DrawDot(Graphics g, bool border = false)
|
||||
{
|
||||
using (Brush brush = new SolidBrush(Options.DrawingPenColor))
|
||||
{
|
||||
Point pos = CurrentMousePosition0Based;
|
||||
RectangleF rect = new RectangleF(pos.X - Options.DrawingPenSize / 2f, pos.Y - Options.DrawingPenSize / 2f, Options.DrawingPenSize, Options.DrawingPenSize);
|
||||
Rectangle rect = new Rectangle((int)(pos.X - Options.DrawingPenSize / 2f), (int)(pos.Y - Options.DrawingPenSize / 2f), Options.DrawingPenSize, Options.DrawingPenSize);
|
||||
g.FillEllipse(brush, rect);
|
||||
|
||||
if (border)
|
||||
{
|
||||
g.DrawEllipse(Pens.Black, rect.Offset(1));
|
||||
g.DrawEllipse(Pens.White, rect.Offset(2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -580,7 +580,7 @@ private void DrawMagnifier(Graphics g)
|
|||
if (Config.ShowInfo)
|
||||
{
|
||||
infoTextRect.Location = new Point(x + (magnifier.Width / 2) - (infoTextRect.Width / 2), y + magnifier.Height + infoTextOffset);
|
||||
DrawInfoText(g, infoText, infoTextRect, 3);
|
||||
DrawInfoText(g, infoText, infoTextRect, infoTextPadding);
|
||||
}
|
||||
|
||||
g.SetHighQuality();
|
||||
|
|
|
@ -75,7 +75,7 @@ internal static byte[] Crosshair {
|
|||
/// </summary>
|
||||
internal static System.Drawing.Bitmap exclamation_button {
|
||||
get {
|
||||
object obj = ResourceManager.GetObject("exclamation-button", resourceCulture);
|
||||
object obj = ResourceManager.GetObject("exclamation_button", resourceCulture);
|
||||
return ((System.Drawing.Bitmap)(obj));
|
||||
}
|
||||
}
|
||||
|
@ -135,24 +135,6 @@ internal static string FFmpegOptionsForm_UpdateUI_Quality_ {
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Ctrl: Drawing mode ░ Space: Fullscreen capture.
|
||||
/// </summary>
|
||||
internal static string RectangleAnnotate_DrawTips_Drawing_mode_off {
|
||||
get {
|
||||
return ResourceManager.GetString("RectangleAnnotate_DrawTips_Drawing_mode_off", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Ctrl: Region mode ░ Shift: Pen color ░ Mouse wheel: Pen size ░ Space: Fullscreen capture.
|
||||
/// </summary>
|
||||
internal static string RectangleAnnotate_DrawTips_Drawing_mode_on {
|
||||
get {
|
||||
return ResourceManager.GetString("RectangleAnnotate_DrawTips_Drawing_mode_on", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Rectangle capture annotate.
|
||||
/// </summary>
|
||||
|
|
|
@ -159,9 +159,6 @@ X: {4} Y: {5}</value>
|
|||
<data name="RectangleRegion_GetAreaText_Area" xml:space="preserve">
|
||||
<value>X: {0} Y: {1} W: {2} H: {3}</value>
|
||||
</data>
|
||||
<data name="RectangleAnnotate_DrawTips_Drawing_mode_on" xml:space="preserve">
|
||||
<value>Ctrl: Region mode ░ Shift: Pen color ░ Mouse wheel: Pen size ░ Space: Fullscreen capture</value>
|
||||
</data>
|
||||
<data name="RectangleRegion_WriteTips__Hold_Left_click_on_selection__Move_region" xml:space="preserve">
|
||||
<value>[Hold left click on selection] Move region</value>
|
||||
</data>
|
||||
|
@ -240,9 +237,6 @@ Distance: {6:0.00} px / Angle: {7:0.00}°</value>
|
|||
<data name="RectangleRegion_WriteTips__Numpad_2__Rounded_rectangle_shape" xml:space="preserve">
|
||||
<value>[Numpad 2] Rounded rectangle shape</value>
|
||||
</data>
|
||||
<data name="RectangleAnnotate_DrawTips_Drawing_mode_off" xml:space="preserve">
|
||||
<value>Ctrl: Drawing mode ░ Space: Fullscreen capture</value>
|
||||
</data>
|
||||
<data name="FFmpegOptionsForm_buttonFFmpegBrowse_Click_Browse_for_ffmpeg_exe" xml:space="preserve">
|
||||
<value>Browse for ffmpeg.exe</value>
|
||||
</data>
|
||||
|
@ -303,7 +297,7 @@ Distance: {6:0.00} px / Angle: {7:0.00}°</value>
|
|||
<data name="RectangleRegion_WriteTips__1__2__3_____0__Monitor_capture" xml:space="preserve">
|
||||
<value>[1, 2, 3 ... 0] Monitor capture</value>
|
||||
</data>
|
||||
<data name="exclamation-button" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<data name="exclamation_button" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>..\Resources\exclamation-button.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||
</data>
|
||||
</root>
|
Loading…
Reference in a new issue