System.Drawing.Brush from System.Drawing.Color

☆樱花仙子☆ 提交于 2019-12-28 06:18:26

问题


I'm developing a WinForm Printing application for our company.

When the document is printed, I need to take the System.Drawing.Color property of each Control on the document and create a System.Drawing.Brush object to draw it.

Is there a way to convert the System.Drawing.Color value to a System.Drawing.Brush value?

NOTE: I've tried looking into the System.Windows.Media.SolidColorBrush() method, but it does not seem to be helpful.


回答1:


Use the SolidBrush class:

using (SolidBrush brush = new SolidBrush(yourColor)) {
    // ...
}



回答2:


Why not the GDI+ brush?

http://msdn.microsoft.com/en-us/library/system.drawing.solidbrush.solidbrush.aspx

The other one is for WPF.



来源:https://stackoverflow.com/questions/5734763/system-drawing-brush-from-system-drawing-color

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