1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- using System;
- using System.Globalization;
- using System.Windows.Data;
- using System.Windows.Markup;
- using System.Windows.Media;
- using AIPractice.Shared.Labels;
- namespace AIPractice.LabelEditor
- {
- [MarkupExtensionReturnType(typeof(IValueConverter))]
- public class MalignantLevelToBrushConverter : MarkupExtension, IValueConverter
- {
- public static MalignantLevelToBrushConverter Converter { get; private set; }
- static MalignantLevelToBrushConverter()
- {
- Converter = new MalignantLevelToBrushConverter();
- }
- public override object ProvideValue(IServiceProvider serviceProvider)
- {
- return Converter ?? (Converter = new MalignantLevelToBrushConverter());
- }
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value != null)
- {
- var level = (MalignantLevel)value;
- switch (level)
- {
- case MalignantLevel.Low:
- return Brushes.Black;
- case MalignantLevel.Middle:
- return Brushes.DarkOrange;
- case MalignantLevel.High:
- return Brushes.Red;
- default:
- return Brushes.Black;
- }
- }
- return Brushes.Black;
- }
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
- }
|