-
Notifications
You must be signed in to change notification settings - Fork 981
Closed
Description
DPI scaling support can be achieved by detecting the current scale factor (this method is specific to each control) then assigning the plot's scale factor inside the Reset() method of that control.
Example (WinForms)
I recently added display scaling support to the WinForms control like this:
ScottPlot/src/ScottPlot5/ScottPlot5 Controls/ScottPlot.WinForms/FormsPlot.cs
Lines 79 to 92 in 190030a
| public Plot Reset() | |
| { | |
| using Graphics gfx = CreateGraphics(); | |
| const int DEFAULT_DPI = 96; | |
| float scaleFactor = gfx.DpiX / DEFAULT_DPI; | |
| Plot newPlot = new() | |
| { | |
| FigureBackground = this.BackColor.ToColor(), | |
| ScaleFactor = scaleFactor | |
| }; | |
| return Reset(newPlot); | |
| } |
Updated Controls
Additional effort is required to determine how to detect DPI scale on the other controls and make this similar modification:
- WinForms SP5: add support for display scaling #2747
- WPF SP5 WPF: automatic display scaling #2766
- WinUI
- Avalonia
- Eto
Community Support
I don't intend to focus on this in the short term, but if someone figures out how to calculate display scaling in one or more of the unsupported controls, I welcome a pull request! 🚀
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels