public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            SquareTypeIndex pi = value as SquareTypeIndex;

            if (pi == null)
            {
                return(null);
            }

            byte  src = (byte)((pi._index + (pi._index / 8)) % 2);
            Style s   = new Style(typeof(Button));

            switch (src)
            {
            case 0:
                s.Setters.Add(new Setter(Button.BackgroundProperty, Brushes.SaddleBrown));
                return(s);

            case 1:
                s.Setters.Add(new Setter(Button.BackgroundProperty, Brushes.Wheat));
                return(s);

            default:
                return(s);
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            SquareTypeIndex pi = value as SquareTypeIndex;

            if (pi == null)
            {
                return(null);
            }

            SquareStates src = (SquareStates)((byte)pi._type);
            Style        s   = new Style(typeof(Button));

            s.Setters.Add(new Setter(Button.BackgroundProperty, Brushes.Transparent));
            Binding b = new Binding();

            switch (src)
            {
            case SquareStates.EMPTY:
                b.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(UserControl), 1);
                b.Path           = new PropertyPath("DataContext.clickEmpty");
                s.Setters.Add(new Setter(Button.CommandProperty, b));
                return(s);

            case SquareStates.ALLIED_PIECE:
                b.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(UserControl), 1);
                b.Path           = new PropertyPath("DataContext.clickAllied");
                s.Setters.Add(new Setter(Button.CommandProperty, b));
                s.Setters.Add(new Setter(Button.CommandParameterProperty, pi._index));

                return(s);

            case SquareStates.TARGET_SQUARE:
                b.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(UserControl), 1);
                b.Path           = new PropertyPath("DataContext.clickTarget");
                s.Setters.Add(new Setter(Button.BackgroundProperty, new SolidColorBrush(Color.FromArgb(150, 155, 255, 155))));
                s.Setters.Add(new Setter(Button.CommandProperty, b));
                s.Setters.Add(new Setter(Button.CommandParameterProperty, pi._index));
                return(s);

            case SquareStates.SELECTED_SQUARE:
                b.RelativeSource = new RelativeSource(RelativeSourceMode.FindAncestor, typeof(UserControl), 1);
                b.Path           = new PropertyPath("DataContext.clickCurrent");
                s.Setters.Add(new Setter(Button.CommandProperty, b));
                return(s);

            default:
                return(s);
            }
        }