Open task menu automatically

This commit is contained in:
Jaex 2022-08-19 20:10:13 +03:00
parent 244883d2f8
commit e2b93615fd
4 changed files with 27 additions and 9 deletions

View file

@ -37,24 +37,36 @@ public class MenuButton : Button
[DefaultValue(false)] [DefaultValue(false)]
public bool ShowMenuUnderCursor { get; set; } public bool ShowMenuUnderCursor { get; set; }
public void OpenMenu()
{
if (Menu != null)
{
OpenMenu(new Point(0, Height));
}
}
public void OpenMenu(Point menuPosition)
{
if (Menu != null)
{
Menu.Show(this, menuPosition);
}
}
protected override void OnMouseDown(MouseEventArgs mevent) protected override void OnMouseDown(MouseEventArgs mevent)
{ {
base.OnMouseDown(mevent); base.OnMouseDown(mevent);
if (Menu != null && mevent.Button == MouseButtons.Left) if (Menu != null && mevent.Button == MouseButtons.Left)
{ {
Point menuLocation;
if (ShowMenuUnderCursor) if (ShowMenuUnderCursor)
{ {
menuLocation = mevent.Location; OpenMenu(mevent.Location);
} }
else else
{ {
menuLocation = new Point(0, Height - 1); OpenMenu();
} }
Menu.Show(this, menuLocation);
} }
} }

View file

@ -644,6 +644,9 @@ private void form_KeyDown(object sender, KeyEventArgs e)
{ {
switch (e.KeyData) switch (e.KeyData)
{ {
case Keys.M:
CurrentTool = ShapeType.ToolSelect;
break;
case Keys.R: case Keys.R:
case Keys.NumPad1: case Keys.NumPad1:
CurrentTool = ShapeType.DrawingRectangle; CurrentTool = ShapeType.DrawingRectangle;
@ -710,9 +713,6 @@ private void form_KeyDown(object sender, KeyEventArgs e)
case Keys.PageDown: case Keys.PageDown:
MoveCurrentShapeDown(); MoveCurrentShapeDown();
break; break;
case Keys.M:
CurrentTool = ShapeType.ToolSelect;
break;
} }
} }

View file

@ -219,6 +219,11 @@ private void StopEditing()
UpdateHotkeyStatus(); UpdateHotkeyStatus();
} }
public void OpenTaskMenu()
{
btnTask.OpenMenu();
}
private void SelectControl() private void SelectControl()
{ {
Selected = true; Selected = true;

View file

@ -188,6 +188,7 @@ private void btnAdd_Click(object sender, EventArgs e)
UpdateCheckStates(); UpdateCheckStates();
control.Focus(); control.Focus();
Update(); Update();
control.OpenTaskMenu();
} }
private void btnRemove_Click(object sender, EventArgs e) private void btnRemove_Click(object sender, EventArgs e)