コード例 #1
0
        public static TransitionDefinition CreateKey(KeyTransitionType transitionType, int? hue, bool? invert,
                                                     int? luminance,
                                                     UInt32? rgb, int? similarity)
        {
            var transitionDefinition = new TransitionDefinition(KeyTransition);
            transitionDefinition.Parameters.Add(new Parameter(KeyTransitionParameter.KeyType, (long) transitionType));

            if (hue.HasValue)
            {
                if ((hue < 0) || (hue > 360))
                {
                    throw new ArgumentOutOfRangeException("hue", "hue must be between 0 and 360");
                }
                else if (transitionType != KeyTransitionType.Hue)
                {
                    throw new ArgumentException("hue specified but selected key transitionType is not \"Hue\"", "hue");
                }
                else
                {
                    transitionDefinition.Parameters.Add(new Parameter(KeyTransitionParameter.Hue, hue.Value));
                }
            }

            if (luminance.HasValue)
            {
                if ((luminance < 0) || (luminance > 100))
                {
                    throw new ArgumentOutOfRangeException("luminance", "luminance must be between 0 and 100");
                }
                else if (transitionType != KeyTransitionType.Hue)
                {
                    throw new ArgumentException("hue specified but selected key transitionType is not \"Hue\"", "hue");
                }
                else
                {
                    transitionDefinition.Parameters.Add(
                        new Parameter(KeyTransitionParameter.Luminance, luminance.Value));
                }
            }

            if (rgb.HasValue)
            {
                if ((rgb < 0) || (rgb > 0xFFFFFF))
                {
                    throw new ArgumentOutOfRangeException("rgb", "rgb must be between 0x000000 and 0xFFFFFF");
                }
                else if (transitionType != KeyTransitionType.Rgb)
                {
                    throw new ArgumentException("rgb specified but selected key transitionType is not \"Rgb\"", "rgb");
                }
                else
                {
                    transitionDefinition.Parameters.Add(new Parameter(KeyTransitionParameter.Rgb, rgb.Value));
                }
            }

            if (similarity.HasValue)
            {
                if ((similarity < 0) || (similarity > 100))
                {
                    throw new ArgumentOutOfRangeException("similarity", "similarity must be between 0 and 100");
                }
                else if ((transitionType != KeyTransitionType.Rgb) && (transitionType != KeyTransitionType.NoRed))
                {
                    throw new ArgumentException(
                        "similarity specified but selected key transitionType does not support it",
                        "similarity");
                }
                else
                {
                    transitionDefinition.Parameters.Add(
                        new Parameter(KeyTransitionParameter.Similarity, similarity.Value));
                }
            }

            if (invert.HasValue)
            {
                if ((transitionType != KeyTransitionType.Rgb) && (transitionType != KeyTransitionType.Hue) &&
                    (transitionType != KeyTransitionType.Luminance) &&
                    (transitionType != KeyTransitionType.NoRed))
                {
                    throw new ArgumentException("invert specified but selected key transitionType does not support it",
                                                "invert");
                }
                else
                {
                    transitionDefinition.Parameters.Add(new Parameter(KeyTransitionParameter.Invert, invert.Value));
                }
            }

            return transitionDefinition;
        }
コード例 #2
0
        public static TransitionDefinition CreateKey(KeyTransitionType transitionType, int?hue, bool?invert,
                                                     int?luminance,
                                                     UInt32?rgb, int?similarity)
        {
            var transitionDefinition = new TransitionDefinition(KeyTransition);

            transitionDefinition.Parameters.Add(new Parameter(KeyTransitionParameter.KeyType, (long)transitionType));

            if (hue.HasValue)
            {
                if ((hue < 0) || (hue > 360))
                {
                    throw new ArgumentOutOfRangeException("hue", "hue must be between 0 and 360");
                }
                else if (transitionType != KeyTransitionType.Hue)
                {
                    throw new ArgumentException("hue specified but selected key transitionType is not \"Hue\"", "hue");
                }
                else
                {
                    transitionDefinition.Parameters.Add(new Parameter(KeyTransitionParameter.Hue, hue.Value));
                }
            }

            if (luminance.HasValue)
            {
                if ((luminance < 0) || (luminance > 100))
                {
                    throw new ArgumentOutOfRangeException("luminance", "luminance must be between 0 and 100");
                }
                else if (transitionType != KeyTransitionType.Hue)
                {
                    throw new ArgumentException("hue specified but selected key transitionType is not \"Hue\"", "hue");
                }
                else
                {
                    transitionDefinition.Parameters.Add(
                        new Parameter(KeyTransitionParameter.Luminance, luminance.Value));
                }
            }

            if (rgb.HasValue)
            {
                if ((rgb < 0) || (rgb > 0xFFFFFF))
                {
                    throw new ArgumentOutOfRangeException("rgb", "rgb must be between 0x000000 and 0xFFFFFF");
                }
                else if (transitionType != KeyTransitionType.Rgb)
                {
                    throw new ArgumentException("rgb specified but selected key transitionType is not \"Rgb\"", "rgb");
                }
                else
                {
                    transitionDefinition.Parameters.Add(new Parameter(KeyTransitionParameter.Rgb, rgb.Value));
                }
            }

            if (similarity.HasValue)
            {
                if ((similarity < 0) || (similarity > 100))
                {
                    throw new ArgumentOutOfRangeException("similarity", "similarity must be between 0 and 100");
                }
                else if ((transitionType != KeyTransitionType.Rgb) && (transitionType != KeyTransitionType.NoRed))
                {
                    throw new ArgumentException(
                              "similarity specified but selected key transitionType does not support it",
                              "similarity");
                }
                else
                {
                    transitionDefinition.Parameters.Add(
                        new Parameter(KeyTransitionParameter.Similarity, similarity.Value));
                }
            }

            if (invert.HasValue)
            {
                if ((transitionType != KeyTransitionType.Rgb) && (transitionType != KeyTransitionType.Hue) &&
                    (transitionType != KeyTransitionType.Luminance) &&
                    (transitionType != KeyTransitionType.NoRed))
                {
                    throw new ArgumentException("invert specified but selected key transitionType does not support it",
                                                "invert");
                }
                else
                {
                    transitionDefinition.Parameters.Add(new Parameter(KeyTransitionParameter.Invert, invert.Value));
                }
            }

            return(transitionDefinition);
        }