Esempio n. 1
0
        void HandleReceive(String str)
        {
            if (str[0] == Cons.Receive_Result)
            {
                result = str[1];
                return;
            }

            if (str[0] == Cons.Receive_End)
            {
                flagEnd = true;
                return;
            }
            if (str[0] == Cons.Receive_OpDisconnect)
            {
                flagReady = false;
                panel3.Invoke((MethodInvoker) delegate
                {
                    //perform on the UI thread
                    label7.Visible = true;
                });
                //
                btdao.Enabled = false;
                flagRuncancau = false;
                flagdraw      = false;
                Clear_Panel1();
                Clear_LstGold();
                refresh();
                Thread.Sleep(1000);
                return;
            }
            if (str[0] == Cons.Receive_Ready)
            {
                btbatdau.Enabled = true;

                panel3.Invoke((MethodInvoker) delegate
                {
                    //perform on the UI thread
                    label7.Visible = false;
                });
                return;
            }
            if (str[0] == Cons.Receive_Room)
            {
                str       = str.Substring(1);
                Room.Text = "Phong: " + str;
                tcp.SendData(Cons.Send_OK + "");
                return;
            }
            if (str[0] == Cons.Receive_Master)
            {
                master           = true;
                btbatdau.Text    = "Bắt đầu";
                btbatdau.Enabled = false;
                return;
            }
            if (str[0] == Cons.Receive_Start)
            {
                btbatdau.Enabled = false;
                flagRuncancau    = true;
                flagReady        = true;
                //timer1.Enabled = true;
                //timer1.Start();
                drawmap(lstGold);
                btdao.Enabled  = true;
                BoxMyMark.Text = "0";
                BoxOpMark.Text = "0";
                return;
            }
            if (str[0] == Cons.Receive_Golg)
            {
                str = str.Substring(1);
                string[] arrListStr = str.Split(',');
                Point    pt         = new Point(Int32.Parse(arrListStr[0]), Int32.Parse(arrListStr[1]));
                GOLD     remove     = new GOLD(0, 0, 0);
                remove = lstGold.Find(x => x.pos == pt);
                if (remove != null)
                {
                    Remove_Gold(remove);
                    remove.lb.Visible = false;
                }
                return;
            }
            if (str[0] == Cons.Receive_map)
            {
                int i = 0;
                Clear_LstGold();
                Clear_Panel1();
                str = str.Substring(1);
                string[] arrListStr = str.Split('.');
                lock (lockthis)
                {
                    while (arrListStr.Length - 1 > i)
                    {
                        Addgold(arrListStr[i]);
                        i++;
                    }
                }
                //  tcp.SendData(Cons.Send_OK+"");
                return;
            }
            if (str[0] == Cons.Receive_OpMark)
            {
                str            = str.Substring(1);
                BoxOpMark.Text = str;

                return;
            }
        }
Esempio n. 2
0
 void Button2Click(object sender, System.EventArgs e)
 {
     //step 2: Gui yeu cau server
     string str  = "START";
     int    flag = tcp.SendData(str);
 }