Beispiel #1
0
        public void Select()
        {
            PieceSelected?.Invoke(this, EventArgs.Empty);
            if (legalActions == null)
            {
                legalActions = gm.LegalActions.Where(a => a.From == Position).ToList();

                List <GameAction> filteredActions = legalActions.GroupBy(m => m.To).Select(g => g.First()).ToList();
                suggestedActions = new Dictionary <Rectangle, GameAction>();
                foreach (GameAction action in filteredActions)
                {
                    Rectangle rect = new Rectangle();
                    suggestedActions[rect] = action;
                    rect.Width             = gm.SquareSize;
                    rect.Height            = gm.SquareSize;
                    SolidColorBrush brush = new SolidColorBrush(Color.FromRgb(255, 241, 145));
                    brush.Opacity = 0.5;
                    rect.Fill     = brush;
                    Point loc = gm.GetLocationOfPos(action.To);
                    Canvas.SetLeft(rect, loc.X);
                    Canvas.SetTop(rect, loc.Y);
                    Canvas.SetZIndex(rect, 6);
                    rect.Cursor   = Cursors.Hand;
                    rect.MouseUp += SuggestedAction_MouseUp;
                    boardCanvas.Children.Add(rect);
                }
            }
        }
Beispiel #2
0
 public void PieceSelect(Point piece, List <MoveOption> options)
 {
     PieceSelected?.Invoke(piece, options);
 }
Beispiel #3
0
 public void QueenSelected()
 {
     PieceSelected?.Invoke(typeof(Queen));
     Close();
 }
Beispiel #4
0
 public void RookSelected()
 {
     PieceSelected?.Invoke(typeof(Rook));
     Close();
 }
Beispiel #5
0
 public void BishopSelected()
 {
     PieceSelected?.Invoke(typeof(Bishop));
     Close();
 }
Beispiel #6
0
 public void KnightSelected()
 {
     PieceSelected?.Invoke(typeof(Knight));
     Close();
 }
Beispiel #7
0
 public void Handle(PieceSelected notification)
 {
     Selected = notification.Square.Equals(square);
 }