Exemplo n.º 1
0
 protected override int GetTop(Dpi dpi)
 {
     return this.Owner.Top.DpiRoundY(dpi) - this.GetHeight(this.CurrentDpi);
 }
Exemplo n.º 2
0
 protected override int GetWidth(Dpi dpi)
 {
     return this.Owner.ActualWidth.DpiRoundX(dpi) + this.Offset.Left.DpiRoundX(this.CurrentDpi) + this.Offset.Right.DpiRoundX(this.CurrentDpi);
 }
Exemplo n.º 3
0
 protected override int GetHeight(Dpi dpi)
 {
     return this.GetContentSizeOrDefault(x => x.ActualHeight).DpiRoundY(dpi);
 }
Exemplo n.º 4
0
 protected override int GetLeft(Dpi dpi)
 {
     return this.Owner.Left.DpiRoundX(dpi) - this.Offset.Left.DpiRoundX(this.CurrentDpi);
 }
Exemplo n.º 5
0
 public static int DpiRoundY(this double value, Dpi dpi)
 {
     return (int)Math.Round(value * dpi.ScaleY, MidpointRounding.AwayFromZero);
 }
Exemplo n.º 6
0
 public bool Equals(Dpi other)
 {
     return(this.X == other.X && this.Y == other.Y);
 }
Exemplo n.º 7
0
        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;
        }
Exemplo n.º 8
0
 public bool Equals(Dpi other)
 {
     return this.X == other.X && this.Y == other.Y;
 }
Exemplo n.º 9
0
        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);
                }
            }
        }
Exemplo n.º 10
0
 protected override int GetWidth(Dpi dpi)
 {
     return this.GetContentSizeOrDefault(x => x.ActualWidth).DpiRoundX(dpi);
 }
Exemplo n.º 11
0
 protected override int GetTop(Dpi dpi)
 {
     return this.Owner.Top.DpiRoundY(dpi);
 }
Exemplo n.º 12
0
 protected override int GetLeft(Dpi dpi)
 {
     return this.Owner.Left.DpiRoundX(dpi) + this.Owner.ActualWidth.DpiRoundX(dpi);
 }
Exemplo n.º 13
0
 protected override int GetHeight(Dpi dpi)
 {
     return this.Owner.ActualHeight.DpiRoundY(dpi);
 }