Initial commit
This commit is contained in:
41
Sudoku_-_DLL/Models/Converters/BackgroundValueConverter.cs
Normal file
41
Sudoku_-_DLL/Models/Converters/BackgroundValueConverter.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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 BackgroundValueConverter : IValueConverter
|
||||
{
|
||||
private static readonly BackgroundValueConverter _instance = new BackgroundValueConverter();
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is Boolean && targetType == typeof(Brush))
|
||||
{
|
||||
Boolean color = (Boolean)value;
|
||||
if (color)
|
||||
return Brushes.Red;
|
||||
else
|
||||
return Brushes.Transparent;
|
||||
}
|
||||
|
||||
// The type is not a brush
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create a property to get the instance of the BackgroundValue
|
||||
public static BackgroundValueConverter Instance
|
||||
{
|
||||
get { return _instance; }
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
41
Sudoku_-_DLL/Models/Converters/BorderValueConverter.cs
Normal file
41
Sudoku_-_DLL/Models/Converters/BorderValueConverter.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
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 BorderValueConverter : IValueConverter
|
||||
{
|
||||
private static readonly BorderValueConverter _instance = new BorderValueConverter();
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (value is Boolean && targetType == typeof(Brush))
|
||||
{
|
||||
Boolean color = (Boolean)value;
|
||||
if (color)
|
||||
return Brushes.Orange;
|
||||
else
|
||||
return Brushes.Transparent;
|
||||
}
|
||||
|
||||
// The type is not a brush
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create a property to get the instance of the BorderValue
|
||||
public static BorderValueConverter Instance
|
||||
{
|
||||
get { return _instance; }
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
35
Sudoku_-_DLL/Models/Converters/Number2BrushValueConverter.cs
Normal file
35
Sudoku_-_DLL/Models/Converters/Number2BrushValueConverter.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
40
Sudoku_-_DLL/Models/Converters/OptionsValueConverter.cs
Normal file
40
Sudoku_-_DLL/Models/Converters/OptionsValueConverter.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
41
Sudoku_-_DLL/Models/Converters/VisibilityValueConverter.cs
Normal file
41
Sudoku_-_DLL/Models/Converters/VisibilityValueConverter.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Data;
|
||||
using System.Globalization;
|
||||
using System.Windows;
|
||||
|
||||
namespace SudokuWeek4.Models.Converters
|
||||
{
|
||||
internal class VisibilityValueConverter : IValueConverter
|
||||
{
|
||||
private static readonly VisibilityValueConverter _instance = new VisibilityValueConverter();
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (!(value is bool) || targetType != typeof(Visibility))
|
||||
throw new InvalidCastException();
|
||||
|
||||
bool visible = (bool)value;
|
||||
if (parameter != null)
|
||||
visible =! visible;
|
||||
|
||||
if (visible)
|
||||
return Visibility.Visible;
|
||||
else
|
||||
return Visibility.Hidden;
|
||||
}
|
||||
|
||||
// Create a property to get the instance of the OptionsValue
|
||||
public static VisibilityValueConverter Instance
|
||||
{
|
||||
get { return _instance; }
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user