private void CheckIP()
 {
     if (!CTYoung.Is_ip_valid(cbIP.Text))
     {
         MessageBox.Show("Ip 格式错误", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
         cbIP.Focus();
     }
 }
 private void MainForm_Load(object sender, EventArgs e)
 {
     if (setting.isLogin)
     {
         LoadStatusIsLogin();
         ct = CTYoung.Init(setting.location, setting.ip, setting.username, setting.passwd, setting.uuid);
     }
     else
     {
         LoadStatusNotLogin();
         var localhost = Dns.GetHostByName(Dns.GetHostName());
         foreach (var ip in localhost.AddressList)
         {
             cbIP.Items.Add(ip.ToString());
         }
         cbIP.Text = "0.0.0.0";
     }
 }
 private void btnlogin_Click(object sender, EventArgs e)
 {
     CheckIP();
     ct = CTYoung.Init(Properties.Settings.Default.location, cbIP.Text, txtUsername.Text, txtPasswd.Text);
     if (ct.Login())
     {
         setting.passwd   = txtPasswd.Text;
         setting.username = txtUsername.Text;
         setting.isLogin  = true;
         setting.uuid     = ct.Uuid;
         setting.ip       = ct.Ip;
         MessageBox.Show("登陆成功");
         LoadStatusIsLogin();
     }
     else
     {
         MessageBox.Show("登陆失败");
     }
 }