protected override int GetTop(Dpi dpi) { return this.Owner.Top.DpiRoundY(dpi) - this.GetHeight(this.CurrentDpi); }
protected override int GetWidth(Dpi dpi) { return this.Owner.ActualWidth.DpiRoundX(dpi) + this.Offset.Left.DpiRoundX(this.CurrentDpi) + this.Offset.Right.DpiRoundX(this.CurrentDpi); }
protected override int GetHeight(Dpi dpi) { return this.GetContentSizeOrDefault(x => x.ActualHeight).DpiRoundY(dpi); }
protected override int GetLeft(Dpi dpi) { return this.Owner.Left.DpiRoundX(dpi) - this.Offset.Left.DpiRoundX(this.CurrentDpi); }
public static int DpiRoundY(this double value, Dpi dpi) { return (int)Math.Round(value * dpi.ScaleY, MidpointRounding.AwayFromZero); }
public bool Equals(Dpi other) { return(this.X == other.X && this.Y == other.Y); }
private void ChangeDpi(Dpi dpi) { if (!PerMonitorDpi.IsSupported) return; this.DpiScaleTransform = dpi == this.systemDpi ? Transform.Identity : new ScaleTransform((double)dpi.X / this.systemDpi.X, (double)dpi.Y / this.systemDpi.Y); this.Width = this.Width * dpi.X / this.CurrentDpi.X; this.Height = this.Height * dpi.Y / this.CurrentDpi.Y; this.CurrentDpi = dpi; }
public bool Equals(Dpi other) { return this.X == other.X && this.Y == other.Y; }
protected override void OnSourceInitialized(EventArgs e) { base.OnSourceInitialized(e); this.source = PresentationSource.FromVisual(this) as HwndSource; if (this.source == null) return; this.source.AddHook(this.WndProc); this.systemDpi = this.GetSystemDpi() ?? Dpi.Default; if (PerMonitorDpi.IsSupported) { this.CurrentDpi = this.source.GetDpi(); this.ChangeDpi(this.CurrentDpi); } else { this.CurrentDpi = this.systemDpi; } if (this.WindowSettings == null) { this.WindowSettings = new WindowSettings(this); } if (this.IsRestoringWindowPlacement) { this.WindowSettings.Reload(); if (this.WindowSettings.Placement.HasValue) { var placement = this.WindowSettings.Placement.Value; placement.length = Marshal.SizeOf(typeof(WINDOWPLACEMENT)); placement.flags = 0; placement.showCmd = placement.showCmd == ShowWindowFlags.SW_SHOWMINIMIZED ? ShowWindowFlags.SW_SHOWNORMAL : placement.showCmd; User32.SetWindowPlacement(this.source.Handle, ref placement); } } }
protected override int GetWidth(Dpi dpi) { return this.GetContentSizeOrDefault(x => x.ActualWidth).DpiRoundX(dpi); }
protected override int GetTop(Dpi dpi) { return this.Owner.Top.DpiRoundY(dpi); }
protected override int GetLeft(Dpi dpi) { return this.Owner.Left.DpiRoundX(dpi) + this.Owner.ActualWidth.DpiRoundX(dpi); }
protected override int GetHeight(Dpi dpi) { return this.Owner.ActualHeight.DpiRoundY(dpi); }