コード例 #1
0
        private void SquareCompleted(object sender, SquareCompletedEventArgs eventArgs)
        {
            var square = sender as Square;

            if (square != null)
            {
                var squareGrid = _squareGrids
                                 .Select(x => new { Grid = x, Square = x.Tag as Square })
                                 .FirstOrDefault(x => x.Square.Row == square.Row && x.Square.Column == square.Column);
                if (squareGrid != null)
                {
                    var player = GetPlayer(eventArgs.PlayerId);

                    if (player != null)
                    {
                        player.Score = player.Score + 5;
                    }

                    switch (eventArgs.PlayerId)
                    {
                    case 0:
                        squareGrid.Grid.Background = new SolidColorBrush(Colors.Transparent);
                        break;

                    case 1:
                        squareGrid.Grid.Background = new SolidColorBrush(Colors.Red);
                        break;

                    case 2:
                        squareGrid.Grid.Background = new SolidColorBrush(Colors.Yellow);
                        break;

                    case 3:
                        squareGrid.Grid.Background = new SolidColorBrush(Colors.Blue);
                        break;

                    case 4:
                        squareGrid.Grid.Background = new SolidColorBrush(Colors.Orange);
                        break;

                    case 5:
                        squareGrid.Grid.Background = new SolidColorBrush(Colors.Green);
                        break;

                    case 6:
                        squareGrid.Grid.Background = new SolidColorBrush(Colors.Purple);
                        break;

                    case 7:
                        squareGrid.Grid.Background = new SolidColorBrush(Colors.Magenta);
                        break;

                    default:
                        squareGrid.Grid.Background = new SolidColorBrush(Colors.Black);
                        break;
                    }
                }
            }
        }
コード例 #2
0
        private void SquareCompleted(object sender, SquareCompletedEventArgs eventArgs)
        {
            var square = sender as Square;
            if (square != null)
            {
                var squareGrid = _squareGrids
                    .Select(x => new { Grid = x, Square = x.Tag as Square })
                    .FirstOrDefault(x => x.Square.Row == square.Row && x.Square.Column == square.Column);
                if (squareGrid != null)
                {
                    var player = GetPlayer(eventArgs.PlayerId);

                    if (player != null) player.Score = player.Score + 5;

                    switch (eventArgs.PlayerId)
                    {
                        case 0:
                            squareGrid.Grid.Background = Brushes.Transparent;
                            break;
                        case 1:
                            squareGrid.Grid.Background = Brushes.Red;
                            break;
                        case 2:
                            squareGrid.Grid.Background = Brushes.Yellow;
                            break;
                        case 3:
                            squareGrid.Grid.Background = Brushes.Blue;
                            break;
                        case 4:
                            squareGrid.Grid.Background = Brushes.Orange;
                            break;
                        case 5:
                            squareGrid.Grid.Background = Brushes.Green;
                            break;
                        case 6:
                            squareGrid.Grid.Background = Brushes.Purple;
                            break;
                        case 7:
                            squareGrid.Grid.Background = Brushes.Pink;
                            break;
                    }
                }
            }
        }
コード例 #3
0
ファイル: Square.cs プロジェクト: IsaacIsHere/SignalRSandbox
 private void OnCompleted(SquareCompletedEventArgs eventArgs)
 {
     if (Completed != null)
         Completed.Invoke(this, eventArgs);
 }