mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
Allow drawing info near cursor even when not drawing magnifier
This commit is contained in:
parent
df3b8b4a59
commit
de55be0420
4 changed files with 59 additions and 37 deletions
|
@ -1411,7 +1411,7 @@ internal static string HotkeyType_ScreenColorPicker_Category {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Start/stop screen recording.
|
||||
/// Looks up a localized string similar to Start/Stop screen recording.
|
||||
/// </summary>
|
||||
internal static string HotkeyType_ScreenRecorder {
|
||||
get {
|
||||
|
@ -1465,7 +1465,7 @@ internal static string HotkeyType_ScreenRecorderCustomRegion_Category {
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Start/stop screen recording (GIF).
|
||||
/// Looks up a localized string similar to Start/Stop screen recording (GIF).
|
||||
/// </summary>
|
||||
internal static string HotkeyType_ScreenRecorderGIF {
|
||||
get {
|
||||
|
|
|
@ -460,7 +460,7 @@ File size: {2:n0} / {3:n0} KB</value>
|
|||
<value>Screen color picker</value>
|
||||
</data>
|
||||
<data name="HotkeyType_ScreenRecorder" xml:space="preserve">
|
||||
<value>Start/stop screen recording</value>
|
||||
<value>Start/Stop screen recording</value>
|
||||
</data>
|
||||
<data name="HotkeyType_StopUploads" xml:space="preserve">
|
||||
<value>Stop all active uploads</value>
|
||||
|
@ -605,7 +605,7 @@ Would you like to download and install it?</value>
|
|||
<value>Color picker</value>
|
||||
</data>
|
||||
<data name="HotkeyType_ScreenRecorderGIF" xml:space="preserve">
|
||||
<value>Start/stop screen recording (GIF)</value>
|
||||
<value>Start/Stop screen recording (GIF)</value>
|
||||
</data>
|
||||
<data name="HotkeyType_StartScreenRecorderGIF" xml:space="preserve">
|
||||
<value>Start screen recording (GIF) using last region</value>
|
||||
|
|
|
@ -298,9 +298,9 @@ protected override void Draw(Graphics g)
|
|||
}
|
||||
|
||||
// Draw magnifier
|
||||
if (Config.ShowMagnifier)
|
||||
if (Config.ShowMagnifier || Config.ShowInfo)
|
||||
{
|
||||
DrawMagnifier(g);
|
||||
DrawCursorGraphics(g);
|
||||
}
|
||||
|
||||
// Draw screen wide crosshair
|
||||
|
@ -595,67 +595,90 @@ private void DrawCrosshair(Graphics g)
|
|||
}
|
||||
}
|
||||
|
||||
private void DrawMagnifier(Graphics g)
|
||||
private void DrawCursorGraphics(Graphics g)
|
||||
{
|
||||
Point mousePos = InputManager.MousePosition0Based;
|
||||
Rectangle currentScreenRect0Based = CaptureHelpers.GetActiveScreenBounds0Based();
|
||||
int offsetX = 10, offsetY = 10, infoTextOffset = 0, infoTextPadding = 3;
|
||||
int cursorOffsetX = 10, cursorOffsetY = 10, itemGap = 10, itemCount = 0;
|
||||
Size totalSize = Size.Empty;
|
||||
|
||||
int magnifierPosition = 0;
|
||||
Bitmap magnifier = null;
|
||||
|
||||
if (Config.ShowMagnifier)
|
||||
{
|
||||
if (itemCount > 0) totalSize.Height += itemGap;
|
||||
magnifierPosition = totalSize.Height;
|
||||
|
||||
magnifier = Magnifier(backgroundImage, mousePos, Config.MagnifierPixelCount, Config.MagnifierPixelCount, Config.MagnifierPixelSize);
|
||||
totalSize.Width = Math.Max(totalSize.Width, magnifier.Width);
|
||||
|
||||
totalSize.Height += magnifier.Height;
|
||||
itemCount++;
|
||||
}
|
||||
|
||||
int infoTextPadding = 3;
|
||||
int infoTextPosition = 0;
|
||||
Rectangle infoTextRect = Rectangle.Empty;
|
||||
string infoText = "";
|
||||
|
||||
if (Config.ShowInfo)
|
||||
{
|
||||
infoTextOffset = 10;
|
||||
if (itemCount > 0) totalSize.Height += itemGap;
|
||||
infoTextPosition = totalSize.Height;
|
||||
|
||||
CurrentPosition = InputManager.MousePosition;
|
||||
|
||||
infoText = GetInfoText();
|
||||
Size textSize = g.MeasureString(infoText, infoFont).ToSize();
|
||||
infoTextRect.Size = new Size(textSize.Width + infoTextPadding * 2, textSize.Height + infoTextPadding * 2);
|
||||
totalSize.Width = Math.Max(totalSize.Width, infoTextRect.Width);
|
||||
|
||||
totalSize.Height += infoTextRect.Height;
|
||||
itemCount++;
|
||||
}
|
||||
|
||||
using (Bitmap magnifier = Magnifier(backgroundImage, mousePos, Config.MagnifierPixelCount, Config.MagnifierPixelCount, Config.MagnifierPixelSize))
|
||||
int x = mousePos.X + cursorOffsetX;
|
||||
|
||||
if (x + totalSize.Width > currentScreenRect0Based.Right)
|
||||
{
|
||||
int x = mousePos.X + offsetX;
|
||||
x = mousePos.X - cursorOffsetX - totalSize.Width;
|
||||
}
|
||||
|
||||
if (x + magnifier.Width > currentScreenRect0Based.Right)
|
||||
{
|
||||
x = mousePos.X - offsetX - magnifier.Width;
|
||||
}
|
||||
int y = mousePos.Y + cursorOffsetY;
|
||||
|
||||
int y = mousePos.Y + offsetY;
|
||||
|
||||
if (y + magnifier.Height + infoTextOffset + infoTextRect.Height > currentScreenRect0Based.Bottom)
|
||||
{
|
||||
y = mousePos.Y - offsetY - magnifier.Height - infoTextOffset - infoTextRect.Height;
|
||||
}
|
||||
|
||||
if (Config.ShowInfo)
|
||||
{
|
||||
infoTextRect.Location = new Point(x + (magnifier.Width / 2) - (infoTextRect.Width / 2), y + magnifier.Height + infoTextOffset);
|
||||
DrawInfoText(g, infoText, infoTextRect, infoFont, infoTextPadding);
|
||||
}
|
||||
if (y + totalSize.Height > currentScreenRect0Based.Bottom)
|
||||
{
|
||||
y = mousePos.Y - cursorOffsetY - totalSize.Height;
|
||||
}
|
||||
|
||||
if (Config.ShowMagnifier)
|
||||
{
|
||||
g.SetHighQuality();
|
||||
|
||||
using (TextureBrush brush = new TextureBrush(magnifier))
|
||||
{
|
||||
brush.TranslateTransform(x, y);
|
||||
brush.TranslateTransform(x, y + magnifierPosition);
|
||||
|
||||
if (Config.UseSquareMagnifier)
|
||||
{
|
||||
g.FillRectangle(brush, x, y, magnifier.Width, magnifier.Height);
|
||||
g.DrawRectangleProper(Pens.White, x - 1, y - 1, magnifier.Width + 2, magnifier.Height + 2);
|
||||
g.DrawRectangleProper(Pens.Black, x, y, magnifier.Width, magnifier.Height);
|
||||
g.FillRectangle(brush, x, y + magnifierPosition, magnifier.Width, magnifier.Height);
|
||||
g.DrawRectangleProper(Pens.White, x - 1, y + magnifierPosition - 1, magnifier.Width + 2, magnifier.Height + 2);
|
||||
g.DrawRectangleProper(Pens.Black, x, y + magnifierPosition, magnifier.Width, magnifier.Height);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.FillEllipse(brush, x, y, magnifier.Width, magnifier.Height);
|
||||
g.DrawEllipse(Pens.White, x - 1, y - 1, magnifier.Width + 2, magnifier.Height + 2);
|
||||
g.DrawEllipse(Pens.Black, x, y, magnifier.Width, magnifier.Height);
|
||||
g.FillEllipse(brush, x, y + magnifierPosition, magnifier.Width, magnifier.Height);
|
||||
g.DrawEllipse(Pens.White, x - 1, y + magnifierPosition - 1, magnifier.Width + 2, magnifier.Height + 2);
|
||||
g.DrawEllipse(Pens.Black, x, y + magnifierPosition, magnifier.Width, magnifier.Height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.ShowInfo)
|
||||
{
|
||||
infoTextRect.Location = new Point(x + (totalSize.Width / 2) - (infoTextRect.Width / 2), y + infoTextPosition);
|
||||
DrawInfoText(g, infoText, infoTextRect, infoFont, infoTextPadding);
|
||||
}
|
||||
}
|
||||
|
||||
private Bitmap Magnifier(Image img, Point position, int horizontalPixelCount, int verticalPixelCount, int pixelSize)
|
||||
|
|
|
@ -123,8 +123,7 @@ public AboutForm()
|
|||
AWS SDK: http://aws.amazon.com/sdk-for-net/
|
||||
CLR Security: http://clrsecurity.codeplex.com
|
||||
Steamworks.NET: https://github.com/rlabrecque/Steamworks.NET
|
||||
|
||||
Trailer music credits: Track Name: Au5 - Inside (feat. Danyka Nadeau), Video Link: https://youtu.be/WrkyT-6ivjc, Buy Link: http://music.monstercat.com/track/inside-feat-danyka-nadeau, Label Channel: http://www.YouTube.com/Monstercat
|
||||
OCR Space: http://ocr.space
|
||||
|
||||
Copyright (c) 2007-2016 ShareX Team", Resources.AboutForm_AboutForm_Contributors, Resources.AboutForm_AboutForm_Translators, Resources.AboutForm_AboutForm_External_libraries);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue