public void RestartGame(int newBombNumber, int newLength) { this.Hide(); //先隐藏主窗体 主窗体 form1 = new 主窗体(newBombNumber, newLength); //重新实例化此窗体 form1.Height = 35 * newLength + 80; form1.Width = 35 * newLength + 60; form1.ShowDialog();//已模式窗体的方法重新打开 this.Close(); }
private void button1_Click(object sender, EventArgs e) { int number = int.Parse(numericUpDown1.Value.ToString()); 主窗体 fp = (主窗体)this.Owner; int length = fp.length; if (number >= length * length) { MessageBox.Show("炸弹数量过多,请重新设置!"); return; } //fp.Show(); this.Hide(); fp.RestartGame(number, length); }
private void button1_Click(object sender, EventArgs e) { int number = int.Parse(numericUpDown1.Value.ToString()); 主窗体 fp = (主窗体)this.Owner; int bombNumber = fp.bombNumber; if (number * number <= bombNumber) { MessageBox.Show("地图过小,无法适应炸弹数量!"); return; } //fp.Show(); this.Hide(); fp.RestartGame(bombNumber, number); }
private void button1_Click(object sender, EventArgs e) { string names = textBox1.Text; if (names.Length == 0) { MessageBox.Show("留下你的尊姓大名吧!!"); return; } FileStream fp2 = new FileStream("Achievements.txt", FileMode.Append); StreamWriter fp = new StreamWriter(fp2); fp.Write(names + " " + length + " " + bombNumber + " " + useTime + "\r\n"); fp.Close(); 主窗体 fps = (主窗体)this.Owner; //this.Close(); this.Hide(); fps.RestartGame(bombNumber, length); }