The Wayback Machine - https://web.archive.org/web/20200927051226/https://github.com/oxyplot/oxyplot/pull/1597
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add supports HiDPI for winforms examples #1597

Open
wants to merge 5 commits into
base: develop
from

Conversation

@rstm-sf
Copy link

rstm-sf commented Jun 5, 2020

Checklist

  • I have included examples or tests
  • I have updated the change log
  • I am listed in the CONTRIBUTORS file
  • I have cleaned up the commit history (use rebase and squash)

Changes proposed in this pull request:

  • Add supports HiDPI for winforms examples

@oxyplot/admins

@Jonarw
Copy link
Member

Jonarw commented Jun 6, 2020

Thanks for your contribution!
Could you please:

Thanks!

@rstm-sf rstm-sf force-pushed the rstm-sf:feature/supports_hidpi_winforms branch from e6cfe41 to c682709 Jun 6, 2020
@Jonarw
Copy link
Member

Jonarw commented Jun 7, 2020

Ok so having now had a closer look at this, I realized that our WinForms-Renderer does not quite support any DPI other than 96 (it uses a fixed 1:1 ratio between 1/96th inch device-independent units and pixels). This is not a problem with this PR per se, but a limitation of the GraphicsRenderContext implementation.

I think we could still merge this just to have a showcase of what is not supported at the moment and maybe at some point we'll want to update the GraphicsRenderContext accordingly.

What do you think @VisualMelon?

@VisualMelon
Copy link
Contributor

VisualMelon commented Jun 7, 2020

High DPI on WinForms is not something I've ever needed, so my input is limit to what I can find on SO and the msdn.

I think you are right that this would be worth including: the example browser is in some senses a separate concern, and it will be useful for testing the PlotView if it is updated to support variable Dpi.

I'd be happy to work on adding DPI support to GraphicsRenderContext. I'm not convinced the font sizes are correct in WinFroms (e.g. the 0.8 font factor should be 0.75?), but that's a question for another day.

@rstm-sf rstm-sf force-pushed the rstm-sf:feature/supports_hidpi_winforms branch from c682709 to c9c10e7 Jun 7, 2020
@rstm-sf
Copy link
Author

rstm-sf commented Jun 7, 2020

Fix TreeView for HiDPI when full framework

#if NETFRAMEWORK
            FixTreeViewDpi();
#endif
@rstm-sf
Copy link
Author

rstm-sf commented Jun 7, 2020

High DPI on WinForms is not something I've ever needed, so my input is limit to what I can find on SO and the msdn.

Support in core looks better. And it looks like it will continue to improve dotnet/winforms#3202 (comment)

@Jonarw
Copy link
Member

Jonarw commented Jun 10, 2020

I don't have enough experience with WinForms to really comment on this. I can confirm that this works on my machine in the sense that the WinForms ExampleBrowser is displayed in a non-blurry way on all DPI settings I tested.
Plot rendering has some issues with incorrectly scaled plot elements on non-standard DPI, but as said previously, this is not an issue of this PR.

So if you don't see any problems @VisualMelon I think we could merge this.

@VisualMelon
Copy link
Contributor

VisualMelon commented Jun 10, 2020

I'm afraid that though I use winforms every day, I've never had to deal with variable DPI, so I'm guessing at everything really.

Testing with the Scaling option in Windows 10 (I don't have a high DPI screen), the .NET Framework text is much larger than the .NET Core text. Disabling the .NET Framework specific stuff seems to reduce (but not remove) the difference. Is this how it behaves for other people? (The .NET Framework stuff looks OK for me with the "Let Windows try to fix apps so they're not blurry" option; Core looks good).

The Framework specific stuff doesn't modify the checkboxes. If it is necessary to perform manual adjustments (which doesn't seem to be the case on my machine: @rstm-sf could you explain the idea?) it should ideally affect everything. The checkboxes can be made smart by setting SutoSize = true, and changing the panel at the bottom to resize/layout with them (e.g. swap it for an auto-sizing flow panel).

@rstm-sf
Copy link
Author

rstm-sf commented Jun 10, 2020

Testing with the Scaling option in Windows 10 (I don't have a high DPI screen)

Sorry, I missed it. Yes, we need to add the definition that dpi is changed and only then increase the treeview

could you explain the idea?

Winforms does not fully support hidpi, so we need to manually increase some controls. But it is possible that I missed some option ...

@rstm-sf
Copy link
Author

rstm-sf commented Jun 10, 2020

Although, I remembered why I did not. At 100%, scaleFactor = 1 should turn out and this is exactly what happens for me. I don’t know why you have this behavior... I need to think about it, as I noticed that if I change the dpi, the winforms does not respond to this

@rstm-sf rstm-sf marked this pull request as draft Jun 10, 2020
@VisualMelon
Copy link
Contributor

VisualMelon commented Jun 10, 2020

I should clarify that the text is only larger with scale factor > 100%: nothing seems to regress at the default DPI.

Feel free to ping me if you want anything tested.

@rstm-sf
Copy link
Author

rstm-sf commented Jun 15, 2020

I tried to set system aware, maybe this will help?

@rstm-sf
Copy link
Author

rstm-sf commented Jun 15, 2020

Last change, so as not to fix with dpi == 96

@rstm-sf rstm-sf marked this pull request as ready for review Jun 26, 2020
@VisualMelon
Copy link
Contributor

VisualMelon commented Jun 26, 2020

I'll take another proper look at this sometime in the next few days, and I'll put together a fix for the checkboxes which we can either merge into this or I'll just push through as a separate PR.

@VisualMelon
Copy link
Contributor

VisualMelon commented Jun 26, 2020

Taking a quick look just now (because I'm contemplating adding DPI support to GTK if it needs it), the tree view is still too big when using .NET Framework.

If I disable FixTreeViewDpi, with 175% scaling and NET Framework I get this (which looks fine):

image

With it enabled, I get this:

image

Similar behaviour with NET Core when I remove the NETFRAMEWORK check in InitTree

@rstm-sf
Copy link
Author

rstm-sf commented Jun 26, 2020

Thanks for the clarification! This problem also reproduces for me, but at 125 everything is fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.