• Silverlight Color的颜色值


    1.MainPage.xaml

    <UserControl xmlns:SysManage="clr-namespace:Application"  x:Class="Application.MainManage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        mc:Ignorable="d"   d:DesignHeight="750" d:DesignWidth="1024">
    
        <Grid x:Name="LayoutRoot"  Background="#EFEFEF" Margin="30,0,30,0">
    
    </Grid>

    2.MainPage.xaml.cs

    this.LayoutRoot.Background = SkinColor.GetTopBrush();

    3.SkinColor.cs

    static public class SkinColor
        {
            static string[] topcolorintro = { "5f8ac1", "bd0000", "1d4598", "1f2537", "ffffff" };
            static string[] topcolor = { "81aadc", "150000", "041537", "000000", "ffffff" };
            static string[] memubgcolor = { "ffffff", "dd0000", "5c8730", "656c7b", "e1ecfe" };
            static string[] memulanbgcolor = { "cbdbee", "440000", "14316f", "222530", "c3d9ff" };
            static string[] bgcolor1 = { "5e86b8", "280000", "0840a9", "010203", "ffffff" };
            static string[] bgcolor2 = { "9abbe3", "680000", "0161c9", "131829", "ffffff" };
            static string[] bottombg = { "cbdbee", "440000", "14316f", "222530", "c3d9ff" };
            static string[] bottomMiddle = { "81aadc", "150000", "041537", "000000", "ffffff" };
            static public void SetColor(int cindex)
            {
                SkinType.color = cindex;    
            }
    
            static public SolidColorBrush GetTopIntroBrush()
            {
                return new SolidColorBrush(qxsl.Tools.Common.ToColor(topcolorintro[SkinType.color]));
            }
    
            static public SolidColorBrush GetBottomBrush()
            {
                return new SolidColorBrush(qxsl.Tools.Common.ToColor(bottombg[SkinType.color]));
            }
            static public SolidColorBrush GetBottomMiddleBrush()
            {
                return new SolidColorBrush(qxsl.Tools.Common.ToColor(bottomMiddle[SkinType.color]));
            }
            static public SolidColorBrush GetTopBrush()
            {
                return new SolidColorBrush(qxsl.Tools.Common.ToColor(topcolor[SkinType.color]));
            }
    
            static public SolidColorBrush GetMenuBgBrush()
            {
                return new SolidColorBrush(qxsl.Tools.Common.ToColor(memubgcolor[SkinType.color]));
            }
    
            static public SolidColorBrush GetMemuLanbgBrush()
            {
                return new SolidColorBrush(qxsl.Tools.Common.ToColor(memulanbgcolor[SkinType.color]));
            }
    
            static public LinearGradientBrush GetbgBrush()
            {
                LinearGradientBrush gradient = new LinearGradientBrush();
                gradient.StartPoint = new Point(0, 0);
                gradient.EndPoint = new Point(0, 1);
    
                GradientStop color1 = new GradientStop();
                color1.Color = qxsl.Tools.Common.ToColor(bgcolor1[SkinType.color]);
                color1.Offset = 0.2;
                gradient.GradientStops.Add(color1);
    
                GradientStop color2 = new GradientStop();
                color2.Color = qxsl.Tools.Common.ToColor(bgcolor2[SkinType.color]);
                color2.Offset = 0.8;
                gradient.GradientStops.Add(color2);
                return gradient;
            }
        }
    static  public class SkinType
        {
            //blue=1,
            //red=2,
            //darkblue=3,
            //black=4,
            //white=5
          /// <summary>
          ///blue=1,red=2,darkblue=3,black=4,white=5
          /// </summary>
          static public int color;
    
        }    

    4.颜色转换

     public  static class Common
        {
            /// <summary>
            ///颜色转化
            /// </summary>
            /// <param name="colorName"></param>
            /// <returns></returns>
            public static Color ToColor(string colorName)
            {
                if (colorName.StartsWith("#"))
                    colorName = colorName.Replace("#", string.Empty);
                var c = new Color
                {
                    A = 0xFF,
                    R = Convert.ToByte(colorName.Substring(0, 2), 16),
                    G = Convert.ToByte(colorName.Substring(2, 2), 16),
                    B = Convert.ToByte(colorName.Substring(4, 2), 16)
                };
    
    
                return c;
            }
        }
  • 相关阅读:
    Ubuntu安装Apache
    【C#设计模式——创建型模式】抽象工厂模式
    【C#设计模式——创建型模式】工场方法模式
    【C#设计模式——创建型模式】简单工场模式
    JS判断是不是Decimal类型(正则实现)
    JS实现给页面表单设置触发默认按钮
    记录ASP.NET页面表单初始状态(主要是为了前台可以根据这个判断页面是否变动了)
    Js触发ASP.NET Validation控件的验证, 同时获取前台验证结果(不包括CustomValidator)
    根据字段名查找表名
    SqlServer判断数据库、表、存储过程、函数是否存在
  • 原文地址:https://www.cnblogs.com/zxbzl/p/3912998.html
Copyright © 2020-2023  润新知