using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;

namespace TEAMModelOS.SDK.Helper.Common.ColorHelper
{
    /// <summary>
    /// 类      名：ColorRGB
    /// 功      能：R 红色 \ G 绿色 \ B 蓝色 颜色模型
    ///                 所有颜色模型的基类，RGB是用于输出到屏幕的颜色模式，所以所有模型都将转换成RGB输出
    /// </summary>
    public class ColorRGB
    {
        /// <summary>
        /// 构造方法
        /// </summary>
        /// <param name="r"></param>
        /// <param name="g"></param>
        /// <param name="b"></param>
        public ColorRGB(int r, int g, int b)
        {
            this._r = r;
            this._g = g;
            this._b = b;
        }

        private int _r;
        private int _g;
        private int _b;

        /// <summary>
        /// 红色
        /// </summary>
        public int R
        {
            get { return this._r; }
            set
            {
                this._r = value;
                this._r = this._r > 255 ? 255 : this._r;
                this._r = this._r < 0 ? 0 : this._r;
            }
        }

        /// <summary>
        /// 绿色
        /// </summary>
        public int G
        {
            get { return this._g; }
            set
            {
                this._g = value;
                this._g = this._g > 255 ? 255 : this._g;
                this._g = this._g < 0 ? 0 : this._g;
            }
        }

        /// <summary>
        /// 蓝色
        /// </summary>
        public int B
        {
            get { return this._b; }
            set
            {
                this._b = value;
                this._b = this._b > 255 ? 255 : this._b;
                this._b = this._b < 0 ? 0 : this._b;
            }
        }

        /// <summary>
        /// 获取实际颜色
        /// </summary>
        /// <returns></returns>
        public Color GetColor()
        {
            return Color.FromArgb(this._r, this._g, this._b);
        }
    } 
}
