/// <summary> /// 呈现蓝色棋子 /// </summary> void ReadForBlueChessman() { if (_chessmanList == null) { InitalChessman(); } foreach (var item in _chessmanList) { if (!item.Chessman.IsRed) { ChessmanCollection.Add(item); } } }
void chessboard_ChessMoved(ChessPoint newPoint, ChessPoint oldPoint, ChessmanBase newChessman, ChessmanBase oldChessman) { _lastMoveChessman = _chessmanBaseDic[newChessman]; soundPlayer.Play(); //置换 IsRedTurn = !IsRedTurn; //移动动画 _chessmanBaseDic[newChessman].RenderTransform = _moveTransform; DoubleAnimation xAnimation = new DoubleAnimation((newPoint.X - oldPoint.X) * CellWidth, _moveDuration, FillBehavior.Stop); _moveTransform.BeginAnimation(TranslateTransform.XProperty, xAnimation); DoubleAnimation yAnimation = new DoubleAnimation((newPoint.Y - oldPoint.Y) * CellWidth, _moveDuration, FillBehavior.Stop); EventHandler tempAction = default(EventHandler); tempAction = delegate { _chessmanBaseDic[newChessman].ClearValue(UIElement.RenderTransformProperty); _chessmanBaseDic[newChessman].isSelected = false; _currentChessmanControl = null; if (oldChessman != null) { ChessmanCollection.Remove(_chessmanBaseDic[oldChessman]); } //更新 this.InvalidateArrange(); //移除本身 yAnimation.Completed -= tempAction; }; yAnimation.Completed += tempAction; _moveTransform.BeginAnimation(TranslateTransform.YProperty, yAnimation); }