示例#1
0
文件: Dpi.cs 项目: Ryks/MetroRadiance
		public bool Equals(Dpi other)
		{
			return this.X == other.X && this.Y == other.Y;
		}
示例#2
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;
        }
示例#3
0
 public bool Equals(Dpi other)
 {
     return(this.X == other.X && this.Y == other.Y);
 }
示例#4
0
        protected override void OnSourceInitialized(EventArgs e)
        {
            base.OnSourceInitialized(e);

            this.source = PresentationSource.FromVisual(this) as HwndSource;
            if (this.source == null) return;

            this.systemDpi = this.GetSystemDpi() ?? Dpi.Default;
            if (PerMonitorDpi.IsSupported)
            {
                this.currentDpi = this.source.GetDpi();
                this.ChangeDpi(this.currentDpi);
                this.source.AddHook(this.WndProc);
            }
            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 == SW.SHOWMINIMIZED ? SW.SHOWNORMAL : placement.showCmd);

                    NativeMethods.SetWindowPlacement(this.source.Handle, ref placement);
                }
            }
        }