Esempio n. 1
0
        /// <summary>
        /// Creates a new instance of the <see cref="DeviceAttribute"/> struct
        /// </summary>
        /// <param name="Opacity">Opacity</param>
        /// <param name="Reflectivity">Reflectivity</param>
        /// <param name="Polarity">Polarity</param>
        /// <param name="Chroma">Chroma</param>
        /// <param name="VendorData">Additional vendor specific data</param>
        public DeviceAttribute(OpacityAttribute Opacity, ReflectivityAttribute Reflectivity,
                               PolarityAttribute Polarity, ChromaAttribute Chroma, byte[] VendorData)
        {
            if (VendorData == null)
            {
                throw new ArgumentNullException(nameof(VendorData));
            }
            if (VendorData.Length != 4)
            {
                throw new ArgumentException($"{nameof(VendorData)} must have a length of 4");
            }

            if (!Enum.IsDefined(typeof(OpacityAttribute), Opacity))
            {
                throw new ArgumentException($"{nameof(Opacity)} value is not of a defined Enum value");
            }
            if (!Enum.IsDefined(typeof(ReflectivityAttribute), Reflectivity))
            {
                throw new ArgumentException($"{nameof(Reflectivity)} value is not of a defined Enum value");
            }
            if (!Enum.IsDefined(typeof(PolarityAttribute), Polarity))
            {
                throw new ArgumentException($"{nameof(Polarity)} value is not of a defined Enum value");
            }
            if (!Enum.IsDefined(typeof(ChromaAttribute), Chroma))
            {
                throw new ArgumentException($"{nameof(Chroma)} value is not of a defined Enum value");
            }

            this.Opacity      = Opacity;
            this.Reflectivity = Reflectivity;
            this.Polarity     = Polarity;
            this.Chroma       = Chroma;
            this.VendorData   = VendorData;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new instance of the <see cref="DeviceAttribute"/> struct
        /// </summary>
        /// <param name="Opacity">Opacity</param>
        /// <param name="Reflectivity">Reflectivity</param>
        /// <param name="Polarity">Polarity</param>
        /// <param name="Chroma">Chroma</param>
        /// <param name="VendorData">Additional vendor specific data</param>
        public DeviceAttribute(bool Opacity, bool Reflectivity, bool Polarity, bool Chroma, byte[] VendorData)
        {
            if (VendorData == null)
            {
                throw new ArgumentNullException(nameof(VendorData));
            }
            if (VendorData.Length != 4)
            {
                throw new ArgumentException("VendorData must have a length of 4");
            }

            if (Opacity)
            {
                this.Opacity = OpacityAttribute.Transparency;
            }
            else
            {
                this.Opacity = OpacityAttribute.Reflective;
            }

            if (Reflectivity)
            {
                this.Reflectivity = ReflectivityAttribute.Matte;
            }
            else
            {
                this.Reflectivity = ReflectivityAttribute.Glossy;
            }

            if (Polarity)
            {
                this.Polarity = PolarityAttribute.Negative;
            }
            else
            {
                this.Polarity = PolarityAttribute.Positive;
            }

            if (Chroma)
            {
                this.Chroma = ChromaAttribute.BlackWhite;
            }
            else
            {
                this.Chroma = ChromaAttribute.Color;
            }

            this.VendorData = VendorData;
        }
Esempio n. 3
0
 /// <summary>
 /// Creates a new instance of the <see cref="DeviceAttribute"/> struct
 /// </summary>
 /// <param name="Opacity">Opacity</param>
 /// <param name="Reflectivity">Reflectivity</param>
 /// <param name="Polarity">Polarity</param>
 /// <param name="Chroma">Chroma</param>
 public DeviceAttribute(OpacityAttribute Opacity, ReflectivityAttribute Reflectivity,
                        PolarityAttribute Polarity, ChromaAttribute Chroma)
     : this(Opacity, Reflectivity, Polarity, Chroma, new byte[4])
 {
 }