簡體   English   中英

不使用SolidColorBrush從Color獲取畫筆

[英]Get Brush from Color without SolidColorBrush

看起來SolidColorBrush需要.NET 3或更高版本,並且我要求不要求制造計算機進行升級。

因此,給定System.Drawing.Color color ,我將如何創建System.Drawing.Brush

public static Brush GetBrush(Color color) {
  Brush result = Brushes.Black;
  // What goes here?
  return result;
}

我在Brushes中看到的唯一靜態方法是EqualsReferenceEquals ; 非靜態只是Clone

編輯:(已解決 - 感謝SLaks

使用System.Drawing.SolidBrush ,我能夠寫:

public static Brush GetBrush(Color color) {
  if (color != Color.Empty) {
    return new SolidBrush(color);
  }
  return Brushes.Black;
}

你看到的是WPF SolidColorBrush。
WPF本身是.Net 3.0的新手。

GDI +(System.Drawing) SolidBrush一直存在。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM