mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 17:56:51 +13:00
When drawing shape is selected show border color inside cursor
This commit is contained in:
parent
37c4749cd0
commit
f237ea6255
2 changed files with 39 additions and 0 deletions
|
@ -120,6 +120,9 @@ public static partial class NativeMethods
|
|||
[DllImport("user32.dll")]
|
||||
public static extern bool GetIconInfo(IntPtr hIcon, out IconInfo piconinfo);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr CreateIconIndirect([In] ref IconInfo piconinfo);
|
||||
|
||||
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true, CallingConvention = CallingConvention.Winapi)]
|
||||
public static extern short GetKeyState(int keyCode);
|
||||
|
||||
|
|
|
@ -80,6 +80,8 @@ private set
|
|||
{
|
||||
Config.LastAnnotationTool = CurrentShapeType;
|
||||
}
|
||||
|
||||
UpdateCursor();
|
||||
}
|
||||
|
||||
DeselectShape();
|
||||
|
@ -403,6 +405,7 @@ private void CreateContextMenu()
|
|||
|
||||
UpdateContextMenu();
|
||||
UpdateCurrentShape();
|
||||
UpdateCursor();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1484,6 +1487,39 @@ public Rectangle CombineAreas()
|
|||
return Rectangle.Empty;
|
||||
}
|
||||
|
||||
private void UpdateCursor()
|
||||
{
|
||||
Cursor cursor = Helpers.CreateCursor(Resources.Crosshair);
|
||||
|
||||
if (!IsCurrentShapeTypeRegion)
|
||||
{
|
||||
using (Bitmap bmp = new Bitmap(32, 32))
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
using (Pen pen = new Pen(Config.AnnotationOptions.BorderColor, 2))
|
||||
{
|
||||
g.DrawRectangleProper(pen, new Rectangle(2, 2, 27, 27));
|
||||
}
|
||||
|
||||
cursor.Draw(g, new Rectangle(0, 0, 32, 32));
|
||||
|
||||
IntPtr ptr = bmp.GetHicon();
|
||||
IconInfo iconInfo = new IconInfo();
|
||||
NativeMethods.GetIconInfo(ptr, out iconInfo);
|
||||
iconInfo.xHotspot = 15;
|
||||
iconInfo.yHotspot = 15;
|
||||
iconInfo.fIcon = false;
|
||||
ptr = NativeMethods.CreateIconIndirect(ref iconInfo);
|
||||
cursor.Dispose();
|
||||
cursor = new Cursor(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
Cursor temp = form.Cursor;
|
||||
form.Cursor = cursor;
|
||||
temp.Dispose();
|
||||
}
|
||||
|
||||
public void PauseForm()
|
||||
{
|
||||
form.Pause();
|
||||
|
|
Loading…
Reference in a new issue