Exemplo n.º 1
0
        //============================================================
        // <T>转换内容为指定类型。</T>
        //
        // @param context 环境
        // @param culture 文化
        // @param value 内容
        // @param destinationType 目标类型
        // @return 是否含有位图
        //============================================================
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
        {
            FUiColor source = (FUiColor)value;

            if (source != null)
            {
                return(source.ToString());
            }
            return(null);
        }
Exemplo n.º 2
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)
     {
         FUiColor source = new FUiColor();
         if (source.ParseHex(value as string))
         {
             source.Valid = true;
             return(source);
         }
     }
     return(null);
 }
Exemplo n.º 3
0
        //============================================================
        // <T>生成设计颜色。</T>
        //
        // @param color 颜色
        // @return 颜色
        //============================================================
        public FUiColor BuildDesignColor(SColor color)
        {
            string   code   = color.ToValue().ToString();
            FUiColor result = _designColors.Find(code);

            if (result == null)
            {
                result = new FUiColor();
                result.Set(color.R, color.G, color.B, color.A);
                result.brush = _context.Device.CreateSolidBrush(result);
                _designColors.Set(code, result);
            }
            return(result);
        }
Exemplo n.º 4
0
 //============================================================
 // <T>配置颜色处理。</T>
 //
 // @param color 颜色
 //============================================================
 public void SetupColor(FUiColor color)
 {
     if (color == null)
     {
         return;
     }
     if (!color.Valid)
     {
         return;
     }
     if (color.brush == null)
     {
         color.brush = _context.Device.CreateSolidBrush(color);
     }
     else
     {
         FDxSolidBrush brush = color.brush as FDxSolidBrush;
         if (brush.Color.ToValue() != color.ToValue())
         {
             color.brush = _context.Device.CreateSolidBrush(color);
         }
     }
 }
Exemplo n.º 5
0
        //============================================================
        // <T>绘制边框。</T>
        //
        // @param border 边框描述
        //============================================================
        public void DrawBorder(FRcBorder innerBorder, FRcBorder outerBorder)
        {
            int outerLeft   = outerBorder.Left.Width;
            int outerTop    = outerBorder.Top.Width;
            int outerRight  = outerBorder.Right.Width;
            int outerBottom = outerBorder.Bottom.Width;
            int innerLeft   = innerBorder.Left.Width;
            int innerTop    = innerBorder.Top.Width;
            int innerRight  = innerBorder.Right.Width;
            int innerBottom = innerBorder.Bottom.Width;

            // 外左边框
            if (0 < outerLeft)
            {
                FUiColor borderColor = _context.BuildDesignColor(outerBorder.Left.Color);
                _context.Context.DrawLine(borderColor.brush, 0, 0, 0, ControlResource.Size.Height, outerLeft);
            }
            // 内左边框
            if (0 < innerLeft)
            {
                float    x1          = outerLeft / 2 + innerLeft / 2 + innerLeft % 2;
                float    y1          = outerTop / 2;
                float    x2          = outerLeft / 2 + innerLeft / 2 + innerLeft % 2;
                float    y2          = ControlResource.Size.Height - outerBottom / 2;
                FUiColor borderColor = _context.BuildDesignColor(innerBorder.Left.Color);
                _context.Context.DrawLine(borderColor.brush, x1, y1, x2, y2, innerLeft);
            }
            // 外上边框
            if (0 < outerTop)
            {
                FUiColor borderColor = _context.BuildDesignColor(outerBorder.Top.Color);
                _context.Context.DrawLine(borderColor.brush, 0, 0, ControlResource.Size.Width, 0, outerTop);
            }
            // 内上边框
            if (0 < innerTop)
            {
                float    x1          = outerLeft / 2;
                float    y1          = outerTop / 2 + innerTop / 2 + innerTop % 2;
                float    x2          = ControlResource.Size.Width - (outerRight / 2 + outerRight % 2);
                float    y2          = outerTop / 2 + innerTop / 2 + innerTop % 2;
                FUiColor borderColor = _context.BuildDesignColor(innerBorder.Top.Color);
                _context.Context.DrawLine(borderColor.brush, x1, y1, x2, y2, innerLeft);
            }
            // 外右边框
            if (0 < outerRight)
            {
                FUiColor borderColor = _context.BuildDesignColor(outerBorder.Right.Color);
                _context.Context.DrawLine(borderColor.brush, ControlResource.Size.Width, 0, ControlResource.Size.Width, ControlResource.Size.Height, outerRight);
            }
            // 内右边框
            if (0 < innerRight)
            {
                float    x1          = ControlResource.Size.Width - (outerRight / 2 + outerRight % 2 + innerRight / 2);
                float    y1          = outerTop / 2;
                float    x2          = ControlResource.Size.Width - (outerRight / 2 + outerRight % 2 + innerRight / 2);
                float    y2          = ControlResource.Size.Height - (outerBottom / 2 + outerBottom % 2);
                FUiColor borderColor = _context.BuildDesignColor(innerBorder.Right.Color);
                _context.Context.DrawLine(borderColor.brush, x1, y1, x2, y2, innerLeft);
            }
            // 外下边框
            if (0 < outerBottom)
            {
                FUiColor borderColor = _context.BuildDesignColor(outerBorder.Bottom.Color);
                _context.Context.DrawLine(borderColor.brush, 0, ControlResource.Size.Height, ControlResource.Size.Width, ControlResource.Size.Height, outerBottom);
            }
            // 内下边框
            if (0 < innerBottom)
            {
                float    x1          = outerLeft / 2;
                float    y1          = ControlResource.Size.Height - (outerBottom / 2 + outerBottom % 2 + innerBottom / 2);
                float    x2          = ControlResource.Size.Width - (outerRight / 2 + outerRight % 2);
                float    y2          = ControlResource.Size.Height - (outerBottom / 2 + outerBottom % 2 + innerBottom / 2);
                FUiColor borderColor = _context.BuildDesignColor(innerBorder.Bottom.Color);
                _context.Context.DrawLine(borderColor.brush, x1, y1, x2, y2, innerLeft);
            }
        }