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; } }
Silverlight Color的颜色值,布布扣,bubuko.com
原文:http://www.cnblogs.com/zxbzl/p/3912998.html