internal void Deactivater() { _socket = null; // Resetting Socket _writer = null; // Resetting Writer _reader = null; // Resetting Reader // Disabling the UI Fields auctionRoom.IsEnabled = false; menuConnect.IsEnabled = true; menuDisconnect.IsEnabled = false; // Resetting the UI ListBox listOnlineUsers.ItemsSource = null; listOnlineUsers.Items.Clear(); }
private void btn_ConnectClicked(object sender, RoutedEventArgs e) { // Checking if the IP and Port are correctly entered. Boolean checkIp = Handler.regex_match(@"^((([0-9]{1,3})(.)){3})([0-9]{1,3})$", inputAddress.Text); Boolean checkPort = Handler.regex_match(@"^([0-9]{1,5})$", inputPort.Text); Boolean connected = false; int error = 0; try { int port = int.Parse(inputPort.Text); String ip = inputAddress.Text; if (port > 65535) error++; if (error == 0) { // Saving Information to use! _socket.IP = ip; _socket.Port = port; // Setting up a connection! connected = _socket.Connect(); if (connected) { _main._socket = _socket; } } } catch (Exception exc) { MessageBox.Show(exc.ToString()); } if (error == 0 && connected) { if (_main._socket.Connection.Connected) { _main.auctionRoom.IsEnabled = true; _main.menuConnect.IsEnabled = false; _main.menuDisconnect.IsEnabled = true; } // Resetting the Tempoary Socket _socket = null; DialogResult = true; } }