PhilipRieck / WpfAppBar

WPF AppBar helper
134 stars 48 forks source link

Support for high DPI settings #16

Closed peterwoodman closed 8 years ago

peterwoodman commented 8 years ago

The window is not scaled properly when using non-96 dpi settings. There is a call to transform the working area to pixels, but the result is not used in the code.

My solution was to do this:

double dpiWidthFactor = toPixel.M11;
double dpiHeightFactor = toPixel.M22;

var actualWorkArea = GetActualWorkArea(info);

if (barData.uEdge == (int)ABEdge.Left || barData.uEdge == (int)ABEdge.Right)
{
    barData.rc.top = (int)(actualWorkArea.Top * dpiHeightFactor);
    barData.rc.bottom = (int)(actualWorkArea.Bottom * dpiHeightFactor);
    etc.        

So anywhere the working area was used, it is multiplied by the dpi factor.