Giter Site home page Giter Site logo

Comments (7)

davsun55 avatar davsun55 commented on June 11, 2024 1

FYI the best solution I've found is:

  • Add <ForceDesignerDpiUnaware>true</ForceDesignerDpiUnaware> to the apps' .csproj file in the first <PropertyGroup> section - this allows the development environment to render forms correctly whatever the DPI
  • Add Application.SetHighDpiMode(HighDpiMode.DpiUnaware); to the startup object (NOT app.config as some suggest) - this causes the executing app to render forms correctly whatever the DPI

Notes:

  • HighDpiMode.SystemAware option: On app startup, control sizes are determined by primary screen, so stretching can occur when moved to a different DPI and/or resolution
  • HighDpiMode.PerMonitorV2 option: causes serious and compounding control layout issues when form is dragged between screens with different DPIs
  • HighDpiMode.DpiUnaware option: seems to work best - at least for me! The fonts are not as perfectly clear as 'SystemAware' but definitely good enough and better than the stretching that occurs otherwise.

Thanks for your work,
D

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on June 11, 2024

@davsun55 Does the issue happens also locally before publishing during debugging if you set Zoom/DPI at your pc's display?
Sounds like each Window has different DPI awareness in your case (not even sure if that possible) that's why Application.SetHighDpiMode will fix this as it will make sure that all of them use the same logic.

Is it possible that you mix WinForms/WPF? Maybe it's Flyleaf's fault that this happens..

<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>

But again, I'm not sure and not easy to understand how .NET handles those related with the DPI awareness.

from flyleaf.

davsun55 avatar davsun55 commented on June 11, 2024

Yes - the issue does occur when debugging direct from VS. I already have true and adding UseWPF made no difference - I'm not sure if you're suggesting to add or make sure I don't have UseWPF?
After more research I have added EnableWindowFormsHighDpiAutoResizing=True to app.config. Now if I start the app with 100% scaling then switch to 200% it reformats perfectly. However when starting the app in 200%, many of the controls/fonts are not sized correctly and toggling 100%/200% doesn't help.
If you've got any guidance (although it's not your issue), I'd be very grateful. My issue is that my app is often run on a tablet, so there isn't a main or secondary screen that's running at 100%.
Would it be possible to have FlyLeaf not require the Application.SetHighDpiMode(HighDpiMode.SystemAware) statement?

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on June 11, 2024

Can you create a mini reproducible demo to have a better look? This might be related with windows settings (for the tablet).

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on June 11, 2024

@davsun55 I will close this but feel free to send more info to investigate more

from flyleaf.

davsun55 avatar davsun55 commented on June 11, 2024

FlyleafDemo.zip
I am resolved to having my app handle DPI changes better, but this zip demonstrates the issue. It's your demo but with the initialisation moved from constructor/form open to the button. If I don't have any version of this statement in program.cs Application.SetHighDpiMode(HighDpiMode.DpiUnaware); // SystemAware);, then when starting on a monitor at other than 100% scaling, the form looks fine, but after initialisation it is reduced to much smaller.
If I do have one of those statements included, then the form stays the same size.
As it stands, I need to go through all my forms and tweak the controls that don't handle DPI changes. It seems ListViews are one of the worst culprits.
I guess it would be nice if FlyLeaf initialisation didn't cause this effect, but I'm guessing that it needs to for other reasons???
:)

from flyleaf.

SuRGeoNix avatar SuRGeoNix commented on June 11, 2024

@davsun55 Found the issue, during the plugin's load event, even if it does not load anything at all (except embedded/default), just by iterating to the current assembly's types will cause dpi-aware enable (possible MS bug).

Line causes the issue

Same issue by another user

from flyleaf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.