private void ChangeConnectState(RemoteClient.RemoteClientState nowSate) { switch (nowSate) { case MyTool.RemoteClient.RemoteClientState.Break: this.Cells[0].Text = this.remoteClient.ToString() + "尝试重新连接"; this.ImageIndex = 1; break; case MyTool.RemoteClient.RemoteClientState.Connecting: this.Cells[0].Text = this.remoteClient.ToString() + "正在连接连接"; this.ImageIndex = 2; break; case MyTool.RemoteClient.RemoteClientState.Connected: this.Cells[0].Text = this.remoteClient.ToString(); this.ImageIndex = 0; this.Expand(); break; case MyTool.RemoteClient.RemoteClientState.Lost: this.Cells[0].Text = this.remoteClient.ToString() + "失去连接"; this.ImageIndex = 3; break; default: break; } }
void remoteClient_OnClientStateChange(RemoteClient sender, RemoteClient.RemoteClientState nowSate) { if (this.TreeControl.InvokeRequired) { this.TreeControl.Invoke(new Action <RemoteClient.RemoteClientState>(ChangeConnectState), nowSate); } else { ChangeConnectState(nowSate); } }