mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Added configurable mouse click actions for region capture
This commit is contained in:
parent
b10eba0950
commit
5bab479325
5 changed files with 90 additions and 12 deletions
|
@ -155,6 +155,26 @@ public enum RectangleRegionMode
|
|||
OneClick
|
||||
}
|
||||
|
||||
public enum RegionCaptureAction
|
||||
{
|
||||
[Description("Do nothing")]
|
||||
None,
|
||||
[Description("Cancel capture")]
|
||||
CancelCapture,
|
||||
[Description("Remove shape or cancel capture")]
|
||||
RemoveShapeCancelCapture,
|
||||
[Description("Remove shape")]
|
||||
RemoveShape,
|
||||
[Description("Open options menu")]
|
||||
OpenOptionsMenu,
|
||||
[Description("Swap tool type")]
|
||||
SwapToolType,
|
||||
[Description("Capture fullscreen")]
|
||||
CaptureFullscreen,
|
||||
[Description("Capture active monitor")]
|
||||
CaptureActiveMonitor
|
||||
}
|
||||
|
||||
public enum ShapeType
|
||||
{
|
||||
[Description("Region: Rectangle")]
|
||||
|
|
|
@ -827,10 +827,9 @@ private void form_MouseUp(object sender, MouseEventArgs e)
|
|||
DeleteCurrentShape();
|
||||
EndRegionSelection();
|
||||
}
|
||||
else if (form.Mode == RectangleRegionMode.Annotation && cmsContextMenu != null)
|
||||
else if (form.Mode == RectangleRegionMode.Annotation)
|
||||
{
|
||||
cmsContextMenu.Show(form, e.Location.Add(-10, -10));
|
||||
Config.ShowMenuTip = false;
|
||||
RunRegionCaptureAction(Config.MouseRightClickAction);
|
||||
}
|
||||
else if (IsShapeIntersect())
|
||||
{
|
||||
|
@ -843,14 +842,15 @@ private void form_MouseUp(object sender, MouseEventArgs e)
|
|||
}
|
||||
else if (e.Button == MouseButtons.Middle)
|
||||
{
|
||||
form.Close(RegionResult.Close);
|
||||
RunRegionCaptureAction(Config.MouseMiddleClickAction);
|
||||
}
|
||||
else if (e.Button == MouseButtons.XButton1)
|
||||
{
|
||||
if (form.Mode == RectangleRegionMode.Annotation)
|
||||
{
|
||||
SwapShapeType();
|
||||
}
|
||||
RunRegionCaptureAction(Config.Mouse4ClickAction);
|
||||
}
|
||||
else if (e.Button == MouseButtons.XButton2)
|
||||
{
|
||||
RunRegionCaptureAction(Config.Mouse5ClickAction);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -993,6 +993,51 @@ private void form_KeyUp(object sender, KeyEventArgs e)
|
|||
}
|
||||
}
|
||||
|
||||
private void RunRegionCaptureAction(RegionCaptureAction action)
|
||||
{
|
||||
switch (action)
|
||||
{
|
||||
case RegionCaptureAction.CancelCapture:
|
||||
form.Close(RegionResult.Close);
|
||||
break;
|
||||
case RegionCaptureAction.RemoveShapeCancelCapture:
|
||||
if (IsShapeIntersect())
|
||||
{
|
||||
DeleteIntersectShape();
|
||||
}
|
||||
else
|
||||
{
|
||||
form.Close(RegionResult.Close);
|
||||
}
|
||||
break;
|
||||
case RegionCaptureAction.RemoveShape:
|
||||
if (IsShapeIntersect())
|
||||
{
|
||||
DeleteIntersectShape();
|
||||
}
|
||||
break;
|
||||
case RegionCaptureAction.OpenOptionsMenu:
|
||||
if (form.Mode == RectangleRegionMode.Annotation && cmsContextMenu != null)
|
||||
{
|
||||
cmsContextMenu.Show(form, InputManager.MousePosition0Based.Add(-10, -10));
|
||||
Config.ShowMenuTip = false;
|
||||
}
|
||||
break;
|
||||
case RegionCaptureAction.SwapToolType:
|
||||
if (form.Mode == RectangleRegionMode.Annotation)
|
||||
{
|
||||
SwapShapeType();
|
||||
}
|
||||
break;
|
||||
case RegionCaptureAction.CaptureFullscreen:
|
||||
form.Close(RegionResult.Fullscreen);
|
||||
break;
|
||||
case RegionCaptureAction.CaptureActiveMonitor:
|
||||
form.Close(RegionResult.ActiveMonitor);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
BaseShape shape = CurrentShape;
|
||||
|
|
|
@ -37,6 +37,18 @@ public class SurfaceOptions
|
|||
[DefaultValue(true), Description("Allow screenshot capture as soon as the mouse is released. This disables the ability to capture multiple shapes and to move and/or resize them.")]
|
||||
public bool QuickCrop { get; set; }
|
||||
|
||||
[DefaultValue(RegionCaptureAction.OpenOptionsMenu), Description("What should happen when you right click in region capture?"), TypeConverter(typeof(EnumDescriptionConverter))]
|
||||
public RegionCaptureAction MouseRightClickAction { get; set; }
|
||||
|
||||
[DefaultValue(RegionCaptureAction.CancelCapture), Description("What should happen when you middle click in region capture?"), TypeConverter(typeof(EnumDescriptionConverter))]
|
||||
public RegionCaptureAction MouseMiddleClickAction { get; set; }
|
||||
|
||||
[DefaultValue(RegionCaptureAction.SwapToolType), Description("What should happen when you mouse 4 click in region capture?"), TypeConverter(typeof(EnumDescriptionConverter))]
|
||||
public RegionCaptureAction Mouse4ClickAction { get; set; }
|
||||
|
||||
[DefaultValue(RegionCaptureAction.CaptureFullscreen), Description("What should happen when you mouse 5 click in region capture?"), TypeConverter(typeof(EnumDescriptionConverter))]
|
||||
public RegionCaptureAction Mouse5ClickAction { get; set; }
|
||||
|
||||
[DefaultValue(true), Description("If annotation is disabled then right click will cancel screen capture instead of opening options menu.")]
|
||||
public bool AnnotationEnabled { get; set; }
|
||||
|
||||
|
|
1
ShareX/Forms/TaskSettingsForm.Designer.cs
generated
1
ShareX/Forms/TaskSettingsForm.Designer.cs
generated
|
@ -1616,6 +1616,7 @@ private void InitializeComponent()
|
|||
this.Controls.Add(this.tcTaskSettings);
|
||||
this.Controls.Add(this.tttvMain);
|
||||
this.Name = "TaskSettingsForm";
|
||||
this.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide;
|
||||
this.Resize += new System.EventHandler(this.TaskSettingsForm_Resize);
|
||||
this.tcTaskSettings.ResumeLayout(false);
|
||||
this.tpTask.ResumeLayout(false);
|
||||
|
|
|
@ -1067,7 +1067,7 @@
|
|||
</data>
|
||||
<data name="lblImageJPEGQualityHint.Text" xml:space="preserve">
|
||||
<value>0 - 100</value>
|
||||
<comment>@Invariant</comment></data>
|
||||
</data>
|
||||
<data name=">>lblImageJPEGQualityHint.Name" xml:space="preserve">
|
||||
<value>lblImageJPEGQualityHint</value>
|
||||
</data>
|
||||
|
@ -1811,7 +1811,7 @@
|
|||
</data>
|
||||
<data name="lblCaptureCustomRegionY.Text" xml:space="preserve">
|
||||
<value>Y</value>
|
||||
<comment>@Invariant</comment></data>
|
||||
</data>
|
||||
<data name=">>lblCaptureCustomRegionY.Name" xml:space="preserve">
|
||||
<value>lblCaptureCustomRegionY</value>
|
||||
</data>
|
||||
|
@ -1841,7 +1841,7 @@
|
|||
</data>
|
||||
<data name="lblCaptureCustomRegionX.Text" xml:space="preserve">
|
||||
<value>X</value>
|
||||
<comment>@Invariant</comment></data>
|
||||
</data>
|
||||
<data name=">>lblCaptureCustomRegionX.Name" xml:space="preserve">
|
||||
<value>lblCaptureCustomRegionX</value>
|
||||
</data>
|
||||
|
@ -3020,7 +3020,7 @@
|
|||
</data>
|
||||
<data name="lblAutoIncrementNumber.Text" xml:space="preserve">
|
||||
<value>0</value>
|
||||
<comment>@Invariant</comment></data>
|
||||
</data>
|
||||
<data name=">>lblAutoIncrementNumber.Name" xml:space="preserve">
|
||||
<value>lblAutoIncrementNumber</value>
|
||||
</data>
|
||||
|
|
Loading…
Reference in a new issue