public frmResult(frmGamePrep prepForm, frmGame gameForm, string result, int gamesize, int gameScore, TimeSpan gameTime) { InitializeComponent(); //initializes properties Result = result; GameSize = gamesize; GameForm = gameForm; PrepForm = prepForm; lblMessage.Text = result; GameScore = gameScore; GameTime = gameTime; DetermineDifficulty(GameSize); lblScoreNum.Text = GameScore + ""; //creates new datatable and makes it the source of the datagridview dt = new DataTable(); dgScores.DataSource = dt; dt.Columns.Add("Player", typeof(string)); dt.Columns.Add("Difficulty", typeof(string)); dt.Columns.Add("Score", typeof(int)); dt.Columns.Add("Time", typeof(string)); //Read from text file Scores = ReadFile(); //if the game is lost, prevent the user from entering initials if (GameScore <= 0) { tbInitials.Enabled = false; tbInitials.Visible = false; btnAddScore.Enabled = false; btnAddScore.Visible = false; lblScoreText.Text = ""; lblScoreNum.Text = ""; lblCongrats.Text = ""; lblInitials.Text = ""; } }
/// <summary> /// Constructor, takes the original form as a parameter in order to pass to the results form, /// takes gridSize to specify the size of the Board and of the button grid shown. /// </summary> /// <param name="prepForm"></param> /// <param name="gridSize"></param> public frmGame(frmGamePrep prepForm, int gridSize) { InitializeComponent(); PrepForm = prepForm; GameSize = gridSize; //Create and set up a new board object board = new Board(gridSize); board.SetupLiveNeighbors(gridSize / 2); board.CalculateLiveNeighbors(); //btnGrid contains the button controls btnGrid = new Button[gridSize, gridSize]; //populate the grid with buttons PopulateGrid(gridSize); //start the stopwatch and timer swGameTime.Start(); tmrGameTimer.Start(); //grant the timer a new tick event tmrGameTimer.Tick += TmrGameTimer_Tick; }