mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-02 21:20:28 +12:00
Added cancel capture button, menu will open centered to cursor
This commit is contained in:
parent
b82ec96b95
commit
bda1e342f4
|
@ -141,6 +141,16 @@ public static bool IsValid(this Rectangle rect)
|
|||
return rect.Width > 0 && rect.Height > 0;
|
||||
}
|
||||
|
||||
public static Point Add(this Point point, int offset)
|
||||
{
|
||||
return point.Add(offset, offset);
|
||||
}
|
||||
|
||||
public static Point Add(this Point point, int offsetX, int offsetY)
|
||||
{
|
||||
return new Point(point.X + offsetX, point.Y + offsetY);
|
||||
}
|
||||
|
||||
public static Size Offset(this Size size, int offset)
|
||||
{
|
||||
return new Size(size.Width + offset, size.Height + offset);
|
||||
|
|
|
@ -434,7 +434,6 @@ protected virtual void WriteTips(StringBuilder sb)
|
|||
|
||||
sb.AppendLine();
|
||||
|
||||
// TODO: Find new hotkey
|
||||
sb.AppendLine(Resources.RectangleRegion_WriteTips__Space__Fullscreen_capture);
|
||||
sb.AppendLine(Resources.RectangleRegion_WriteTips__1__2__3_____0__Monitor_capture);
|
||||
sb.AppendLine(Resources.RectangleRegion_WriteTips_____Active_monitor_capture);
|
||||
|
|
|
@ -167,6 +167,16 @@ private void CreateContextMenu()
|
|||
{
|
||||
cmsContextMenu = new ContextMenuStrip();
|
||||
|
||||
ToolStripMenuItem tsmiCancelCapture = new ToolStripMenuItem("Cancel capture");
|
||||
tsmiCancelCapture.Click += (sender, e) => surface.Close(SurfaceResult.Close);
|
||||
cmsContextMenu.Items.Add(tsmiCancelCapture);
|
||||
|
||||
ToolStripMenuItem tsmiCloseMenu = new ToolStripMenuItem("Close menu");
|
||||
tsmiCloseMenu.Click += (sender, e) => cmsContextMenu.Close();
|
||||
cmsContextMenu.Items.Add(tsmiCloseMenu);
|
||||
|
||||
cmsContextMenu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
foreach (ShapeType shapeType in Helpers.GetEnums<ShapeType>())
|
||||
{
|
||||
ToolStripMenuItem tsmiShapeType = new ToolStripMenuItem(shapeType.GetLocalizedDescription());
|
||||
|
@ -301,12 +311,39 @@ private void CreateContextMenu()
|
|||
tsmiShowCrosshair.CheckOnClick = true;
|
||||
tsmiShowCrosshair.Click += (sender, e) => config.ShowCrosshair = tsmiShowCrosshair.Checked;
|
||||
tsmiOptions.DropDownItems.Add(tsmiShowCrosshair);
|
||||
}
|
||||
|
||||
cmsContextMenu.Items.Add(new ToolStripSeparator());
|
||||
private void surface_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (!IsCreating)
|
||||
{
|
||||
RegionSelection(e.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ToolStripMenuItem tsmiCloseMenu = new ToolStripMenuItem("Close menu");
|
||||
tsmiCloseMenu.Click += (sender, e) => cmsContextMenu.Close();
|
||||
cmsContextMenu.Items.Add(tsmiCloseMenu);
|
||||
private void surface_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (IsMoving || IsCreating)
|
||||
{
|
||||
EndRegionSelection();
|
||||
}
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
if (IsCreating)
|
||||
{
|
||||
EndRegionSelection();
|
||||
}
|
||||
else
|
||||
{
|
||||
cmsContextMenu.Show(surface, e.Location.Add(-cmsContextMenu.Width / 2, -10));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void surface_KeyDown(object sender, KeyEventArgs e)
|
||||
|
@ -563,39 +600,6 @@ public WindowInfo FindSelectedWindowInfo(Point mousePosition)
|
|||
return null;
|
||||
}
|
||||
|
||||
private void surface_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (!IsCreating)
|
||||
{
|
||||
RegionSelection(e.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void surface_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
if (IsMoving || IsCreating)
|
||||
{
|
||||
EndRegionSelection();
|
||||
}
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
if (IsCreating)
|
||||
{
|
||||
EndRegionSelection();
|
||||
}
|
||||
else
|
||||
{
|
||||
cmsContextMenu.Show(surface, e.Location);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RegionSelection(Point location)
|
||||
{
|
||||
if (ResizeManager.IsCursorOnNode())
|
||||
|
|
Loading…
Reference in a new issue