Improve DPI support (#254)

* Improving the DPI handling for most forms, there are still issues with:
* the AboutForm.Designer.cs where the title with the version scales differently.
* the destination picker doesn't seem to scale the font correctly.
Some parts are not tested yet...

* Solved the issue with the destination picker font, and some other small issues.
There still is an issue when using Powertoys (the feature which is experimental), that the capture is somehow skipping.
This commit is contained in:
Robin Krom 2020-10-23 00:28:50 +02:00 committed by GitHub
commit 94c778d82c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 216 additions and 216 deletions

View file

@ -155,10 +155,16 @@ namespace GreenshotPlugin.Core {
TopLevel = true
};
menu.Opened += (sender, args) =>
{
var scaledIconSize = DpiHelper.ScaleWithDpi(CoreConfig.IconSize, DpiHelper.GetDpi(menu.Handle));
menu.ImageScalingSize = scaledIconSize;
menu.Opening += (sender, args) =>
{
// find the DPI settings for the screen where this is going to land
var screenDpi = DpiHelper.GetDpi(menu.Location);
var scaledIconSize = DpiHelper.ScaleWithDpi(CoreConfig.IconSize, screenDpi);
menu.SuspendLayout();
var fontSize = DpiHelper.ScaleWithDpi(12f, screenDpi);
menu.Font = new Font(FontFamily.GenericSansSerif, fontSize, FontStyle.Regular, GraphicsUnit.Pixel);
menu.ImageScalingSize = scaledIconSize;
menu.ResumeLayout();
};
menu.Closing += delegate(object source, ToolStripDropDownClosingEventArgs eventArgs) {
@ -191,7 +197,10 @@ namespace GreenshotPlugin.Core {
menu.MouseEnter += delegate
{
// in case the menu has been unfocused, focus again so that dropdown menus will still open on mouseenter
if(!menu.ContainsFocus) menu.Focus();
if (!menu.ContainsFocus)
{
menu.Focus();
}
};
foreach (IDestination destination in destinations) {
// Fix foreach loop variable for the delegate