Ejemplo n.º 1
0
        public void RatioConvertTest()
        {
            var fixture   = new Fixture();
            var converter = new RatioConverter();
            var value     = fixture.Create <double>();
            var parameter = fixture.Create <double>();

            var result = converter.Convert(value, null, parameter, CultureInfo.CurrentCulture);

            Assert.That(result, Is.EqualTo(value * parameter));
            Assert.That(result, Is.TypeOf <double>());
        }
        public Boolean Validate(IMediaFeature feature, IRenderDevice device)
        {
            var ratio = RatioConverter.Convert(feature.Value);

            if (ratio != null)
            {
                var desired   = ratio.AsNumber();
                var available = device.ViewPortWidth / (Double)device.ViewPortHeight;

                if (feature.IsMaximum)
                {
                    return(available <= desired);
                }
                else if (feature.IsMinimum)
                {
                    return(available >= desired);
                }

                return(desired == available);
            }

            return(false);
        }
Ejemplo n.º 3
0
 public void InitializeConverter()
 {
     _converter = new RatioConverter();
 }
Ejemplo n.º 4
0
 public override object ProvideValue(IServiceProvider serviceProvider)
 {
     return(_instance ?? (_instance = new RatioConverter()));
 }