添加项目文件。
This commit is contained in:
46
Szmedi.RvKits/Converters/ColorToBrushConverter.cs
Normal file
46
Szmedi.RvKits/Converters/ColorToBrushConverter.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
|
||||
using Autodesk.Revit.DB;
|
||||
|
||||
using ColorHelper;
|
||||
|
||||
using System;
|
||||
|
||||
using System.Globalization;
|
||||
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Szmedi.RvKits.Converters
|
||||
{
|
||||
class ColorToBrushConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is Color color)
|
||||
{
|
||||
var col = System.Windows.Media.Color.FromRgb(color.Red, color.Green, color.Blue);
|
||||
return new System.Windows.Media.SolidColorBrush(col);
|
||||
}
|
||||
return new System.Windows.Media.SolidColorBrush();
|
||||
}
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
class RGBToBrushConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is RGB color)
|
||||
{
|
||||
var col = System.Windows.Media.Color.FromRgb(color.R, color.G, color.B);
|
||||
return new System.Windows.Media.SolidColorBrush(col);
|
||||
}
|
||||
return new System.Windows.Media.SolidColorBrush();
|
||||
}
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user