mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Automatically move toolbar to snap top of annotate window
This commit is contained in:
parent
2a5370c101
commit
48681af900
2 changed files with 28 additions and 11 deletions
|
@ -254,9 +254,12 @@ internal void InitBackground(Image img)
|
|||
}
|
||||
}
|
||||
|
||||
private void CenterCanvas()
|
||||
private void CenterCanvas(bool updateCoordinates = true)
|
||||
{
|
||||
UpdateCoordinates();
|
||||
if (updateCoordinates)
|
||||
{
|
||||
UpdateCoordinates();
|
||||
}
|
||||
|
||||
Rectangle rect = ScreenRectangle0Based;
|
||||
|
||||
|
@ -291,15 +294,22 @@ private void RegionCaptureForm_Shown(object sender, EventArgs e)
|
|||
|
||||
private void RegionCaptureForm_Resize(object sender, EventArgs e)
|
||||
{
|
||||
UpdateCoordinates();
|
||||
|
||||
if (WindowState != lastWindowState)
|
||||
{
|
||||
lastWindowState = WindowState;
|
||||
|
||||
if (WindowState == FormWindowState.Normal || WindowState == FormWindowState.Maximized)
|
||||
{
|
||||
CenterCanvas();
|
||||
CenterCanvas(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (IsAnnotationMode && ShapeManager != null && ShapeManager.ToolbarCreated)
|
||||
{
|
||||
ShapeManager.UpdateMenuPosition();
|
||||
}
|
||||
}
|
||||
|
||||
internal void RegionCaptureForm_KeyDown(object sender, KeyEventArgs e)
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace ShareX.ScreenCaptureLib
|
|||
{
|
||||
internal partial class ShapeManager
|
||||
{
|
||||
public bool ToolbarCreated { get; private set; }
|
||||
public bool IsMenuCollapsed { get; private set; }
|
||||
|
||||
internal TextAnimation MenuTextAnimation = new TextAnimation()
|
||||
|
@ -53,7 +54,7 @@ internal partial class ShapeManager
|
|||
private ToolStripLabel tslDragLeft;
|
||||
private ToolStripLabeledComboBox tscbCursorTypes;
|
||||
|
||||
private void CreateToolbar()
|
||||
internal void CreateToolbar()
|
||||
{
|
||||
menuForm = new Form()
|
||||
{
|
||||
|
@ -66,8 +67,7 @@ private void CreateToolbar()
|
|||
Location = new Point(200, 200),
|
||||
ShowInTaskbar = false,
|
||||
StartPosition = FormStartPosition.Manual,
|
||||
Text = "ShareX - Region capture menu",
|
||||
TopMost = true
|
||||
Text = "ShareX - Region capture menu"
|
||||
};
|
||||
|
||||
menuForm.Shown += MenuForm_Shown;
|
||||
|
@ -857,6 +857,8 @@ private void CreateToolbar()
|
|||
ConfigureMenuState();
|
||||
|
||||
form.Activate();
|
||||
|
||||
ToolbarCreated = true;
|
||||
}
|
||||
|
||||
private void MenuForm_Shown(object sender, EventArgs e)
|
||||
|
@ -930,7 +932,12 @@ private void ConfigureMenuState()
|
|||
SetMenuCollapsed(Config.MenuCollapsed);
|
||||
}
|
||||
|
||||
Rectangle rectScreen = CaptureHelpers.GetScreenBounds();
|
||||
UpdateMenuPosition();
|
||||
}
|
||||
|
||||
internal void UpdateMenuPosition()
|
||||
{
|
||||
Rectangle rectScreen = form.RectangleToScreen(form.ScreenRectangle0Based);
|
||||
|
||||
if (Config.RememberMenuState && rectScreen.Contains(Config.MenuPosition))
|
||||
{
|
||||
|
@ -938,15 +945,15 @@ private void ConfigureMenuState()
|
|||
}
|
||||
else
|
||||
{
|
||||
Rectangle rectActiveScreen = CaptureHelpers.GetActiveScreenBounds();
|
||||
//Rectangle rectActiveScreen = CaptureHelpers.GetActiveScreenBounds();
|
||||
|
||||
if (tsMain.Width < rectActiveScreen.Width)
|
||||
if (tsMain.Width < rectScreen.Width)
|
||||
{
|
||||
menuForm.Location = new Point(rectActiveScreen.X + rectActiveScreen.Width / 2 - tsMain.Width / 2, rectActiveScreen.Y + 20);
|
||||
menuForm.Location = new Point(rectScreen.X + rectScreen.Width / 2 - tsMain.Width / 2, rectScreen.Y);
|
||||
}
|
||||
else
|
||||
{
|
||||
menuForm.Location = rectActiveScreen.Location;
|
||||
menuForm.Location = rectScreen.Location;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue