private void OnExit_Click(object sender, EventArgs e) { if (connection != null) { connection.Stop(); connection = null; } this.ParentForm.Close(); isExiting = true; }
private void Connect(string address, int port) { if (connection != null) connection.Stop(); connection = new ClientSocketConnection(address, port); connection.OnConnectionEstablished += new Action(connection_OnConnectionEstablished); connection.OnServerNotFound += new Action(connection_OnServerNotFound); connection.OnMapReceived += new Action<SimpleImage>(connection_OnMapReceived); connection.OnCenterMapReceived += new Action<SimplePoint>(connection_OnCenterMapReceived); connection.OnFogReceived += new Action<SimpleImage>(connection_OnFogReceived); connection.OnFogUpdateReceived += new Action<FogUpdate>(connection_OnFogUpdateReceived); connection.OnGridSizeReceived += new Action<bool, int>(connection_OnGridSizeReceived); connection.OnGridColorReceived += new Action<SimpleColor>(connection_OnGridColorReceived); connection.OnBlackoutReceived += new Action<bool>(connection_OnBlackoutReceived); connection.OnExitReceived += new Action(connection_OnExitReceived); this.ParentForm.Text = string.Format("{0} - Connecting to {1}:{2}...", initialParentFormText, address, port); connection.Start(); }