コード例 #1
0
        private DisplayInformationEx(Size physicalSize, Size physicalResolution, DisplayInformationSource informationSource)
        {
            PhysicalSize = physicalSize;
              PhysicalDiagonal = PhysicalSize.GetHypotenuse();
              PhysicalResolution = physicalResolution;

              AspectRatio = physicalSize.Height / physicalSize.Width;

              if (!(AspectRatio.IsCloseEnoughTo(physicalResolution.Height / physicalResolution.Width)))
            throw new ArgumentOutOfRangeException("physicalResolution", "only square pixels supported");

              RawDpi = physicalResolution.Width / physicalSize.Width;

              AbsoluteScaleFactorBeforeNormalizing = PhysicalSize.Width / DisplayConstants.BaselineWidthInInches;

              RawPixelsPerViewPixel = GenerateRawPixelsPerViewPixel();

              ViewResolution = new Size(PhysicalResolution.Width / RawPixelsPerViewPixel, PhysicalResolution.Height / RawPixelsPerViewPixel);

              ViewPixelsPerInch = RawDpi / RawPixelsPerViewPixel;

              // Adjust for different aspect ratio, if necessary
              ViewPixelsPerHostPixel = Math.Min(ViewResolution.Width / Application.Current.Host.Content.ActualWidth,
            ViewResolution.Height / Application.Current.Host.Content.ActualHeight);

              HostPixelsPerViewPixel = 1 / ViewPixelsPerHostPixel;

              InformationSource = informationSource;
        }