This repository was archived by the owner on Jul 17, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathColorToColorConverter.cs
More file actions
53 lines (47 loc) · 1.84 KB
/
Copy pathColorToColorConverter.cs
File metadata and controls
53 lines (47 loc) · 1.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Globalization;
using DeveloperSample.Core.Helpers;
using Xamarin.Forms;
namespace DeveloperSample.Core.Converters
{
public abstract class BaseColorToColorConverter : IValueConverter
{
public abstract object Convert(object value, Type targetType, object parameter, CultureInfo culture);
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
[ValueConversion(typeof(Color), typeof(Color))]
public class ColorToBlackOrWhiteConverter : BaseColorToColorConverter
{
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is Color input ? input.ToBlackOrWhite() : Color.Black;
}
}
[ValueConversion(typeof(Color), typeof(Color))]
public class ColorToColorForTextConverter : BaseColorToColorConverter
{
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is Color input ? input.ToBlackOrWhiteForText() : Color.Black;
}
}
[ValueConversion(typeof(Color), typeof(Color))]
public class ColorToGrayScaleColorConverter : BaseColorToColorConverter
{
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is Color input ? input.ToGrayScale() : Color.Black;
}
}
[ValueConversion(typeof(Color), typeof(Color))]
public class ColorToInverseColorConverter : BaseColorToColorConverter
{
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
return value is Color input ? input.Inverse() : Color.Black;
}
}
}