private void IsFinished() { try { bool IsFinished = true; // iterate through all of the panel that make up the score card // with the exception of Yahtzee Bonus which can be blank // if they are all filled then the game is finished for (int i = 0; i <= 19; i++) { for (int j = 1; j <= 5; j++) { Panel mPanel = (Panel)FindControl("r" + i.ToString() + "c" + j.ToString()); if ((mPanel.HasChildren == false) && (i != 16)) { IsFinished = false; } } } if (IsFinished == true) { mIsFinished = true; this.SaveGameData(); this.SaveScoreCard(); int tmpScore = 0; Panel mPanel; Label mLabel; string pnlName; for (int i = 1; i <= 5; i++) { pnlName = "r19c" + i.ToString(); mPanel = (Panel)FindControl(pnlName); if (mPanel.HasChildren == true) { mLabel = (Label)mPanel.Controls[0]; tmpScore += int.Parse(mLabel.Text); } } // bring up the "your finished" form to give the user // the final score and ask for a new game frmFinish ff = new frmFinish(tmpScore.ToString()); DialogResult mResult = ff.ShowDialog(); if (mResult == DialogResult.Yes) { // start a new game // get rid of the data in the current dsScoreCard. for (int i = 0; i <= 19; i++) { for (int j = 1; j <= 5; j++) { mPanel = (Panel)FindControl("r" + i.ToString() + "c" + j.ToString()); mPanel.Controls.Clear(); } } GameNumber = 0; dsScoreCard.Clear(); InitScoreCard(); this.SetEnabled(true); IsGameSaved = true; NewRollGroup(); } else if (mResult == DialogResult.No) { Application.Exit(); } } } catch (System.Exception ex) { EmailError.frmError eForm = new EmailError.frmError(ex.ToString(), mVersion); eForm.ShowDialog(); } }
private void IsFinished() { try { bool IsFinished = true; // iterate through all of the panel that make up the score card // with the exception of Yahtzee Bonus which can be blank // if they are all filled then the game is finished for(int i = 0;i<=19;i++) { for(int j = 1; j <=5; j++) { Panel mPanel = (Panel)FindControl("r" + i.ToString() + "c" + j.ToString()); if((mPanel.HasChildren == false) &&(i != 16)) IsFinished = false; } } if(IsFinished == true) { mIsFinished = true; this.SaveGameData(); this.SaveScoreCard(); int tmpScore = 0; Panel mPanel; Label mLabel; string pnlName; for(int i = 1; i <= 5; i++) { pnlName = "r19c" + i.ToString(); mPanel = (Panel)FindControl(pnlName); if(mPanel.HasChildren == true) { mLabel = (Label)mPanel.Controls[0]; tmpScore += int.Parse(mLabel.Text); } } // bring up the "your finished" form to give the user // the final score and ask for a new game frmFinish ff = new frmFinish(tmpScore.ToString()); DialogResult mResult = ff.ShowDialog(); if(mResult == DialogResult.Yes) { // start a new game // get rid of the data in the current dsScoreCard. for(int i = 0;i<=19;i++) { for(int j = 1; j <=5; j++) { mPanel = (Panel)FindControl("r" + i.ToString() + "c" + j.ToString()); mPanel.Controls.Clear(); } } GameNumber = 0; dsScoreCard.Clear(); InitScoreCard(); this.SetEnabled(true); IsGameSaved = true; NewRollGroup(); } else if(mResult == DialogResult.No) { Application.Exit(); } } } catch(System.Exception ex) { EmailError.frmError eForm = new EmailError.frmError(ex.ToString(), mVersion); eForm.ShowDialog(); } }