Esempio n. 1
0
      void BoardClick(object sender, MouseButtonEventArgs e)
      {
          if (game.GameData.isRunning)
          {
              Control  src  = e.Source as Control;
              string[] s    = string.Format("{0}", src.Tag).Split(',');
              int      x    = Int32.Parse(s[0]);
              int      y    = Int32.Parse(s[1]);
              MoveType type = new MoveType();
              switch (e.ChangedButton)
              {
              case MouseButton.Left:
                  type = MoveType.Expose;
                  break;

              case MouseButton.Right:
                  type = MoveType.Flag;
                  break;

              case MouseButton.XButton2:
                  type = MoveType.ExposeAdjacent;
                  break;

              default:
                  break;
              }
              game.MakeMove(y, x, type);
              UpdateBoard();
              Trace.WriteLine(string.Format("Win: {0}", game.GameData.win));
              Trace.WriteLine(string.Format("Lose: {0}", game.GameData.lose));

              if (game.GameData.lose)
              {
                  MessageBox.Show(string.Format("Przegrales"));
              }
              if (game.GameData.win)
              {
                  MessageBox.Show(string.Format("Wygrales"));
              }
          }
      }