private void btnSave_Click(object sender, EventArgs e) { string port = this.txtPort.Text.Trim(); try { int tmp = Convert.ToInt32(port); ClientConfig config = new ClientConfig(); config.Port = tmp; config.Ip = this.txtIp.Text.Trim(); config.ServerIp = this.txtServerIp.Text.Trim(); ClientConfig.SaveConfig(config); MessageBoxHelper.Show("����ɹ�"); } catch(Exception ex) { MessageBoxHelper.Show("�˿ڱ��������֣�"); } }
/// <summary> /// ����ͻ������� /// </summary> /// <param name="config">������Ϣ</param> public static void SaveConfig(ClientConfig config) { string path = ReflectHelper.GetExePath() + "\\" + Config_File_Name; SerializeHelper.SerializeToFile(config, path); }
/// <summary> /// �������ý�������,���ӳɹ�������һ��Login���� /// </summary> /// <param name="config">����</param> public void Start(ClientConfig config) { //locked.WaitOne(); if (this.IsStarted) { this.Log("�ͻ����Ѿ����ӣ�"); //locked.ReleaseMutex(); return; } else { this.tcpClient = new TcpClient(); IPAddress remote = IPAddress.Parse(config.ServerIp); this.tcpClient.BeginConnect(remote, config.Port,new AsyncCallback(ConnectedEnd),this.tcpClient); } }