Advertisement
Hellboyandso

PlayerToColorTileConvertor

May 23rd, 2015
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.35 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using System.Windows.Data;
  7. using System.Windows.Media;
  8. using Reversi.Domain;
  9. using Reversi.Cells;
  10.  
  11. namespace ReversiGUI
  12. {
  13.     //[ValueConversion(typeof(object), typeof(string))]
  14.     public class PlayerToColorTilesConvertor : IValueConverter
  15.     {
  16.         public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  17.         {
  18.             ICell<String> temp = (ICell<String>)value;
  19.             String format = temp.Value;
  20.             if (format != null)
  21.             {
  22.                 if (format.Equals("ValidMove"))
  23.                     return Colors.SkyBlue;
  24.                 else if (format.Equals("PlayerOne"))
  25.                     return Colors.Black;
  26.                 else if (format.Equals("PlayerTwo"))
  27.                     return Colors.White;
  28.                 else if (format.Equals("NoTile"))
  29.                     return Colors.Transparent;
  30.                 else
  31.                     return Colors.Transparent;
  32.             }
  33.             else
  34.                 return Colors.Transparent;
  35.         }
  36.  
  37.         public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
  38.         {
  39.             return null;
  40.         }
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement