zoukankan      html  css  js  c++  java
  • 【转】C# 的Brush 及相关颜色的操作

    // (实心刷)
    Rectangle rect1 = new Rectangle(20, 80, 250, 100);
    SolidBrush sbrush1 = new SolidBrush(Color.DarkOrchid);                  
    SolidBrush sbrush2 = new SolidBrush(Color.Aquamarine);      
    SolidBrush sbrush3 = new SolidBrush(Color.DarkOrange);
    //(梯度刷)
    LinearGradientBrush lbrush1 = new LinearGradientBrush(rect1,
    Color.DarkOrange, Color.Aquamarine,
    LinearGradientMode.BackwardDiagonal);
    
    //(阴影刷)
    HatchBrush hbrush1 = new HatchBrush(HatchStyle.DiagonalCross,
    Color.DarkOrange, Color.Aquamarine);
    HatchBrush hbrush2 = new HatchBrush(HatchStyle.DarkVertical,
    Color.DarkOrange, Color.Aquamarine);
    HatchBrush hbrush3 = new HatchBrush(HatchStyle.LargeConfetti,
    Color.DarkOrange, Color.Aquamarine);
    
    //(纹理刷)
    textureBrush = new TextureBrush(new Bitmap(@"e:123.jpg"));
    //e.Graphics.FillRectangle(hbrush1, rect1);
    //e.Graphics.FillRectangle(sbrush1, rect1);
    //e.Graphics.FillRectangle(textureBrush, rect1);
    e.Graphics.FillRectangle(lbrush1, rect1);
    using System.Windows.Media;
    
    1、String转换成Color
    
                Color color = (Color)ColorConverter.ConvertFromString(string);
    
    2、String转换成Brush
    
                BrushConverter brushConverter = new BrushConverter();
                Brush brush = (Brush)brushConverter.ConvertFromString(string);
    
    3、Color转换成Brush
    
                Brush brush = new SolidColorBrush(color));
    
    4、Brush转换成Color有两种方法:
    
    (1)先将Brush转成string,再转成Color。
    
                Color color= (Color)ColorConverter.ConvertFromString(brush.ToString());
    
    (2)将Brush转成SolidColorBrush,再取Color。
    
                Color color= ((SolidColorBrush)CadColor.Background).Color;
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title></title>
        <script src="../../../JS/jquerycj/jquery-1.7.2.min.js" type="text/javascript"></script>
        <style>
            
        </style>
        <script>
            var s;
            var studata = [
                { id: 1, name: '张三', selected: true },
                { id: 2, name: '深蓝色', selected: true },
                { id: 3, name: '肖西林', selected: true },
                { id: 4, name: '田伟', selected: true },
                { id: 5, name: '李四', selected: true },
                { id: 6, name: '彭平', selected: false },
                { id: 7, name: '张三丰', selected: false },
                { id: 8, name: '肖西林', selected: false },
                { id: 9, name: '肖西林', selected: false },
                { id: 32, name: '肖西林', selected: false },
                { id: 22, name: '肖西林', selected: false },
                { id: 65, name: '肖西林', selected: false },
            ];
                $(function() {
                     s = new SelectStu('select_stubox',studata);
                 });
                //取值
                function tt() {
                    alert(s.val());
                }
        </script>
        <link href="http://localhost:12580/SOA/common/SelectStu/selectStu.css" rel="stylesheet" type="text/css" />
        <script src="http://localhost:12580/SOA/common/SelectStu/selectStu.js" type="text/javascript"></script>
    </head>
    <body>
    
        <form id="form1" runat="server">
        
       <div id = "select_stubox" style="600px;">
        </div>
        <input type="button" value="tt" onclick="tt();" />
        </form>
    </body>
    </html>
  • 相关阅读:
    一种循环方式
    SqlServer循环读取配置
    app抓包
    c# 前端写代码的情况
    第36月第27日 codesign重签名
    第36月第26天 吴恩达 目标检测
    第36月第25天 TensorFlow Object_detection
    第36月第19天 多个tomcat查端口
    第36月第8天 flask_bootstrap
    第36月第5天 升级到 XCode10.3 项目中的xib报错
  • 原文地址:https://www.cnblogs.com/ZXdeveloper/p/4703830.html
Copyright © 2011-2022 走看看