private void Form1_Load(object sender, EventArgs e) { timer1 = new System.Windows.Forms.Timer(); timer1.Interval = 1; timer1.Tick += new EventHandler(timer1_Tick); timer1.Enabled = true; int count = 1; for (int i = 0; i < _NUMROW_; i++) { for (int j = 0; j < _NUMCOLUMN_; j++) { PictureBox pictureBox = new PictureBox(); pictureBox.Location = new System.Drawing.Point(j * _CARDSIZE_, i * _CARDSIZE_); pictureBox.Name = "Card" + count; pictureBox.Size = new System.Drawing.Size(_CARDSIZE_, _CARDSIZE_); pictureBox.BackColor = Color.Black; pictureBox.SizeMode = PictureBoxSizeMode.StretchImage; pictureBox.Click += pictureBox_click; panel1.Controls.Add(pictureBox); count++; } } LISTCARD.randomimage(); object background = Properties.Resources.ResourceManager.GetObject("background" + (_LEVEL_ + 1)); panel1.BackgroundImage = (Image)background; foreach (PictureBox picture in panel1.Controls) { covercard(picture); } this.panel1.Width = _NUMCOLUMN_ * _CARDSIZE_; this.panel1.Height = _NUMROW_ * _CARDSIZE_; this.progressBar1.Width = this.panel1.Width; this.Width = _NUMCOLUMN_ * _CARDSIZE_; this.Height = _NUMROW_ * _CARDSIZE_ + this.progressBar1.Height; }
private void btnCreateandSend_Click(object sender, EventArgs e) { if (cbbStyleCard.SelectedIndex == -1 || String.IsNullOrEmpty(tbRow.Text) || String.IsNullOrEmpty(tbCol.Text)) { MessageBoxEx.Show("Nhập đầy đủ thông tin bàn chơi!"); } else if ((Int32.Parse(tbRow.Text) * Int32.Parse(tbCol.Text)) % 2 != 0 || (Int32.Parse(tbRow.Text) * Int32.Parse(tbCol.Text)) > 200) { MessageBoxEx.Show("Tích số cột và dòng là một số chẵn và nhỏ hơn hoặc bằng 200"); } else { int numrow = Int32.Parse(tbRow.Text); int numcol = Int32.Parse(tbCol.Text); string typecard = cbbStyleCard.SelectedItem.ToString(); ListCard listcard = new ListCard(); listcard.setListCard(numcol, numrow, 0, 0, 0, typecard); listcard.randomimage(); frmlangame = new frmLanGameplay(); frmlangame.setGame(listcard); frmlangame.MdiParent = this; frmlangame.Show(); frmlangame.Location = new Point(0, 0); panel1.Location = new Point(frmlangame.Width, 0); this.Width = frmlangame.Width + panel1.Width + 30; this.Height = (panel1.Height > frmlangame.Height ? panel1.Height + 30 : frmlangame.Height + 30); frmlangame.DisableAll(); socket.Send(new SocketData((int)SocketCommand.NOTIFY, "Nhận bàn chơi thành công", null)); socket.Send(new SocketData((int)SocketCommand.SEND_LISTCARD, "", listcard)); btnCreateandSend.Enabled = false; btnPlay.Enabled = true; } }