[Feature] Option to appear at mouse location (#135), version 1.0.17.25

This commit is contained in:
Markus Hofknecht 2021-04-28 22:58:33 +02:00
parent 49907998bb
commit 7914950c9f
5 changed files with 32 additions and 10 deletions

View file

@ -862,20 +862,26 @@ namespace SystemTrayMenu.Business
private void AdjustMenusSizeAndLocation()
{
WindowsTaskbar taskbar = new WindowsTaskbar();
Menu menuPredecessor = null;
List<Menu> list = AsList;
Menu menu;
Rectangle screenBounds = Screen.PrimaryScreen.Bounds;
Menu.StartLocation startLocation;
Rectangle screenBounds;
if (Properties.Settings.Default.AppearAtMouseLocation)
{
screenBounds = Screen.FromPoint(Cursor.Position).Bounds;
}
else
{
screenBounds = Screen.PrimaryScreen.Bounds;
}
// Only apply taskbar position change when no menu is currently open
List<Menu> list = AsList;
WindowsTaskbar taskbar = new WindowsTaskbar();
if (list.Count == 1)
{
taskbarPosition = taskbar.Position;
}
// Shrink the usable space depending on taskbar location
Menu.StartLocation startLocation;
switch (taskbarPosition)
{
case TaskbarPosition.Left:
@ -899,6 +905,8 @@ namespace SystemTrayMenu.Business
break;
}
Menu menu;
Menu menuPredecessor = null;
for (int i = 0; i < list.Count; i++)
{
menu = list[i];

View file

@ -39,5 +39,5 @@ using System.Runtime.InteropServices;
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.17.24")]
[assembly: AssemblyFileVersion("1.0.17.24")]
[assembly: AssemblyVersion("1.0.17.25")]
[assembly: AssemblyFileVersion("1.0.17.25")]

View file

@ -241,7 +241,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View file

@ -301,6 +301,15 @@ namespace SystemTrayMenu.UserInterface
// Ignore start as we use predecessor
startLocation = StartLocation.Predecessor;
}
else if (Properties.Settings.Default.AppearAtMouseLocation)
{
// Use this menu as predecessor and set location of Mouse
menuPredecessor = this;
Tag = new RowData();
Location = new Point(Cursor.Position.X, Cursor.Position.Y - labelTitle.Height);
directionToRight = true;
startLocation = StartLocation.Predecessor;
}
// Update the height and width
AdjustDataGridViewHeight(menuPredecessor, bounds.Height);
@ -349,6 +358,13 @@ namespace SystemTrayMenu.UserInterface
break;
}
// X position for click, remove width of this menu as it is used as predecessor
if (menuPredecessor == this && directionToRight)
{
x -= Width;
directionToRight = false;
}
// Calculate Y position
int y;
switch (startLocation)

View file

@ -545,7 +545,6 @@ namespace SystemTrayMenu.UserInterface
//
this.checkBoxAppearAtMouseLocation.AutoSize = true;
this.checkBoxAppearAtMouseLocation.Dock = System.Windows.Forms.DockStyle.Fill;
this.checkBoxAppearAtMouseLocation.Enabled = false;
this.checkBoxAppearAtMouseLocation.Location = new System.Drawing.Point(3, 3);
this.checkBoxAppearAtMouseLocation.Name = "checkBoxAppearAtMouseLocation";
this.checkBoxAppearAtMouseLocation.Size = new System.Drawing.Size(438, 19);