mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-04 14:11:38 +12:00
Only limit menu position if menu width smaller than screen width
This commit is contained in:
parent
df9a99b264
commit
5600d69936
|
@ -57,36 +57,6 @@ private void CreateMenu()
|
||||||
Text = "RegionCaptureFormMenu"
|
Text = "RegionCaptureFormMenu"
|
||||||
};
|
};
|
||||||
|
|
||||||
menuForm.LocationChanged += (sender, e) =>
|
|
||||||
{
|
|
||||||
Rectangle rectMenu = menuForm.Bounds;
|
|
||||||
Rectangle rectScreen = CaptureHelpers.GetScreenBounds();
|
|
||||||
Point pos = rectMenu.Location;
|
|
||||||
|
|
||||||
if (rectMenu.X < rectScreen.X)
|
|
||||||
{
|
|
||||||
pos.X = rectScreen.X;
|
|
||||||
}
|
|
||||||
else if (rectMenu.Right > rectScreen.Right)
|
|
||||||
{
|
|
||||||
pos.X = rectScreen.Right - rectMenu.Width;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rectMenu.Y < rectScreen.Y)
|
|
||||||
{
|
|
||||||
pos.Y = rectScreen.Y;
|
|
||||||
}
|
|
||||||
else if (rectMenu.Bottom > rectScreen.Bottom)
|
|
||||||
{
|
|
||||||
pos.Y = rectScreen.Bottom - rectMenu.Height;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pos != rectMenu.Location)
|
|
||||||
{
|
|
||||||
menuForm.Location = pos;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
menuForm.SuspendLayout();
|
menuForm.SuspendLayout();
|
||||||
|
|
||||||
tsMain = new ToolStripEx()
|
tsMain = new ToolStripEx()
|
||||||
|
@ -623,9 +593,39 @@ private void CreateMenu()
|
||||||
|
|
||||||
Rectangle rectActiveScreen = CaptureHelpers.GetActiveScreenBounds0Based();
|
Rectangle rectActiveScreen = CaptureHelpers.GetActiveScreenBounds0Based();
|
||||||
|
|
||||||
if (rectActiveScreen.Width > tsMain.Width)
|
if (tsMain.Width < rectActiveScreen.Width)
|
||||||
{
|
{
|
||||||
menuForm.Location = new Point(rectActiveScreen.X + rectActiveScreen.Width / 2 - tsMain.Width / 2, rectActiveScreen.Y + 20);
|
menuForm.Location = new Point(rectActiveScreen.X + rectActiveScreen.Width / 2 - tsMain.Width / 2, rectActiveScreen.Y + 20);
|
||||||
|
|
||||||
|
menuForm.LocationChanged += (sender, e) =>
|
||||||
|
{
|
||||||
|
Rectangle rectMenu = menuForm.Bounds;
|
||||||
|
Rectangle rectScreen = CaptureHelpers.GetScreenBounds();
|
||||||
|
Point pos = rectMenu.Location;
|
||||||
|
|
||||||
|
if (rectMenu.X < rectScreen.X)
|
||||||
|
{
|
||||||
|
pos.X = rectScreen.X;
|
||||||
|
}
|
||||||
|
else if (rectMenu.Right > rectScreen.Right)
|
||||||
|
{
|
||||||
|
pos.X = rectScreen.Right - rectMenu.Width;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rectMenu.Y < rectScreen.Y)
|
||||||
|
{
|
||||||
|
pos.Y = rectScreen.Y;
|
||||||
|
}
|
||||||
|
else if (rectMenu.Bottom > rectScreen.Bottom)
|
||||||
|
{
|
||||||
|
pos.Y = rectScreen.Bottom - rectMenu.Height;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pos != rectMenu.Location)
|
||||||
|
{
|
||||||
|
menuForm.Location = pos;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue