public ChessWindowViewModel(bool isRed, string reveiver, Chessboard board) { _board = board; _board.ChessMoved += _board_ChessMoved; IsRedSelected = isRed; _receiver = reveiver; if (isRed) { IsRedReady = true; IsBlueReady = true; } else { IsBlueReady = true; IsRedReady = true; } ClosedCommandAsync = new RelayCommand(CloseAsync); //监听落子 Const.Connection.On <ChessPoint, ChessPoint>(ReceiveLocation, (oldPoint, newPoint) => { var old = new ChessPoint(oldPoint.X, 9 - oldPoint.Y); var neW = new ChessPoint(newPoint.X, 9 - newPoint.Y); _board.GetChessman(old).Location = neW; IsRedTurn = IsRedSelected; }); //对方逃跑或投降 Const.Connection.On(OtherExit, () => { MessageBox.Show("对方逃跑或者投降了,你赢了!", "恭喜", MessageBoxButton.OK, MessageBoxImage.Information); Messenger.Default.Send(true, "Close"); }); }