41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
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 OptionsValueConverter : IValueConverter
|
|
{
|
|
private static readonly OptionsValueConverter _instance = new OptionsValueConverter();
|
|
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (!(value is HashSet<int>) || targetType != typeof(Brush) || !(parameter is int))
|
|
throw new InvalidCastException();
|
|
|
|
HashSet<int> set = (HashSet<int>)value;
|
|
int number = (int)parameter;
|
|
|
|
if (set.Contains(number) && BoardModel.CheatMode)
|
|
return NumberBrushes.GetBrush(number, Constants.CheatActivedFontColor);
|
|
else
|
|
return Brushes.Transparent;
|
|
}
|
|
|
|
// Create a property to get the instance of the OptionsValue
|
|
public static OptionsValueConverter Instance
|
|
{
|
|
get { return _instance; }
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
}
|