Skip to content

Commit

Permalink
Refactor IValueConverter for color to gradiant.
Browse files Browse the repository at this point in the history
  • Loading branch information
mohammadKarimi committed Nov 25, 2024
1 parent 5710b0d commit ff8ece7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/Riter/Core/Drawing/ColorToGradientConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class ColorToGradientConverter : IValueConverter
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is string inkColor && inkColor == InkColor.RainBow.ToString())
{
return new LinearGradientBrush
{
GradientStops =
Expand All @@ -24,14 +25,15 @@ public object Convert(object value, Type targetType, object parameter, CultureIn
StartPoint = new Point(0, 0),
EndPoint = new Point(1, 0),
};
}
else if (value is string colorName && !string.IsNullOrEmpty(colorName))
{
return new SolidColorBrush((Color)ColorConverter.ConvertFromString(colorName));
}

return Brushes.Transparent;
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
=> throw new NotImplementedException();
}

0 comments on commit ff8ece7

Please sign in to comment.