private void styleSetting(string str) { if (qipan == null) { return; } if (str.Trim().Equals("")) { return; } int x, y, player; string[] tmp = str.Trim().Split(' '); //棋盘的棋子信息 for (int i = 0; i < tmp.Length; i += 3) { x = Convert.ToInt32(tmp[i]); y = Convert.ToInt32(tmp[i + 1]); player = Convert.ToInt32(tmp[i + 2]); qipan.put(x, y, player); } }
//设置棋盘信息 private void SetInfo() { dis = Convert.ToInt32(comboBox5.Text); //棋盘格的大小 if (dis < 6) { dis = 5; } border = dis * 3 / 4; //棋盘到窗体的边框距离 s = (double)dis / Convert.ToInt32(comboBox5.Items[0].ToString()); if (qipan == null || qipan.num == 0) { M = Convert.ToInt32(comboBox1.Text.Trim()); if (M < 6) { M = 5; } N = Convert.ToInt32(comboBox2.Text); //棋盘大小为M*N if (N < 6) { N = 5; } num = Convert.ToInt32(comboBox3.Text); player = new C_Num(num); //初始化num个玩家 qipan = new QiPan(M, N, num); //初始化一个M行N列的棋盘 win = new int[num]; quit = new bool[num]; auto = new bool[num]; } pictureBox1.Width = (N - 1) * dis + 2 * border; //根据行列数设置棋盘大小 pictureBox1.Height = (M - 1) * dis + 2 * border; //string str = "jpg\\" + comboBox6.Text.Trim() + ".jpg"; //if (System.IO.File.Exists(str)) // pictureBox1.BackgroundImage = Image.FromFile(str); pictureBox1.BackgroundImage = backImage[Convert.ToInt32(comboBox6.Text.Trim()) - 1]; g = pictureBox1.CreateGraphics(); //在对象图片框中创建一个Graphics对象用于绘图 pen1 = new Pen(label12.BackColor, 2); if (checkBox1.Checked) { panel1.Visible = false; } else { panel1.Visible = true; } if (checkBox3.Checked) { TopMost = true; //最前端显示棋盘 } else { TopMost = false; } if (radioButton1.Checked == true) { FormBorderStyle = FormBorderStyle.None; //无边框 } else if (radioButton3.Checked == true) { FormBorderStyle = FormBorderStyle.Fixed3D; //固定大小 } if (FormBorderStyle == FormBorderStyle.None) { 退出ToolStripMenuItem.Visible = true; } else { 退出ToolStripMenuItem.Visible = false; } pictureBox1.Visible = true; resize(); }