/// <summary> /// method to detect DisplayResolutionFormat /// </summary> /// <returns></returns> private DisplayAspectRatio GetDisplayAspectRatio() { DisplayAspectRatio result = DisplayAspectRatio.Unknown; //WP8.1 uses logical pixel dimensions, we need to convert this to raw pixel dimensions double logicalPixelWidth = Windows.UI.Xaml.Window.Current.Bounds.Width; double logicalPixelHeight = Windows.UI.Xaml.Window.Current.Bounds.Height; double rawPerViewPixels = DisplayInformation.GetForCurrentView().RawPixelsPerViewPixel; double rawPixelHeight = logicalPixelHeight * rawPerViewPixels; double rawPixelWidth = logicalPixelWidth * rawPerViewPixels; //calculate and return screen format double relation = Math.Max(rawPixelWidth, rawPixelHeight) / Math.Min(rawPixelWidth, rawPixelHeight); if (Math.Abs(relation - (15.0 / 9.0)) < 0.01) { result = DisplayAspectRatio.FifteenByNine; } else if (Math.Abs(relation - (16.0 / 9.0)) < 0.01) { result = DisplayAspectRatio.SixteenByNine; } return(result); }
public void AscpectRatioTest(string filePath, DisplayAspectRatio ratio) { var file = _mediaInfoFacade.Read(filePath); Assert.That(file.Video.DisplayAspectRatio, Is.EqualTo(ratio)); }