예제 #1
0
        public Boolean Validate(IMediaFeature feature, IRenderDevice renderDevice)
        {
            var defaultValue = new Length(1.0, Length.Unit.None);
            var converter    = feature.IsMinimum || feature.IsMaximum ? NaturalIntegerConverter : NaturalIntegerConverter.Option(defaultValue);
            var index        = converter.Convert(feature.Value);

            if (index != null)
            {
                var desired   = index.AsInt32();
                var available = renderDevice.MonochromeBits;

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

                return(desired == available);
            }

            return(false);
        }
예제 #2
0
        public static Boolean Validate(this IMediaFeature feature, IRenderDevice device)
        {
            var validator = default(IFeatureValidator);

            AssociatedValidators.TryGetValue(feature, out validator);
            return(validator?.Validate(feature, device) ?? false);
        }
        public Boolean Validate(IMediaFeature feature, IRenderDevice renderDevice)
        {
            var defaultValue = new Length(1.0, Length.Unit.None);
            var converter    = feature.IsMinimum || feature.IsMaximum ? PositiveIntegerConverter : PositiveIntegerConverter.Option(defaultValue);
            var color        = converter.Convert(feature.Value);

            if (color != null)
            {
                var desired   = color.AsInt32();
                var available = Math.Pow(renderDevice.ColorBits, 2);

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

                return(desired == available);
            }

            return(false);
        }
        public Boolean Validate(IMediaFeature feature, IRenderDevice renderDevice)
        {
            var hover = HoverAbilityConverter.Convert(feature.Value);

            if (hover != null)
            {
                var desired = hover.AsEnum <HoverAbility>();
                //Nothing yet, so we assume we have a headless browser
                return(desired == HoverAbility.None);
            }

            return(false);
        }
        public Boolean Validate(IMediaFeature feature, IRenderDevice device)
        {
            var grid = BinaryConverter.Convert(feature.Value);

            if (grid != null)
            {
                var desired   = grid.AsBoolean();
                var available = device.IsGrid;
                return(desired == available);
            }

            return(false);
        }
        public Boolean Validate(IMediaFeature feature, IRenderDevice renderDevice)
        {
            var accuracy = PointerAccuracyConverter.Convert(feature.Value);

            if (accuracy != null)
            {
                var desired = accuracy.AsEnum <PointerAccuracy>();
                //Nothing yet, so we assume we have a headless browser
                return(desired == PointerAccuracy.None);
            }

            return(false);
        }
        public Boolean Validate(IMediaFeature feature, IRenderDevice device)
        {
            var portrait = OrientationModeConverter.Convert(feature.Value);

            if (portrait != null)
            {
                var desired   = portrait.Is(CssKeywords.Portrait);
                var available = device.DeviceHeight >= device.DeviceWidth;
                return(desired == available);
            }

            return(false);
        }
예제 #8
0
        public Boolean Validate(IMediaFeature feature, IRenderDevice device)
        {
            var interlace = ScanModeConverter.Convert(feature.Value);

            if (interlace != null)
            {
                var desired   = interlace.Is(CssKeywords.Interlace);
                var available = device.IsInterlaced;
                return(desired == available);
            }

            return(false);
        }
예제 #9
0
        public Boolean Validate(IMediaFeature feature, IRenderDevice device)
        {
            var state = ScriptingStateConverter.Convert(feature.Value);

            if (state != null)
            {
                var available = ScriptingState.None;
                var desired   = state.AsEnum <ScriptingState>();

                if (device.IsScripting)
                {
                    available = device.Category == DeviceCategory.Screen ? ScriptingState.Enabled : ScriptingState.InitialOnly;
                }

                return(desired == available);
            }

            return(false);
        }
        public Boolean Validate(IMediaFeature feature, IRenderDevice device)
        {
            var length = LengthConverter.Convert(feature.Value);

            if (length != null)
            {
                var desired   = length.AsPixel();
                var available = (Double)device.DeviceWidth;

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

                return(desired == available);
            }

            return(false);
        }
        public Boolean Validate(IMediaFeature feature, IRenderDevice renderDevice)
        {
            var length = LengthConverter.Convert(feature.Value);

            if (length != null)
            {
                var desired   = length.AsPx(renderDevice, RenderMode.Vertical);
                var available = (Double)renderDevice.ViewPortHeight;

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

                return(desired == available);
            }

            return(false);
        }
        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);
        }
예제 #13
0
        public Boolean Validate(IMediaFeature feature, IRenderDevice device)
        {
            var value = NaturalNumberConverter.Convert(feature.Value);

            if (value != null)
            {
                var desired   = value.AsNumber();
                var available = device.Resolution / 96f;

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

                return(desired == available);
            }

            return(false);
        }
        public Boolean Validate(IMediaFeature feature, IRenderDevice device)
        {
            var res = ResolutionConverter.Convert(feature.Value);

            if (res != null)
            {
                var desired   = res.AsInt32();
                var available = device.Resolution;

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

                return(desired == available);
            }

            return(false);
        }
예제 #15
0
        public Boolean Validate(IMediaFeature feature, IRenderDevice device)
        {
            var frequency = UpdateFrequencyConverter.Convert(feature.Value);

            if (frequency != null)
            {
                var desired   = frequency.AsEnum <UpdateFrequency>();
                var available = device.Frequency;

                if (available >= 30)
                {
                    return(desired == UpdateFrequency.Normal);
                }
                else if (available > 0)
                {
                    return(desired == UpdateFrequency.Slow);
                }

                return(desired == UpdateFrequency.None);
            }

            return(false);
        }
예제 #16
0
        public Boolean Validate(IMediaFeature feature, IRenderDevice device)
        {
            var converter = feature.IsMinimum || feature.IsMaximum ? NaturalIntegerConverter : NaturalIntegerConverter.Option(1);
            var index     = converter.Convert(feature.Value);

            if (index != null)
            {
                var desired   = index.AsInteger();
                var available = device.ColorBits;

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

                return(desired == available);
            }

            return(false);
        }
예제 #17
0
 public Boolean Validate(IMediaFeature feature, IRenderDevice device)
 {
     return(true);
 }
 public static void AssociateValidator(this IMediaFeature feature, IFeatureValidator validator) =>
 AssociatedValidators.Add(feature, validator);