mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Adding menu form inside ShapeManager
This commit is contained in:
parent
9badbe7fdb
commit
f0f8d0711c
6 changed files with 273 additions and 158 deletions
57
ShareX.HelpersLib/Controls/ToolStripEx.cs
Normal file
57
ShareX.HelpersLib/Controls/ToolStripEx.cs
Normal file
|
@ -0,0 +1,57 @@
|
|||
#region License Information (GPL v3)
|
||||
|
||||
/*
|
||||
ShareX - A program that allows you to take screenshots and share any file type
|
||||
Copyright (c) 2007-2016 ShareX Team
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
Optionally you can also view the license at <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#endregion License Information (GPL v3)
|
||||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace ShareX.HelpersLib
|
||||
{
|
||||
public class ToolStripEx : ToolStrip
|
||||
{
|
||||
private bool clickThrough = false;
|
||||
|
||||
public bool ClickThrough
|
||||
{
|
||||
get
|
||||
{
|
||||
return clickThrough;
|
||||
}
|
||||
set
|
||||
{
|
||||
clickThrough = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m)
|
||||
{
|
||||
base.WndProc(ref m);
|
||||
|
||||
if (clickThrough && m.Msg == (int)WindowsMessages.MOUSEACTIVATE && m.Result == (IntPtr)NativeMethods.MA_ACTIVATEANDEAT)
|
||||
{
|
||||
m.Result = (IntPtr)NativeMethods.MA_ACTIVATE;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -317,6 +317,21 @@ public static void RadioCheck(this ToolStripMenuItem tsmi)
|
|||
tsmi.Checked = true;
|
||||
}
|
||||
|
||||
public static void RadioCheck(this ToolStripButton tsb)
|
||||
{
|
||||
ToolStrip parent = tsb.GetCurrentParent();
|
||||
|
||||
foreach (ToolStripButton tsbParent in parent.Items.OfType<ToolStripButton>())
|
||||
{
|
||||
if (tsbParent != tsb)
|
||||
{
|
||||
tsbParent.Checked = false;
|
||||
}
|
||||
}
|
||||
|
||||
tsb.Checked = true;
|
||||
}
|
||||
|
||||
public static void InvokeSafe(this Control control, Action action)
|
||||
{
|
||||
if (control != null && !control.IsDisposed)
|
||||
|
|
|
@ -82,5 +82,9 @@ public static partial class NativeMethods
|
|||
|
||||
public const uint ECM_FIRST = 0x1500;
|
||||
public const uint EM_SETCUEBANNER = ECM_FIRST + 1;
|
||||
public const uint MA_ACTIVATE = 1;
|
||||
public const uint MA_ACTIVATEANDEAT = 2;
|
||||
public const uint MA_NOACTIVATE = 3;
|
||||
public const uint MA_NOACTIVATEANDEAT = 4;
|
||||
}
|
||||
}
|
|
@ -84,6 +84,9 @@
|
|||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controls\ToolStripEx.cs">
|
||||
<SubType>Component</SubType>
|
||||
</Compile>
|
||||
<Compile Include="NameParser\CodeMenuEntryActions.cs" />
|
||||
<Compile Include="Automate\AutomateForm.cs">
|
||||
<SubType>Form</SubType>
|
||||
|
|
|
@ -29,6 +29,7 @@ protected override void Dispose(bool disposing)
|
|||
private void InitializeComponent()
|
||||
{
|
||||
this.tsTools = new System.Windows.Forms.ToolStrip();
|
||||
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
|
||||
this.tsbRegionRectangle = new System.Windows.Forms.ToolStripButton();
|
||||
this.tsbRegionRoundedRectangle = new System.Windows.Forms.ToolStripButton();
|
||||
this.tsbRegionEllipse = new System.Windows.Forms.ToolStripButton();
|
||||
|
@ -46,7 +47,6 @@ private void InitializeComponent()
|
|||
this.tsbEffectBlur = new System.Windows.Forms.ToolStripButton();
|
||||
this.tsbEffectPixelate = new System.Windows.Forms.ToolStripButton();
|
||||
this.tsbEffectHighlight = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripLabel1 = new System.Windows.Forms.ToolStripLabel();
|
||||
this.tsTools.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
|
@ -76,18 +76,25 @@ private void InitializeComponent()
|
|||
this.tsbEffectHighlight});
|
||||
this.tsTools.Location = new System.Drawing.Point(0, 0);
|
||||
this.tsTools.Name = "tsTools";
|
||||
this.tsTools.Padding = new System.Windows.Forms.Padding(0, 0, 0, 0);
|
||||
this.tsTools.Padding = new System.Windows.Forms.Padding(0);
|
||||
this.tsTools.Size = new System.Drawing.Size(552, 28);
|
||||
this.tsTools.TabIndex = 0;
|
||||
this.tsTools.Text = "toolStrip1";
|
||||
//
|
||||
// toolStripLabel1
|
||||
//
|
||||
this.toolStripLabel1.Margin = new System.Windows.Forms.Padding(0, 1, 2, 2);
|
||||
this.toolStripLabel1.Name = "toolStripLabel1";
|
||||
this.toolStripLabel1.Size = new System.Drawing.Size(35, 25);
|
||||
this.toolStripLabel1.Text = "Tools";
|
||||
//
|
||||
// tsbRegionRectangle
|
||||
//
|
||||
this.tsbRegionRectangle.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.tsbRegionRectangle.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shape_region;
|
||||
this.tsbRegionRectangle.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbRegionRectangle.Name = "tsbRegionRectangle";
|
||||
this.tsbRegionRectangle.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbRegionRectangle.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbRegionRectangle.Text = "Region: Rectangle";
|
||||
//
|
||||
// tsbRegionRoundedRectangle
|
||||
|
@ -96,7 +103,7 @@ private void InitializeComponent()
|
|||
this.tsbRegionRoundedRectangle.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shape_round_region;
|
||||
this.tsbRegionRoundedRectangle.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbRegionRoundedRectangle.Name = "tsbRegionRoundedRectangle";
|
||||
this.tsbRegionRoundedRectangle.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbRegionRoundedRectangle.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbRegionRoundedRectangle.Text = "Region: Rounded rectangle";
|
||||
//
|
||||
// tsbRegionEllipse
|
||||
|
@ -105,7 +112,7 @@ private void InitializeComponent()
|
|||
this.tsbRegionEllipse.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shape_ellipse_region;
|
||||
this.tsbRegionEllipse.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbRegionEllipse.Name = "tsbRegionEllipse";
|
||||
this.tsbRegionEllipse.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbRegionEllipse.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbRegionEllipse.Text = "Region: Ellipse";
|
||||
//
|
||||
// tsbRegionFreehand
|
||||
|
@ -114,7 +121,7 @@ private void InitializeComponent()
|
|||
this.tsbRegionFreehand.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shape_polygon;
|
||||
this.tsbRegionFreehand.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbRegionFreehand.Name = "tsbRegionFreehand";
|
||||
this.tsbRegionFreehand.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbRegionFreehand.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbRegionFreehand.Text = "Region: Freehand";
|
||||
//
|
||||
// tsbDrawingRectangle
|
||||
|
@ -123,7 +130,7 @@ private void InitializeComponent()
|
|||
this.tsbDrawingRectangle.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shape;
|
||||
this.tsbDrawingRectangle.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbDrawingRectangle.Name = "tsbDrawingRectangle";
|
||||
this.tsbDrawingRectangle.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbDrawingRectangle.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbDrawingRectangle.Text = "Drawing: Rectangle";
|
||||
//
|
||||
// tsbDrawingRoundedRectangle
|
||||
|
@ -132,7 +139,7 @@ private void InitializeComponent()
|
|||
this.tsbDrawingRoundedRectangle.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shape_round;
|
||||
this.tsbDrawingRoundedRectangle.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbDrawingRoundedRectangle.Name = "tsbDrawingRoundedRectangle";
|
||||
this.tsbDrawingRoundedRectangle.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbDrawingRoundedRectangle.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbDrawingRoundedRectangle.Text = "Drawing: Rounded rectangle";
|
||||
//
|
||||
// tsbDrawingEllipse
|
||||
|
@ -141,7 +148,7 @@ private void InitializeComponent()
|
|||
this.tsbDrawingEllipse.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shape_ellipse;
|
||||
this.tsbDrawingEllipse.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbDrawingEllipse.Name = "tsbDrawingEllipse";
|
||||
this.tsbDrawingEllipse.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbDrawingEllipse.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbDrawingEllipse.Text = "Drawing: Ellipse";
|
||||
//
|
||||
// tsbDrawingFreehand
|
||||
|
@ -150,7 +157,7 @@ private void InitializeComponent()
|
|||
this.tsbDrawingFreehand.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shape_curve;
|
||||
this.tsbDrawingFreehand.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbDrawingFreehand.Name = "tsbDrawingFreehand";
|
||||
this.tsbDrawingFreehand.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbDrawingFreehand.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbDrawingFreehand.Text = "Drawing: Freehand";
|
||||
//
|
||||
// tsbDrawingLine
|
||||
|
@ -159,7 +166,7 @@ private void InitializeComponent()
|
|||
this.tsbDrawingLine.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shape_line;
|
||||
this.tsbDrawingLine.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbDrawingLine.Name = "tsbDrawingLine";
|
||||
this.tsbDrawingLine.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbDrawingLine.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbDrawingLine.Text = "Drawing: Line";
|
||||
//
|
||||
// tsbDrawingArrow
|
||||
|
@ -168,7 +175,7 @@ private void InitializeComponent()
|
|||
this.tsbDrawingArrow.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shape_arrow;
|
||||
this.tsbDrawingArrow.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbDrawingArrow.Name = "tsbDrawingArrow";
|
||||
this.tsbDrawingArrow.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbDrawingArrow.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbDrawingArrow.Text = "Drawing: Arrow";
|
||||
//
|
||||
// tsbDrawingText
|
||||
|
@ -177,7 +184,7 @@ private void InitializeComponent()
|
|||
this.tsbDrawingText.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shape_text;
|
||||
this.tsbDrawingText.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbDrawingText.Name = "tsbDrawingText";
|
||||
this.tsbDrawingText.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbDrawingText.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbDrawingText.Text = "Drawing: Text";
|
||||
//
|
||||
// tsbDrawingSpeechBalloon
|
||||
|
@ -186,7 +193,7 @@ private void InitializeComponent()
|
|||
this.tsbDrawingSpeechBalloon.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.balloon_box_left;
|
||||
this.tsbDrawingSpeechBalloon.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbDrawingSpeechBalloon.Name = "tsbDrawingSpeechBalloon";
|
||||
this.tsbDrawingSpeechBalloon.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbDrawingSpeechBalloon.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbDrawingSpeechBalloon.Text = "Drawing: Speech balloon";
|
||||
//
|
||||
// tsbDrawingStep
|
||||
|
@ -195,7 +202,7 @@ private void InitializeComponent()
|
|||
this.tsbDrawingStep.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.counter_reset;
|
||||
this.tsbDrawingStep.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbDrawingStep.Name = "tsbDrawingStep";
|
||||
this.tsbDrawingStep.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbDrawingStep.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbDrawingStep.Text = "Drawing: Step";
|
||||
//
|
||||
// tsbDrawingImage
|
||||
|
@ -204,7 +211,7 @@ private void InitializeComponent()
|
|||
this.tsbDrawingImage.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.image;
|
||||
this.tsbDrawingImage.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbDrawingImage.Name = "tsbDrawingImage";
|
||||
this.tsbDrawingImage.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbDrawingImage.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbDrawingImage.Text = "Drawing: Image";
|
||||
//
|
||||
// tsbEffectBlur
|
||||
|
@ -213,7 +220,7 @@ private void InitializeComponent()
|
|||
this.tsbEffectBlur.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.layer_shade;
|
||||
this.tsbEffectBlur.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbEffectBlur.Name = "tsbEffectBlur";
|
||||
this.tsbEffectBlur.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbEffectBlur.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbEffectBlur.Text = "Effect: Blur";
|
||||
//
|
||||
// tsbEffectPixelate
|
||||
|
@ -222,7 +229,7 @@ private void InitializeComponent()
|
|||
this.tsbEffectPixelate.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.grid;
|
||||
this.tsbEffectPixelate.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbEffectPixelate.Name = "tsbEffectPixelate";
|
||||
this.tsbEffectPixelate.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbEffectPixelate.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbEffectPixelate.Text = "Effect: Pixelate";
|
||||
//
|
||||
// tsbEffectHighlight
|
||||
|
@ -231,16 +238,9 @@ private void InitializeComponent()
|
|||
this.tsbEffectHighlight.Image = global::ShareX.ScreenCaptureLib.Properties.Resources.highlighter_text;
|
||||
this.tsbEffectHighlight.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsbEffectHighlight.Name = "tsbEffectHighlight";
|
||||
this.tsbEffectHighlight.Size = new System.Drawing.Size(31, 20);
|
||||
this.tsbEffectHighlight.Size = new System.Drawing.Size(23, 25);
|
||||
this.tsbEffectHighlight.Text = "Effect: Highlight";
|
||||
//
|
||||
// toolStripLabel1
|
||||
//
|
||||
this.toolStripLabel1.Margin = new System.Windows.Forms.Padding(0, 1, 2, 2);
|
||||
this.toolStripLabel1.Name = "toolStripLabel1";
|
||||
this.toolStripLabel1.Size = new System.Drawing.Size(35, 25);
|
||||
this.toolStripLabel1.Text = "Tools";
|
||||
//
|
||||
// RegionCaptureMenuForm
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
|
|
|
@ -183,9 +183,11 @@ public bool NodesVisible
|
|||
public event Action<ShapeType> CurrentShapeTypeChanged;
|
||||
|
||||
private RegionCaptureForm form;
|
||||
private Form menuForm;
|
||||
private ContextMenuStrip cmsContextMenu;
|
||||
private ToolStripSeparator tssObjectOptions, tssShapeOptions;
|
||||
private ToolStripMenuItem tsmiDeleteSelected, tsmiDeleteAll, tsmiBorderColor, tsmiFillColor, tsmiHighlightColor, tsmiQuickCrop;
|
||||
private ToolStripButton tsbDeleteSelected, tsbDeleteAll;
|
||||
private ToolStripMenuItem tsmiBorderColor, tsmiFillColor, tsmiHighlightColor, tsmiQuickCrop;
|
||||
private ToolStripLabeledNumericUpDown tslnudBorderSize, tslnudCornerRadius, tslnudBlurRadius, tslnudPixelateSize;
|
||||
private bool isLeftPressed, isRightPressed, isUpPressed, isDownPressed, allowOptionsMenu;
|
||||
private Stopwatch cmsCloseTimer;
|
||||
|
@ -243,9 +245,167 @@ private void form_Shown(object sender, EventArgs e)
|
|||
|
||||
private void CreateMenu()
|
||||
{
|
||||
RegionCaptureMenuForm menu = new RegionCaptureMenuForm();
|
||||
menu.Location = new Point(100, 100);
|
||||
menu.Show(form);
|
||||
menuForm = new Form()
|
||||
{
|
||||
AutoScaleDimensions = new SizeF(6F, 13F),
|
||||
AutoScaleMode = AutoScaleMode.Font,
|
||||
AutoSize = true,
|
||||
AutoSizeMode = AutoSizeMode.GrowAndShrink,
|
||||
ClientSize = new Size(759, 509),
|
||||
FormBorderStyle = FormBorderStyle.None,
|
||||
Location = new Point(100, 100),
|
||||
ShowInTaskbar = false,
|
||||
Text = "RegionCaptureFormMenu"
|
||||
};
|
||||
|
||||
menuForm.SuspendLayout();
|
||||
|
||||
ToolStripEx tsMain = new ToolStripEx()
|
||||
{
|
||||
AutoSize = false,
|
||||
CanOverflow = false,
|
||||
ClickThrough = true,
|
||||
Dock = DockStyle.None,
|
||||
Location = new Point(0, 0),
|
||||
Padding = new Padding(0, 0, 0, 0),
|
||||
Size = new Size(552, 30),
|
||||
TabIndex = 0,
|
||||
Text = "ToolStrip"
|
||||
};
|
||||
|
||||
menuForm.Controls.Add(tsMain);
|
||||
|
||||
#region Main
|
||||
|
||||
string buttonText;
|
||||
|
||||
if (form.Mode == RegionCaptureMode.Editor)
|
||||
{
|
||||
buttonText = "Cancel annotation";
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonText = Resources.ShapeManager_CreateContextMenu_Cancel_capture;
|
||||
}
|
||||
|
||||
ToolStripButton tsbCancelCapture = new ToolStripButton(buttonText);
|
||||
tsbCancelCapture.DisplayStyle = ToolStripItemDisplayStyle.Image;
|
||||
tsbCancelCapture.Image = Resources.prohibition;
|
||||
tsbCancelCapture.MouseDown += (sender, e) => form.Close();
|
||||
tsMain.Items.Add(tsbCancelCapture);
|
||||
|
||||
#endregion Main
|
||||
|
||||
#region Selected object
|
||||
|
||||
tssObjectOptions = new ToolStripSeparator();
|
||||
tsMain.Items.Add(tssObjectOptions);
|
||||
|
||||
tsbDeleteSelected = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Delete_selected_object);
|
||||
tsbDeleteSelected.DisplayStyle = ToolStripItemDisplayStyle.Image;
|
||||
tsbDeleteSelected.Image = Resources.layer__minus;
|
||||
tsbDeleteSelected.MouseDown += (sender, e) => DeleteCurrentShape();
|
||||
tsMain.Items.Add(tsbDeleteSelected);
|
||||
|
||||
tsbDeleteAll = new ToolStripButton(Resources.ShapeManager_CreateContextMenu_Delete_all_objects);
|
||||
tsbDeleteAll.DisplayStyle = ToolStripItemDisplayStyle.Image;
|
||||
tsbDeleteAll.Image = Resources.minus;
|
||||
tsbDeleteAll.MouseDown += (sender, e) => DeleteAllShapes();
|
||||
tsMain.Items.Add(tsbDeleteAll);
|
||||
|
||||
#endregion Selected object
|
||||
|
||||
#region Tools
|
||||
|
||||
tsMain.Items.Add(new ToolStripSeparator());
|
||||
|
||||
foreach (ShapeType shapeType in Helpers.GetEnums<ShapeType>())
|
||||
{
|
||||
if (form.Mode == RegionCaptureMode.Editor && IsShapeTypeRegion(shapeType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ToolStripButton tsbShapeType = new ToolStripButton(shapeType.GetLocalizedDescription());
|
||||
tsbShapeType.DisplayStyle = ToolStripItemDisplayStyle.Image;
|
||||
|
||||
Image img = null;
|
||||
|
||||
switch (shapeType)
|
||||
{
|
||||
case ShapeType.RegionRectangle:
|
||||
img = Resources.layer_shape_region;
|
||||
break;
|
||||
case ShapeType.RegionRoundedRectangle:
|
||||
img = Resources.layer_shape_round_region;
|
||||
break;
|
||||
case ShapeType.RegionEllipse:
|
||||
img = Resources.layer_shape_ellipse_region;
|
||||
break;
|
||||
case ShapeType.RegionFreehand:
|
||||
img = Resources.layer_shape_polygon;
|
||||
break;
|
||||
case ShapeType.DrawingRectangle:
|
||||
img = Resources.layer_shape;
|
||||
break;
|
||||
case ShapeType.DrawingRoundedRectangle:
|
||||
img = Resources.layer_shape_round;
|
||||
break;
|
||||
case ShapeType.DrawingEllipse:
|
||||
img = Resources.layer_shape_ellipse;
|
||||
break;
|
||||
case ShapeType.DrawingFreehand:
|
||||
img = Resources.layer_shape_curve;
|
||||
break;
|
||||
case ShapeType.DrawingLine:
|
||||
img = Resources.layer_shape_line;
|
||||
break;
|
||||
case ShapeType.DrawingArrow:
|
||||
img = Resources.layer_shape_arrow;
|
||||
break;
|
||||
case ShapeType.DrawingText:
|
||||
img = Resources.layer_shape_text;
|
||||
break;
|
||||
case ShapeType.DrawingSpeechBalloon:
|
||||
img = Resources.balloon_box_left;
|
||||
break;
|
||||
case ShapeType.DrawingStep:
|
||||
img = Resources.counter_reset;
|
||||
break;
|
||||
case ShapeType.DrawingImage:
|
||||
img = Resources.image;
|
||||
break;
|
||||
case ShapeType.EffectBlur:
|
||||
img = Resources.layer_shade;
|
||||
break;
|
||||
case ShapeType.EffectPixelate:
|
||||
img = Resources.grid;
|
||||
break;
|
||||
case ShapeType.EffectHighlight:
|
||||
img = Resources.highlighter_text;
|
||||
break;
|
||||
}
|
||||
|
||||
tsbShapeType.Image = img;
|
||||
tsbShapeType.Checked = shapeType == CurrentShapeType;
|
||||
tsbShapeType.Tag = shapeType;
|
||||
|
||||
tsbShapeType.MouseDown += (sender, e) =>
|
||||
{
|
||||
tsbShapeType.RadioCheck();
|
||||
CurrentShapeType = shapeType;
|
||||
};
|
||||
|
||||
tsMain.Items.Add(tsbShapeType);
|
||||
}
|
||||
|
||||
#endregion Tools
|
||||
|
||||
menuForm.ResumeLayout(false);
|
||||
|
||||
menuForm.Show(form);
|
||||
|
||||
UpdateContextMenu();
|
||||
}
|
||||
|
||||
private void CreateContextMenu()
|
||||
|
@ -319,132 +479,6 @@ private void CreateContextMenu()
|
|||
|
||||
#endregion Editor mode
|
||||
|
||||
#region Main
|
||||
|
||||
string buttonText;
|
||||
|
||||
if (form.Mode == RegionCaptureMode.Editor)
|
||||
{
|
||||
buttonText = "Cancel annotation";
|
||||
}
|
||||
else
|
||||
{
|
||||
buttonText = Resources.ShapeManager_CreateContextMenu_Cancel_capture;
|
||||
}
|
||||
|
||||
ToolStripMenuItem tsmiCancelCapture = new ToolStripMenuItem(buttonText);
|
||||
tsmiCancelCapture.Image = Resources.prohibition;
|
||||
tsmiCancelCapture.Click += (sender, e) => form.Close();
|
||||
cmsContextMenu.Items.Add(tsmiCancelCapture);
|
||||
|
||||
ToolStripMenuItem tsmiCloseMenu = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Close_menu);
|
||||
tsmiCloseMenu.Image = Resources.cross;
|
||||
tsmiCloseMenu.Click += (sender, e) => cmsContextMenu.Close();
|
||||
cmsContextMenu.Items.Add(tsmiCloseMenu);
|
||||
|
||||
#endregion Main
|
||||
|
||||
#region Selected object
|
||||
|
||||
tssObjectOptions = new ToolStripSeparator();
|
||||
cmsContextMenu.Items.Add(tssObjectOptions);
|
||||
|
||||
tsmiDeleteSelected = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Delete_selected_object);
|
||||
tsmiDeleteSelected.Image = Resources.layer__minus;
|
||||
tsmiDeleteSelected.Click += (sender, e) => DeleteCurrentShape();
|
||||
cmsContextMenu.Items.Add(tsmiDeleteSelected);
|
||||
|
||||
tsmiDeleteAll = new ToolStripMenuItem(Resources.ShapeManager_CreateContextMenu_Delete_all_objects);
|
||||
tsmiDeleteAll.Image = Resources.minus;
|
||||
tsmiDeleteAll.Click += (sender, e) => DeleteAllShapes();
|
||||
cmsContextMenu.Items.Add(tsmiDeleteAll);
|
||||
|
||||
#endregion Selected object
|
||||
|
||||
#region Tools
|
||||
|
||||
cmsContextMenu.Items.Add(new ToolStripSeparator());
|
||||
|
||||
foreach (ShapeType shapeType in Helpers.GetEnums<ShapeType>())
|
||||
{
|
||||
if (form.Mode == RegionCaptureMode.Editor && IsShapeTypeRegion(shapeType))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
ToolStripMenuItem tsmiShapeType = new ToolStripMenuItem(shapeType.GetLocalizedDescription());
|
||||
|
||||
Image img = null;
|
||||
|
||||
switch (shapeType)
|
||||
{
|
||||
case ShapeType.RegionRectangle:
|
||||
img = Resources.layer_shape_region;
|
||||
break;
|
||||
case ShapeType.RegionRoundedRectangle:
|
||||
img = Resources.layer_shape_round_region;
|
||||
break;
|
||||
case ShapeType.RegionEllipse:
|
||||
img = Resources.layer_shape_ellipse_region;
|
||||
break;
|
||||
case ShapeType.RegionFreehand:
|
||||
img = Resources.layer_shape_polygon;
|
||||
break;
|
||||
case ShapeType.DrawingRectangle:
|
||||
img = Resources.layer_shape;
|
||||
break;
|
||||
case ShapeType.DrawingRoundedRectangle:
|
||||
img = Resources.layer_shape_round;
|
||||
break;
|
||||
case ShapeType.DrawingEllipse:
|
||||
img = Resources.layer_shape_ellipse;
|
||||
break;
|
||||
case ShapeType.DrawingFreehand:
|
||||
img = Resources.layer_shape_curve;
|
||||
break;
|
||||
case ShapeType.DrawingLine:
|
||||
img = Resources.layer_shape_line;
|
||||
break;
|
||||
case ShapeType.DrawingArrow:
|
||||
img = Resources.layer_shape_arrow;
|
||||
break;
|
||||
case ShapeType.DrawingText:
|
||||
img = Resources.layer_shape_text;
|
||||
break;
|
||||
case ShapeType.DrawingSpeechBalloon:
|
||||
img = Resources.balloon_box_left;
|
||||
break;
|
||||
case ShapeType.DrawingStep:
|
||||
img = Resources.counter_reset;
|
||||
break;
|
||||
case ShapeType.DrawingImage:
|
||||
img = Resources.image;
|
||||
break;
|
||||
case ShapeType.EffectBlur:
|
||||
img = Resources.layer_shade;
|
||||
break;
|
||||
case ShapeType.EffectPixelate:
|
||||
img = Resources.grid;
|
||||
break;
|
||||
case ShapeType.EffectHighlight:
|
||||
img = Resources.highlighter_text;
|
||||
break;
|
||||
}
|
||||
|
||||
tsmiShapeType.Image = img;
|
||||
|
||||
tsmiShapeType.Checked = shapeType == CurrentShapeType;
|
||||
tsmiShapeType.Tag = shapeType;
|
||||
tsmiShapeType.Click += (sender, e) =>
|
||||
{
|
||||
tsmiShapeType.RadioCheck();
|
||||
CurrentShapeType = shapeType;
|
||||
};
|
||||
cmsContextMenu.Items.Add(tsmiShapeType);
|
||||
}
|
||||
|
||||
#endregion Tools
|
||||
|
||||
#region Shape options
|
||||
|
||||
tssShapeOptions = new ToolStripSeparator();
|
||||
|
@ -770,10 +804,12 @@ private void CreateContextMenu()
|
|||
|
||||
private void UpdateContextMenu()
|
||||
{
|
||||
if (menuForm == null) return;
|
||||
|
||||
ShapeType shapeType = CurrentShapeType;
|
||||
|
||||
tssObjectOptions.Visible = tsmiDeleteAll.Visible = Shapes.Count > 0;
|
||||
tsmiDeleteSelected.Visible = CurrentShape != null;
|
||||
tssObjectOptions.Visible = tsbDeleteAll.Visible = Shapes.Count > 0;
|
||||
tsbDeleteSelected.Visible = CurrentShape != null;
|
||||
|
||||
foreach (ToolStripMenuItem tsmi in cmsContextMenu.Items.OfType<ToolStripMenuItem>().Where(x => x.Tag is ShapeType))
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue