Example #1
0
        //============================================================
        // <T>从字符串中解析一个颜色。</T>
        //
        // @param value 字符串
        // @return 颜色
        //============================================================
        public static Color ParseColorFromString(string value)
        {
            FRcColor color = new FRcColor();

            color.Parse(value);
            return(Color.FromArgb(color.Alpha, color.Red, color.Green, color.Blue));
        }
Example #2
0
        //============================================================
        // <T>转换内容为指定类型。</T>
        //
        // @param context 环境
        // @param culture 文化
        // @param value 内容
        // @param destinationType 目标类型
        // @return 是否含有位图
        //============================================================
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            FRcColor source = (FRcColor)value;

            if (source != null)
            {
                return(source.ToString());
            }
            return(null);
        }
Example #3
0
 //============================================================
 // <T>从指定类型转换为内容。</T>
 //
 // @param context 环境
 // @param culture 文化
 // @param value 内容
 // @param destinationType 目标类型
 // @return 是否含有位图
 //============================================================
 public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
 {
     if (value is string)
     {
         FRcColor source = new FRcColor();
         if (source.Parse(value as string))
         {
             source.Valid = true;
             return(source);
         }
     }
     return(null);
 }
Example #4
0
 //============================================================
 // <T>接收颜色对象。</T>
 //
 // @param constainsValid 颜色对象
 //============================================================
 public void Assign(FRcColor color, bool constainsValid = true)
 {
     if (color == null)
     {
         return;
     }
     if (constainsValid)
     {
         Valid = color.Valid;
     }
     _alpha = color.Alpha;
     _red   = color.Red;
     _green = color.Green;
     _blue  = color.Blue;
 }