Pass color name as string in SharpDX.Color

浪尽此生 提交于 2019-12-11 19:12:46

问题


i am getting a color name as string (like "Black"). have to convert that color name as SharpDX.Color for my Metro app. now trying in following ways,

1)SharpDX.Color.FromRgba(int or uint value of color)
2)SharpDX.Color.FromArgb(int or uint value of color)

is it possible to do this in this way.? or any other best way to done this.??


回答1:


Using Enum Parse and System.Drawing can help, it's not great but that would work:

KnownColor colorenum = (KnownColor)Enum.Parse(typeof(KnownColor),"Black");

Color4 bgcolor = new Color4(Color.FromKnownColor(colorenum).ToArgb());

Otherwise you can build a custom Dictionary with string as key and SharpDX.Color4 as value, and create your own list of colors.



来源:https://stackoverflow.com/questions/12857760/pass-color-name-as-string-in-sharpdx-color

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!