String、Brush、Color 相互转换
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;
String、Brush、Color 相互转换的更多相关文章
- c#-WPF string,color,brush之间的转换
原文:c#-WPF string,color,brush之间的转换 String转换成Color string-"ffffff" Color color = (Color)Colo ...
- String与InputStream相互转换
1.String to InputStream String str = "String与InputStream相互转换"; InputStream in_nocode = ...
- C#中String 与Color之间的相互转换
C#中String 与Color之间的相互转换 ————————————宋兴柱 其实,我们平常如果要在数据库存放Color类型值的话,肯定会在数据库中建立varchar类型.对吧.但是Colo ...
- C#中string和byte[]相互转换问题解决
本来想讲string转换为byte数组,通过在VS上打 ‘str. “来找,结果半天没发现跳出来的函数中有想要的,哭瞎 /(ㄒoㄒ)/~~ 这回将两种情况都记下来了.... string ---> ...
- String转Color
原文:String转Color 很硬性的转换,谁知道更好的忘不吝赐教啊. /// <summary> /// String To Color /// </summary> // ...
- String与StringBuilder相互转换以及获取字符串中第一个中文汉字
String与StringBuilder相互转换 1. StringBuilder转为String StringBuilder sb = new StringBuilder(); sb.append( ...
- WPF string,color,brush之间的转换
String转换成Color string-"ffffff" Color color = (Color)ColorConverter.ConvertFromString(strin ...
- C# Brush Color String 互相转换
using System.Windows.Media; //String转换成Color Color color = (Color)ColorConverter.ConvertFromString(s ...
- string 至 Color 转换演示示例:
string colorstr = "#FF4D4D4D";string hex = colorstr.ToString().Replace("#", &quo ...
随机推荐
- HDOJ_1010 Tempter of the Bone
http://acm.hdu.edu.cn/showproblem.php?pid=1010 奇偶剪枝:可以把map看成这样: 0 1 0 1 0 1 1 0 1 0 1 0 0 1 0 1 0 1 ...
- [iOS微博项目 - 2.2] - 在app中获取授权
github: https://github.com/hellovoidworld/HVWWeibo A.发送授权请求 1.使用UIWebView加载请求页面 自定义一个继承UIViewContr ...
- DefWndProc/WndProc/IMessageFilter的区别
谈到Winform的消息处理,多数时候是通过事件处理程序进行的,但当没有对应的事件时通常的做法是声明DefWndProc或者WndProc或者IMessageFilter,经常在网上看见有文章将三者并 ...
- Pongo建立信号基站-实际上还是考中位数
题目: 要建立一个信号基站服务n个村庄,这n个村庄用平面上的n个点表示.假设基站建立的位置在(X,Y),则它对某个村庄(x,y)的距离为max{|X – x|, |Y – y|}, 其中| |表示绝对 ...
- hdu 2881 Jack's struggle(DP)
对于所有的任务所在的地点按照时间排序,可以将其看成是一道非常简单的“天上掉馅饼”的题的二维版本. 将这些任务看成从天而降的馅饼,统计有哪些之前馅饼掉落的位置可以在两者时间差内到达该点的点,取其最大值. ...
- iOS7 各种问题解决
1 UITableView 行分割线不到头,短线问题 if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) { ...
- IE下判断IE版本的语句...[if lte IE 6]……[endif]
<!--[if lte IE 6]> <![endif]--> IE6及其以下版本可见 <!--[if lte IE 7]> <![endif]--> ...
- Label & TextBlock
I always thought it was odd that WPF has both TextBlock and Label. They both are responsible for di ...
- OC:点语法
IOS中的@property 与 assign copy retain 的区别参考 //@理解为 OC 代码的标记 //如何去创建一个对象 创建对象的两步: // (1)为对象在堆区中开辟空间 Stu ...
- Android Studio 0.4 + PhoneGap 3.3 开发环境的搭建
最近在尝试HTML5移动平台下的开发 由于安卓的方便性,首先开始了安卓的试验 现在安卓下的开发工具首选 Android Studio (写这文章的时候,是0.4) 而跨平台的HTML5 App比较出名 ...