Exemplo n.º 1
0
        static void Main()
        {
            ClientGobang.ChessClass.Client cc = new ClientGobang.ChessClass.Client(); //########
            Program.PublicClientObject = cc;                                          //########

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Frm_Hall());
        }
Exemplo n.º 2
0
 private void pictureBox1_Click(object sender, EventArgs e)
 {
     ClientGobang.ChessClass.Client cc = ClientGobang.Program.PublicClientObject;
     cc.CloseConnection();
     if (Out == true)
     {
         listener.Close();
     }
     ConnHandle = 0;
     if (GIP.Trim().Length > 4)
     {
         temMsg2.msgCommand = MsgCommand.ExitJoin;
         udpSocket1.Send(IPAddress.Parse(GIP), 11001, new ClassSerializers().SerializeBinary(temMsg2).ToArray());
         MessageBox.Show("是否关闭窗体");
     }
     this.DialogResult = DialogResult.OK;
     this.Close();
 }
Exemplo n.º 3
0
        //点击棋盘
        public void asd(object sender, EventArgs e)
        {
            if (dropchild == false)
            {
                return;
            }
            if ((Mouse_X <= 30.0 / 2.0) || (Mouse_Y <= 30.0 / 2.0))
            {
                return;
            }
            if (CanDown == true)
            {
                if (Conqueror == true)
                {
                    if (CKind == 0)
                    {
                        Bwin();
                    }
                    if (CKind == 1)
                    {
                        Wwin();
                    }
                    return;
                }
                if (WhoFisrtDown == true)
                {
                    int Column = Convert.ToInt32(Math.Round((Mouse_X - 30) / 35));
                    int Row    = Convert.ToInt32(Math.Round((Mouse_Y - 30) / 35));
                    int bw     = 0;

                    if (note[Convert.ToInt32(Row), Convert.ToInt32(Column)] >= 0)
                    {
                        return;
                    }

                    PictureBox pictureBoxTem = new PictureBox();
                    pictureBoxTem.Parent   = panel_Check;
                    pictureBoxTem.Location = new System.Drawing.Point(Column * 35 + 9, Row * 35 + 9);
                    pictureBoxTem.Name     = "pictureBox" + Row.ToString() + "*" + Column.ToString();
                    pBox_Sign.Location     = new System.Drawing.Point(Column * 35 + 20, Row * 35 + 20);

                    pictureBoxTem.Size     = new System.Drawing.Size(30, 30);
                    pictureBoxTem.SizeMode = PictureBoxSizeMode.StretchImage;
                    ClientGobang.ChessClass.Client cc = Program.PublicClientObject;
                    BBow++;
                    pBox_Sign.Visible = true;
                    pBox_Sign.BringToFront();
                    if (BBow % 2 == 1)
                    {
                        label_Genre.Text    = "黑棋";
                        label_Genre.Tag     = 0;
                        pictureBoxTem.Image = imageList1.Images[0];
                        bw = 0;
                        note[Row, Column] = 0;
                        cc.SendMessage("Down#" + Row.ToString() + "*" + Column.ToString() + "|" + "0" + "@" + BBow.ToString());
                    }
                    else
                    {
                        label_Genre.Text    = "白棋";
                        label_Genre.Tag     = 1;
                        pictureBoxTem.Image = imageList1.Images[1];
                        bw = 1;
                        note[Row, Column] = 1;
                        cc.SendMessage("Down#" + Row.ToString() + "*" + Column.ToString() + "|" + "1" + "@" + BBow.ToString());
                    }

                    if (childSgin == true)
                    {
                        if (BBow % 2 == 1)
                        {
                            if (label_Left.Text.Trim() == Publec_Class.UserName)
                            {
                                pictureBox_Q_Left.Image = null;
                                pictureBox_Q_Left.Image = Image.FromFile(ClientClass.ImaDir + "\\Image\\黑棋.png");
                            }
                            else
                            {
                                pictureBox_Q_Right.Image = null;
                                pictureBox_Q_Right.Image = Image.FromFile(ClientClass.ImaDir + "\\Image\\白棋.png");
                            }
                        }
                        else
                        {
                            if (label_Left.Text.Trim() == Publec_Class.UserName)
                            {
                                pictureBox_Q_Left.Image = null;
                                pictureBox_Q_Left.Image = Image.FromFile(ClientClass.ImaDir + "\\Image\\白棋.png");
                            }
                            else
                            {
                                pictureBox_Q_Right.Image = null;
                                pictureBox_Q_Right.Image = Image.FromFile(ClientClass.ImaDir + "\\Image\\黑棋.png");
                            }
                        }
                        childSgin = false;
                    }



                    note[Row, Column] = bw;
                    if_UPdata         = 0;
                    Arithmetic(bw, Row, Column);
                }
                else
                {
                    MessageBox.Show("对方还没有落子!");
                    dropchild = true;
                    return;
                }
            }
            else
            {
                MessageBox.Show("本盘棋局没有开始无法下棋!");
                dropchild = true;
                return;
            }
            dropchild = false;
        }
Exemplo n.º 4
0
        private void pictureBox2_Click(object sender, EventArgs e)
        {
            this.pictureBox2.Image   = null;
            this.pictureBox2.Image   = Image.FromFile(ClientClass.ImaDir + "\\Image\\开始按钮灰.png");
            this.pictureBox2.Enabled = false;

            switch (ConnHandle)
            {
            case 1:
            {
                ClientGobang.ChessClass.Client cc = ClientGobang.Program.PublicClientObject;
                if (cc.Connected)
                {
                    cc.CloseConnection();
                }

                try
                {
                    if (GIP == "")
                    {
                        break;
                    }
                    cc.ConnectServer(GIP, int.Parse("11003"));
                }
                catch
                {
                    MessageBox.Show("连接服务器失败");
                    this.pictureBox2.Image   = null;
                    this.pictureBox2.Enabled = true;
                    this.pictureBox2.Image   = Image.FromFile(ClientClass.ImaDir + "\\Image\\开始按钮.png");
                    return;
                }
                WhoFisrtDown = false;
                cc.SendMessage("FiDn" + "Me");
                CanDown    = true;
                ConnHandle = 2;
                break;
            }

            case 2:
            {
                CanAgin      = true;
                WhoFisrtDown = false;
                dropchild    = true;
                CanDown      = true;
                Conqueror    = false;
                ClientGobang.ChessClass.Client cc = ClientGobang.Program.PublicClientObject;
                cc.SendMessage("FiDn" + "Me");
                if (Agin_if == false)
                {
                    cc.SendMessage("Agin#" + "OK?");
                    Agin();
                }
                else
                {
                    Agin_if = false;
                    if (panel_Check.Controls.Count > 10)
                    {
                        Agin();
                    }
                }
                BBow = BBow + 1;
                pBox_Sign.Visible = false;
                Conqueror         = false;
                break;
            }
            }
            childSgin = true;
        }