/// <summary> /// 完成游戏调用线程的方法 /// </summary> void Finish() { //改变每个格子的字体颜色和背景颜色 foreach (Pane pane in panes) { pane.ReadOnly = true; pane.BackColor = backNormalColor; } Avails ava = new Avails(81, false); //利用一个随机序列改变每个格子的字体颜色 foreach (int i in ava) { int x = (i - 1) / 9; int y = (i - 1) % 9; panes[x, y].ForeColor = GerColor(fontNormalColor, 96); Thread.Sleep(30); } ava.Random(); //利用另一个随机序列改变每个格子的背景颜色 foreach (int i in ava) { int x = (i - 1) / 9; int y = (i - 1) % 9; panes[x, y].BackColor = GerColor(backNormalColor, -48); Thread.Sleep(30); } }
/// <summary> /// 完成游戏调用线程的方法 /// </summary> void Finish() { try { //改变每个格子的字体颜色和背景颜色 ((FrmGame)this.Parent).menuStrip1.Enabled = false; foreach (Pane pane in panes) { pane.ReadOnly = true; pane.BackColor = backNormalColor; } Avails ava = new Avails(81, false); //利用一个随机序列改变每个格子的字体颜色 foreach (int i in ava) { int x = (i - 1) / 9; int y = (i - 1) % 9; panes[x, y].ForeColor = GerColor(fontNormalColor, 96); Thread.Sleep(30); } ava.Random(); //利用另一个随机序列改变每个格子的背景颜色 foreach (int i in ava) { int x = (i - 1) / 9; int y = (i - 1) % 9; panes[x, y].BackColor = GerColor(backNormalColor, -48); Thread.Sleep(30); } ((FrmGame)this.Parent).menuStrip1.Enabled = true; Thread.CurrentThread.Abort(); Thread.CurrentThread.Join(); } catch { } }