Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing wrong dropdown location in a rare multi screen setup (#162)
This should finally fix #160.
- Loading branch information
Showing
3 changed files
with
54 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Drawing; | ||
using System.Windows.Forms; | ||
|
||
namespace KeeTrayTOTP.Helpers | ||
{ | ||
[DesignerCategory("")] | ||
public class ToolStripMenuItemEx : ToolStripMenuItem | ||
{ | ||
public ToolStripMenuItemEx() | ||
{ | ||
} | ||
|
||
public ToolStripMenuItemEx(string text) : base(text) | ||
{ | ||
} | ||
|
||
public ToolStripMenuItemEx(string text, Image image) : base(text, image) | ||
{ | ||
} | ||
|
||
public ToolStripMenuItemEx(string text, Image image, EventHandler onClick) : base(text, image, onClick) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// This is required, because there is a bug in the .NET Framework, which calculates the position of dropdown menus wrong, | ||
/// if there is a multi-monitor setup with two monitors stacked above with the taskbar on the bottom of the top screen. | ||
/// </summary> | ||
protected override Point DropDownLocation | ||
{ | ||
get | ||
{ | ||
var dropDownLocation = base.DropDownLocation; | ||
|
||
var screenOfDropDown = Screen.FromPoint(dropDownLocation); | ||
var screenOfParentMenu = Screen.FromControl(Parent); | ||
|
||
if (!screenOfParentMenu.Equals(screenOfDropDown)) | ||
{ | ||
dropDownLocation.Offset(0, -DropDown.Height); | ||
} | ||
|
||
return dropDownLocation; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters