private void btnPlay_Click(object sender, EventArgs e) { difficulties = new Difficulties(this, options); difficulties.Show(); this.Hide(); }
// Contructor with arguments public Game(Difficulties d, Form1 f, Options o) { InitializeComponent(); error = new ErrorProvider(); difficulties = d; form = f; options = o; matrix = new Matrix(); currentMatrix = new TextBox[9, 9]; tempMatrix = new int[9, 9]; random = new Random(); numHints = 5; form = f; str = File.Open("test.bin", FileMode.Append); bf = new BinaryFormatter(); bf.Context = new StreamingContext(StreamingContextStates.CrossAppDomain); if (difficulties.easy == true) { matrix.easyMatrix(); tempMatrix = matrix.List.ElementAt(random.Next(4)); for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { Font font = new Font("Times New Roman", 16.0f, FontStyle.Bold | FontStyle.Italic); currentMatrix[i, j] = new TextBox(); currentMatrix[i, j].Location = new Point(20 + 50 * i, 145 + 53 * j); currentMatrix[i, j].Size = new System.Drawing.Size(45, 50); currentMatrix[i, j].BackColor = Color.Wheat; currentMatrix[i, j].Font = font; if (((i % 4 == 0) && (j % 5 == 0)) || ((i % 3 == 0) && (j % 2 == 0))) { currentMatrix[i, j].Clear(); } else { currentMatrix[i, j].AppendText(tempMatrix[j, i].ToString()); currentMatrix[i, j].Enabled = false; } this.Controls.Add(currentMatrix[i, j]); } } } else if (difficulties.normal == true) { matrix.normalMatrix(); tempMatrix = matrix.List.ElementAt(random.Next(4)); for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { Font font = new Font("Times New Roman", 16.0f, FontStyle.Bold | FontStyle.Italic); currentMatrix[i, j] = new TextBox(); currentMatrix[i, j].Location = new Point(20 + 50 * i, 145 + 53 * j); currentMatrix[i, j].Size = new System.Drawing.Size(45, 50); currentMatrix[i, j].BackColor = Color.Wheat; currentMatrix[i, j].Font = font; if (((i % 2 == 0) && (j % 5 == 0)) || ((i % 4 == 0) && (j % 2 == 0)) || ((i % 3 == 0) && (j % 4 == 0))) { currentMatrix[i, j].Clear(); } else { currentMatrix[i, j].AppendText(tempMatrix[j, i].ToString()); currentMatrix[i, j].Enabled = false; } this.Controls.Add(currentMatrix[i, j]); } } } else if (difficulties.hard == true) { matrix.hardMatrix(); tempMatrix = matrix.List.ElementAt(random.Next(4)); for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { Font font = new Font("Times New Roman", 16.0f, FontStyle.Bold | FontStyle.Italic); currentMatrix[i, j] = new TextBox(); currentMatrix[i, j].Location = new Point(20 + 50 * i, 145 + 53 * j); currentMatrix[i, j].Size = new System.Drawing.Size(45, 50); currentMatrix[i, j].BackColor = Color.Wheat; currentMatrix[i, j].Font = font; if (((i % 2 == 0) && (j % 3 == 0)) || ((i % 3 == 0) && (j % 2 == 0)) || ((i % 2 == 0) && (j % 6 == 0)) || ((i % 7 == 0) && (j % 2 == 0))) { currentMatrix[i, j].Clear(); } else { currentMatrix[i, j].AppendText(tempMatrix[j, i].ToString()); currentMatrix[i, j].Enabled = false; } this.Controls.Add(currentMatrix[i, j]); } } } else if (difficulties.expert == true) { matrix.expertMatrix(); tempMatrix = matrix.List.ElementAt(random.Next(4)); for (int i = 0; i < 9; i++) { for (int j = 0; j < 9; j++) { Font font = new Font("Times New Roman", 16.0f, FontStyle.Bold | FontStyle.Italic); currentMatrix[i, j] = new TextBox(); currentMatrix[i, j].Location = new Point(20 + 50 * i, 145 + 53 * j); currentMatrix[i, j].Size = new System.Drawing.Size(45, 50); currentMatrix[i, j].BackColor = Color.Wheat; currentMatrix[i, j].Font = font; if (((i % 2 == 0) && (j % 3 == 0)) || ((i % 3 == 0) && (j % 2 == 0)) || ((i % 2 == 0) && (j % 6 == 0)) || ((i % 7 == 0) && (j % 2 == 0)) || ((i == 3) && (j % 2 == 0)) || ((j == 2) && (i % 2 == 0))) { currentMatrix[i, j].Clear(); } else { currentMatrix[i, j].AppendText(tempMatrix[j, i].ToString()); currentMatrix[i, j].Enabled = false; } this.Controls.Add(currentMatrix[i, j]); } } } }