using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Data; using System.Globalization; using System.Windows.Media; namespace SudokuWeek4.Models.Converters { internal class Number2BrushValueConverter : IValueConverter { private static readonly Number2BrushValueConverter _instance = new Number2BrushValueConverter(); public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (!(value is int) || targetType != typeof(Brush)) throw new InvalidCastException(); int number = (int)value; return NumberBrushes.GetBrush(number, (Color)parameter); } // Create a property to get the instance of the Number2BrushValue public static Number2BrushValueConverter Instance { get { return _instance; } } public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }