public void CalculateLargestSizeHavingAspect() { var size = new Size(1000, 1000); var targetAspect = new Rational(1, 1); // 1:1 var result = new Size(0, 0); result = VisualHelper.CalculateMaxSize(size, targetAspect); Assert.Equal(new Size(1000, 1000), result); // ----------------------------------------------------------------------------------------------- targetAspect = new Rational(2, 1); // 2:1 (width 2x height) result = VisualHelper.CalculateMaxSize(size, targetAspect); Assert.Equal(new Size(1000, 500), result); // ----------------------------------------------------------------------------------------------- targetAspect = new Rational(3, 1); // 3:1 (width 3x height) result = VisualHelper.CalculateMaxSize(size, targetAspect); Assert.Equal(new Size(1000, 333), result); // 333.3 (round down) // ----------------------------------------------------------------------------------------------- targetAspect = new Rational(4, 1); // 3:1 (width 3x height) result = VisualHelper.CalculateMaxSize(size, targetAspect); Assert.Equal(new Size(1000, 250), result); // 333.3 (round down) // ----------------------------------------------------------------------------------------------- targetAspect = new Rational(1, 2); // 1:2 (width 0.5 height) result = VisualHelper.CalculateMaxSize(size, targetAspect); Assert.Equal(new Size(500, 1000), result); // 333.3 (round down) }
public static TimeBase Parse(string text) { var rational = Rational.Parse(text); return(new TimeBase(rational.Numerator, rational.Denominator)); }