mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
Added options sub menu to region capture
This commit is contained in:
parent
61887a6b32
commit
9531740b2d
4 changed files with 108 additions and 54 deletions
|
@ -37,11 +37,12 @@ private void InitializeComponent()
|
|||
//
|
||||
// flpMain
|
||||
//
|
||||
this.flpMain.AutoSize = true;
|
||||
this.flpMain.Controls.Add(this.lblText);
|
||||
this.flpMain.Controls.Add(this.nudValue);
|
||||
this.flpMain.Location = new System.Drawing.Point(0, 0);
|
||||
this.flpMain.Name = "flpMain";
|
||||
this.flpMain.Size = new System.Drawing.Size(173, 26);
|
||||
this.flpMain.Size = new System.Drawing.Size(99, 26);
|
||||
this.flpMain.TabIndex = 0;
|
||||
this.flpMain.WrapContents = false;
|
||||
//
|
||||
|
@ -58,10 +59,10 @@ private void InitializeComponent()
|
|||
//
|
||||
// nudValue
|
||||
//
|
||||
this.nudValue.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.nudValue.Anchor = System.Windows.Forms.AnchorStyles.Left;
|
||||
this.nudValue.Location = new System.Drawing.Point(41, 3);
|
||||
this.nudValue.Name = "nudValue";
|
||||
this.nudValue.Size = new System.Drawing.Size(68, 20);
|
||||
this.nudValue.Size = new System.Drawing.Size(55, 20);
|
||||
this.nudValue.TabIndex = 1;
|
||||
this.nudValue.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
//
|
||||
|
@ -72,11 +73,12 @@ private void InitializeComponent()
|
|||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.Controls.Add(this.flpMain);
|
||||
this.Name = "LabeledNumericUpDown";
|
||||
this.Size = new System.Drawing.Size(173, 26);
|
||||
this.Size = new System.Drawing.Size(100, 26);
|
||||
this.flpMain.ResumeLayout(false);
|
||||
this.flpMain.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.nudValue)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -84,6 +84,18 @@ public decimal Minimum
|
|||
}
|
||||
}
|
||||
|
||||
public decimal Increment
|
||||
{
|
||||
get
|
||||
{
|
||||
return nudValue.Increment;
|
||||
}
|
||||
set
|
||||
{
|
||||
nudValue.Increment = value;
|
||||
}
|
||||
}
|
||||
|
||||
public EventHandler ValueChanged;
|
||||
|
||||
public LabeledNumericUpDown()
|
||||
|
|
|
@ -77,8 +77,6 @@ public Color CurrentColor
|
|||
|
||||
public RectangleRegionForm()
|
||||
{
|
||||
AreaManager = new AreaManager(this);
|
||||
|
||||
KeyDown += RectangleRegion_KeyDown;
|
||||
MouseDown += RectangleRegion_MouseDown;
|
||||
MouseWheel += RectangleRegion_MouseWheel;
|
||||
|
@ -170,6 +168,7 @@ public override void Prepare()
|
|||
|
||||
if (Config != null)
|
||||
{
|
||||
AreaManager = new AreaManager(this);
|
||||
AreaManager.WindowCaptureMode = Config.DetectWindows;
|
||||
AreaManager.IncludeControls = Config.DetectControls;
|
||||
|
||||
|
@ -185,13 +184,13 @@ public override void Prepare()
|
|||
AreaManager.Windows = wla.GetWindowInfoListAsync(5000);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (Config.UseCustomInfoText || ScreenColorPickerMode)
|
||||
{
|
||||
bmpSurfaceImage = new Bitmap(SurfaceImage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override WindowInfo GetWindowInfo()
|
||||
{
|
||||
|
|
|
@ -112,7 +112,7 @@ public bool IsCurrentShapeTypeRegion
|
|||
}
|
||||
|
||||
public Color BorderColor { get; set; } = Color.Red;
|
||||
public int BorderSize { get; set; } = 1;
|
||||
public int BorderSize { get; set; } = 2;
|
||||
public Color FillColor { get; set; } = Color.Transparent;
|
||||
|
||||
public float RoundedRectangleRadius { get; set; } = 15;
|
||||
|
@ -143,13 +143,15 @@ public bool IsResizing
|
|||
public int MinimumSize { get; set; } = 3;
|
||||
|
||||
private RectangleRegionForm surface;
|
||||
private ContextMenuStrip cmsShapeMenu;
|
||||
private SurfaceOptions config;
|
||||
private ContextMenuStrip cmsContextMenu;
|
||||
|
||||
public AreaManager(RectangleRegionForm surface)
|
||||
{
|
||||
this.surface = surface;
|
||||
config = surface.Config;
|
||||
|
||||
CurrentShapeType = surface.Config.CurrentShapeType;
|
||||
//CurrentShapeType = config.CurrentShapeType;
|
||||
|
||||
ResizeManager = new ResizeManager(surface, this);
|
||||
|
||||
|
@ -158,17 +160,17 @@ public AreaManager(RectangleRegionForm surface)
|
|||
surface.KeyDown += surface_KeyDown;
|
||||
surface.KeyUp += surface_KeyUp;
|
||||
|
||||
CreateShapeMenu();
|
||||
CreateContextMenu();
|
||||
}
|
||||
|
||||
private void CreateShapeMenu()
|
||||
private void CreateContextMenu()
|
||||
{
|
||||
cmsShapeMenu = new ContextMenuStrip();
|
||||
cmsShapeMenu.KeyDown += (sender, e) =>
|
||||
cmsContextMenu = new ContextMenuStrip();
|
||||
cmsContextMenu.KeyDown += (sender, e) =>
|
||||
{
|
||||
if (e.KeyCode == Keys.Space)
|
||||
{
|
||||
cmsShapeMenu.Close();
|
||||
cmsContextMenu.Close();
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -181,10 +183,10 @@ private void CreateShapeMenu()
|
|||
tsmiShapeType.RadioCheck();
|
||||
ChangeCurrentShapeType(shapeType);
|
||||
};
|
||||
cmsShapeMenu.Items.Add(tsmiShapeType);
|
||||
cmsContextMenu.Items.Add(tsmiShapeType);
|
||||
}
|
||||
|
||||
cmsShapeMenu.Items.Add(new ToolStripSeparator());
|
||||
cmsContextMenu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
ToolStripMenuItem tsmiChangeBorderColor = new ToolStripMenuItem("Border color...");
|
||||
tsmiChangeBorderColor.Click += (sender, e) =>
|
||||
|
@ -203,22 +205,15 @@ private void CreateShapeMenu()
|
|||
surface.Resume();
|
||||
};
|
||||
tsmiChangeBorderColor.Image = ImageHelpers.CreateColorPickerIcon(BorderColor, new Rectangle(0, 0, 16, 16));
|
||||
cmsShapeMenu.Items.Add(tsmiChangeBorderColor);
|
||||
cmsContextMenu.Items.Add(tsmiChangeBorderColor);
|
||||
|
||||
ToolStripLabel tslChangeBorderSize = new ToolStripLabel("Border size:");
|
||||
cmsShapeMenu.Items.Add(tslChangeBorderSize);
|
||||
|
||||
ToolStripComboBox tscbBorderSize = new ToolStripComboBox();
|
||||
tscbBorderSize.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
|
||||
for (int i = 1; i <= 10; i++)
|
||||
{
|
||||
tscbBorderSize.Items.Add(i);
|
||||
}
|
||||
|
||||
tscbBorderSize.SelectedIndexChanged += (sender, e) => BorderSize = tscbBorderSize.SelectedIndex + 1;
|
||||
tscbBorderSize.SelectedIndex = (BorderSize - 1).Between(0, tscbBorderSize.Items.Count - 1);
|
||||
cmsShapeMenu.Items.Add(tscbBorderSize);
|
||||
ToolStripLabeledNumericUpDown tslnudBorderSize = new ToolStripLabeledNumericUpDown();
|
||||
tslnudBorderSize.LabeledNumericUpDownControl.Text = "Border size:";
|
||||
tslnudBorderSize.LabeledNumericUpDownControl.Minimum = 1;
|
||||
tslnudBorderSize.LabeledNumericUpDownControl.Maximum = 20;
|
||||
tslnudBorderSize.LabeledNumericUpDownControl.Value = BorderSize;
|
||||
tslnudBorderSize.LabeledNumericUpDownControl.ValueChanged = (sender, e) => BorderSize = (int)tslnudBorderSize.LabeledNumericUpDownControl.Value;
|
||||
cmsContextMenu.Items.Add(tslnudBorderSize);
|
||||
|
||||
ToolStripMenuItem tsmiChangeFillColor = new ToolStripMenuItem("Fill color...");
|
||||
tsmiChangeFillColor.Click += (sender, e) =>
|
||||
|
@ -237,16 +232,16 @@ private void CreateShapeMenu()
|
|||
surface.Resume();
|
||||
};
|
||||
tsmiChangeFillColor.Image = ImageHelpers.CreateColorPickerIcon(FillColor, new Rectangle(0, 0, 16, 16));
|
||||
cmsShapeMenu.Items.Add(tsmiChangeFillColor);
|
||||
cmsContextMenu.Items.Add(tsmiChangeFillColor);
|
||||
|
||||
cmsShapeMenu.Items.Add(new ToolStripSeparator());
|
||||
cmsContextMenu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
ToolStripMenuItem tsmiFullscreenCapture = new ToolStripMenuItem("Capture fullscreen");
|
||||
tsmiFullscreenCapture.Click += (sender, e) => surface.Close(SurfaceResult.Fullscreen);
|
||||
cmsShapeMenu.Items.Add(tsmiFullscreenCapture);
|
||||
cmsContextMenu.Items.Add(tsmiFullscreenCapture);
|
||||
|
||||
ToolStripMenuItem tsmiMonitorCapture = new ToolStripMenuItem("Capture monitor");
|
||||
cmsShapeMenu.Items.Add(tsmiMonitorCapture);
|
||||
cmsContextMenu.Items.Add(tsmiMonitorCapture);
|
||||
|
||||
tsmiMonitorCapture.DropDownItems.Clear();
|
||||
|
||||
|
@ -266,13 +261,59 @@ private void CreateShapeMenu()
|
|||
|
||||
ToolStripMenuItem tsmiActiveMonitorCapture = new ToolStripMenuItem("Capture active monitor");
|
||||
tsmiActiveMonitorCapture.Click += (sender, e) => surface.Close(SurfaceResult.ActiveMonitor);
|
||||
cmsShapeMenu.Items.Add(tsmiActiveMonitorCapture);
|
||||
cmsContextMenu.Items.Add(tsmiActiveMonitorCapture);
|
||||
|
||||
cmsShapeMenu.Items.Add(new ToolStripSeparator());
|
||||
cmsContextMenu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
ToolStripMenuItem tsmiCloseMenu = new ToolStripMenuItem("Close");
|
||||
tsmiCloseMenu.Click += (sender, e) => cmsShapeMenu.Close();
|
||||
cmsShapeMenu.Items.Add(tsmiCloseMenu);
|
||||
ToolStripMenuItem tsmiOptions = new ToolStripMenuItem("Options");
|
||||
cmsContextMenu.Items.Add(tsmiOptions);
|
||||
|
||||
ToolStripMenuItem tsmiQuickCrop = new ToolStripMenuItem("Multi region mode");
|
||||
tsmiQuickCrop.Checked = !config.QuickCrop;
|
||||
tsmiQuickCrop.CheckOnClick = true;
|
||||
tsmiQuickCrop.Click += (sender, e) => config.QuickCrop = !tsmiQuickCrop.Checked;
|
||||
tsmiOptions.DropDownItems.Add(tsmiQuickCrop);
|
||||
|
||||
ToolStripMenuItem tsmiShowInfo = new ToolStripMenuItem("Position and size info");
|
||||
tsmiShowInfo.Checked = config.ShowInfo;
|
||||
tsmiShowInfo.CheckOnClick = true;
|
||||
tsmiShowInfo.Click += (sender, e) => config.ShowInfo = tsmiShowInfo.Checked;
|
||||
tsmiOptions.DropDownItems.Add(tsmiShowInfo);
|
||||
|
||||
ToolStripMenuItem tsmiShowMagnifier = new ToolStripMenuItem("Magnifier");
|
||||
tsmiShowMagnifier.Checked = config.ShowMagnifier;
|
||||
tsmiShowMagnifier.CheckOnClick = true;
|
||||
tsmiShowMagnifier.Click += (sender, e) => config.ShowMagnifier = tsmiShowMagnifier.Checked;
|
||||
tsmiOptions.DropDownItems.Add(tsmiShowMagnifier);
|
||||
|
||||
ToolStripLabeledNumericUpDown tslnudMagnifierPixelCount = new ToolStripLabeledNumericUpDown();
|
||||
tslnudMagnifierPixelCount.LabeledNumericUpDownControl.Text = "Magnifier pixel count:";
|
||||
tslnudMagnifierPixelCount.LabeledNumericUpDownControl.Minimum = 1;
|
||||
tslnudMagnifierPixelCount.LabeledNumericUpDownControl.Maximum = 35;
|
||||
tslnudMagnifierPixelCount.LabeledNumericUpDownControl.Increment = 2;
|
||||
tslnudMagnifierPixelCount.LabeledNumericUpDownControl.Value = config.MagnifierPixelCount;
|
||||
tslnudMagnifierPixelCount.LabeledNumericUpDownControl.ValueChanged = (sender, e) => config.MagnifierPixelCount = (int)tslnudMagnifierPixelCount.LabeledNumericUpDownControl.Value;
|
||||
tsmiOptions.DropDownItems.Add(tslnudMagnifierPixelCount);
|
||||
|
||||
ToolStripLabeledNumericUpDown tslnudMagnifierPixelSize = new ToolStripLabeledNumericUpDown();
|
||||
tslnudMagnifierPixelSize.LabeledNumericUpDownControl.Text = "Magnifier pixel size:";
|
||||
tslnudMagnifierPixelSize.LabeledNumericUpDownControl.Minimum = 2;
|
||||
tslnudMagnifierPixelSize.LabeledNumericUpDownControl.Maximum = 30;
|
||||
tslnudMagnifierPixelSize.LabeledNumericUpDownControl.Value = config.MagnifierPixelSize;
|
||||
tslnudMagnifierPixelSize.LabeledNumericUpDownControl.ValueChanged = (sender, e) => config.MagnifierPixelSize = (int)tslnudMagnifierPixelSize.LabeledNumericUpDownControl.Value;
|
||||
tsmiOptions.DropDownItems.Add(tslnudMagnifierPixelSize);
|
||||
|
||||
ToolStripMenuItem tsmiShowCrosshair = new ToolStripMenuItem("Screen wide crosshair");
|
||||
tsmiShowCrosshair.Checked = config.ShowCrosshair;
|
||||
tsmiShowCrosshair.CheckOnClick = true;
|
||||
tsmiShowCrosshair.Click += (sender, e) => config.ShowCrosshair = tsmiShowCrosshair.Checked;
|
||||
tsmiOptions.DropDownItems.Add(tsmiShowCrosshair);
|
||||
|
||||
cmsContextMenu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
ToolStripMenuItem tsmiCloseMenu = new ToolStripMenuItem("Close menu");
|
||||
tsmiCloseMenu.Click += (sender, e) => cmsContextMenu.Close();
|
||||
cmsContextMenu.Items.Add(tsmiCloseMenu);
|
||||
}
|
||||
|
||||
private void surface_KeyDown(object sender, KeyEventArgs e)
|
||||
|
@ -365,7 +406,7 @@ private void surface_KeyDown(object sender, KeyEventArgs e)
|
|||
}
|
||||
break;
|
||||
case Keys.Space:
|
||||
cmsShapeMenu.Show(Cursor.Position.X, Cursor.Position.Y);
|
||||
cmsContextMenu.Show(Cursor.Position.X, Cursor.Position.Y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -373,7 +414,7 @@ private void surface_KeyDown(object sender, KeyEventArgs e)
|
|||
private void ChangeCurrentShapeType(ShapeType shapeType)
|
||||
{
|
||||
CurrentShapeType = shapeType;
|
||||
surface.Config.CurrentShapeType = shapeType;
|
||||
//config.CurrentShapeType = shapeType;
|
||||
DeselectArea();
|
||||
}
|
||||
|
||||
|
@ -462,10 +503,10 @@ private Point SnapPosition(Point posOnClick, Point posCurrent)
|
|||
Rectangle currentRect = CaptureHelpers.CreateRectangle(posOnClick, posCurrent);
|
||||
Point newPosition = posCurrent;
|
||||
|
||||
foreach (SnapSize size in surface.Config.SnapSizes)
|
||||
foreach (SnapSize size in config.SnapSizes)
|
||||
{
|
||||
if (currentRect.Width.IsBetween(size.Width - surface.Config.SnapDistance, size.Width + surface.Config.SnapDistance) ||
|
||||
currentRect.Height.IsBetween(size.Height - surface.Config.SnapDistance, size.Height + surface.Config.SnapDistance))
|
||||
if (currentRect.Width.IsBetween(size.Width - config.SnapDistance, size.Width + config.SnapDistance) ||
|
||||
currentRect.Height.IsBetween(size.Height - config.SnapDistance, size.Height + config.SnapDistance))
|
||||
{
|
||||
newPosition = CaptureHelpers.CalculateNewPosition(posOnClick, posCurrent, size);
|
||||
break;
|
||||
|
@ -586,10 +627,10 @@ private void RegionSelection(Point location)
|
|||
|
||||
Rectangle rect;
|
||||
|
||||
if (surface.Config.IsFixedSize)
|
||||
if (config.IsFixedSize)
|
||||
{
|
||||
IsMoving = true;
|
||||
rect = new Rectangle(new Point(location.X - surface.Config.FixedSize.Width / 2, location.Y - surface.Config.FixedSize.Height / 2), surface.Config.FixedSize);
|
||||
rect = new Rectangle(new Point(location.X - config.FixedSize.Width / 2, location.Y - config.FixedSize.Height / 2), config.FixedSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -613,7 +654,7 @@ private void EndRegionSelection()
|
|||
RemoveCurrentArea();
|
||||
CheckHover();
|
||||
}
|
||||
else if (surface.Config.QuickCrop && IsCurrentShapeTypeRegion)
|
||||
else if (config.QuickCrop && IsCurrentShapeTypeRegion)
|
||||
{
|
||||
surface.UpdateRegionPath();
|
||||
surface.Close(SurfaceResult.Region);
|
||||
|
@ -628,7 +669,7 @@ private void EndRegionSelection()
|
|||
{
|
||||
AddRegionShape(CurrentHoverRectangle);
|
||||
|
||||
if (surface.Config.QuickCrop && IsCurrentShapeTypeRegion)
|
||||
if (config.QuickCrop && IsCurrentShapeTypeRegion)
|
||||
{
|
||||
surface.UpdateRegionPath();
|
||||
surface.Close(SurfaceResult.Region);
|
||||
|
@ -716,7 +757,7 @@ public BaseShape CreateRegionShape(Rectangle rect)
|
|||
|
||||
private void SelectArea()
|
||||
{
|
||||
if (!CurrentRectangle.IsEmpty && !surface.Config.IsFixedSize)
|
||||
if (!CurrentRectangle.IsEmpty && !config.IsFixedSize)
|
||||
{
|
||||
ResizeManager.Show();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue