Files
aistudio-wpf-diagram/AIStudio.Wpf.DiagramDesigner/Converters/BrushOpacityConverter.cs
2023-03-03 18:59:02 +08:00

27 lines
800 B
C#

using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;
namespace AIStudio.Wpf.DiagramDesigner
{
public class BrushOpacityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is SolidColorBrush brush)
{
var opacity = System.Convert.ToDouble(parameter, CultureInfo.InvariantCulture);
return new SolidColorBrush(brush.Color)
{
Opacity = opacity
};
}
return null;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
=> Binding.DoNothing;
}
}