Exemplo n.º 1
0
        public static IList<ServerInfo> GetServerList()
        {
            List<ServerInfo> serverlist = new List<ServerInfo>();

            ServerInfo server = new ServerInfo();
            server.ServerName = ConfigurationManager.AppSettings["Server"].ToString();
            server.ServerAddress = ConfigurationManager.AppSettings["Server"].ToString();
            server.Port = Convert.ToInt32(ConfigurationManager.AppSettings["ServerPort"].ToString());
            serverlist.Add(server);
            return serverlist;
        }
Exemplo n.º 2
0
 private void ClientForm_KeyDown(object sender, KeyEventArgs e)
 {
     ServerInfo serverInfo = new ServerInfo(Variable.RECEIVETEXT);
     if (e.KeyCode == Keys.Left)
     {
        if(serverInfo.Sec==1)
        {
            int score = Convert.ToInt32(lblSec1Red.Text);
            score++;
            lblSec1Red.Text = score.ToString();
            lblSec1Red.BackColor = Color.LightCoral;
            UpdateScore();
        }
        if (serverInfo.Sec == 2)
        {
            int score = Convert.ToInt32(lblSec2Red.Text);
            score++;
            lblSec2Red.Text = score.ToString();
            lblSec2Red.BackColor = Color.LightCoral;
            UpdateScore();
        }
     }
     if (e.KeyCode == Keys.Right)
     {
         if (serverInfo.Sec == 1)
         {
             int score = Convert.ToInt32(lblSec1Blue.Text);
             score++;
             lblSec1Blue.Text = score.ToString();
             lblSec1Blue.BackColor = Color.LightBlue;
             UpdateScore();
         }
         if (serverInfo.Sec == 2)
         {
             int score = Convert.ToInt32(lblSec2Blue.Text);
             score++;
             lblSec2Blue.Text = score.ToString();
             lblSec2Blue.BackColor = Color.LightBlue;
             UpdateScore();
         }
     }
 }
Exemplo n.º 3
0
        public void setFormFromServerJson(string serverJson)
        {
            /*//Nếu nhận được chuỗi -. Tức là server có gửi dữ liệu, nhưng chưa cho chấm điểm
            if(serverJson=="-")
            {
                resetNewMath();
                Variable.ENDMATH = 0; //Chưa chấm
                pnlSetting.Visible = true;
                btnHideSetting.Enabled = false;
                btnHideSetting.BackColor = Color.Gray;
                return;
            }*/
            resetColorKeydown();
            ServerInfo serverInfo = new ServerInfo(serverJson);
            //Máy con đang được cấp phép chấm điểm trận
            if (serverInfo.Sec != -1)
            {
                btnHideSetting.Enabled = true;
                btnHideSetting.BackColor = Color.Green;

                lblClock.Text = serverInfo.Time;
                lblWeight.Text = serverInfo.Weight;
                lblSex.Text = serverInfo.Sex;
                lblNumberMatch.Text = serverInfo.Math.ToString();
                if (serverInfo.State == "Standing")
                {
                    lblClock.BackColor = Color.LightGray;
                }
                else if (serverInfo.State == "Running")
                {
                    lblClock.BackColor = Color.White;
                }
                else if (serverInfo.State == "Pausing")
                {
                    lblClock.BackColor = Color.Yellow;
                }
                else if (serverInfo.State == "Stopping")
                {
                    lblClock.BackColor = Color.Red;
                }
                this.Text = "Máy: " + Variable.COMPUTER + "---Trận số: " + serverInfo.Math.ToString();

                if (serverInfo.Sec == 1)
                {
                    lblSec.Text = "Hiệp 1";

                    lblSec1.ForeColor = Color.Green;
                    lblTotalSec1Red.BackColor = Color.White;
                    lblMinusSec1Red.BackColor = Color.White;
                    //lblSec1.BackColor = Color.LightGreen;
                    lblSec1Red.BackColor = Color.White;
                    lblSec1Blue.BackColor = Color.White;
                    lblMinusSec1Blue.BackColor = Color.White;
                    lblTotalSec1Blue.BackColor = Color.White;

                    EndSec2();
                }
                else if (serverInfo.Sec == 2)
                {
                    lblSec.Text = "Hiệp 2";

                    lblSec2.ForeColor = Color.Green;
                    lblTotalSec2Red.BackColor = Color.White;
                    lblMinusSec2Red.BackColor = Color.White;
                    //lblSec2.BackColor = Color.LightGreen;
                    lblSec2Red.BackColor = Color.White;
                    lblSec2Blue.BackColor = Color.White;
                    lblMinusSec2Blue.BackColor = Color.White;
                    lblTotalSec2Blue.BackColor = Color.White;

                    EndSec1();
                }
                else if (serverInfo.Sec == 0)
                {
                    lblSec.Text = "Giải lao";
                    EndSec1();
                    EndSec2();
                }
            }
            //sec = -1. Ý nghĩa là không cho máy con không được chấm điểm lúc này
            else
            {
                resetNewMath();
                Variable.ENDMATH = 0; //Chưa chấm
                pnlSetting.Visible = true;
                btnHideSetting.Enabled = false;
                btnHideSetting.BackColor = Color.Gray;
            }
        }
Exemplo n.º 4
0
 public void resetColorKeydown()
 {
     ServerInfo serverInfo = new ServerInfo(Variable.RECEIVETEXT);
     if (serverInfo.Sec == 1)
     {
         lblSec1Red.BackColor = Color.White;
         lblSec2Red.BackColor = Color.White;
     }
     if (serverInfo.Sec == 2)
     {
         lblSec1Blue.BackColor = Color.White;
         lblSec2Blue.BackColor = Color.White;
     }
 }
Exemplo n.º 5
0
 public string getClientJson(ServerInfo serverInfo)
 {
     string serverJson = JsonConvert.SerializeObject(serverInfo);
     serverJson = "{\"ServerInfo\":" + serverJson + "}";
     return serverJson;
 }
Exemplo n.º 6
0
 public void resetColorKeydown()
 {
     ServerInfo serverInfo;
     try
     {
         serverInfo = new ServerInfo(Variable.RECEIVETEXT);
     }
     catch (Exception)
     {
         return;
     }
     if (serverInfo.Sec == 1)
     {
         lblSec1Red.BackColor = Color.White;
         lblSec2Red.BackColor = Color.White;
     }
     if (serverInfo.Sec == 2)
     {
         lblSec1Blue.BackColor = Color.White;
         lblSec2Blue.BackColor = Color.White;
     }
 }