void ClientStatusChanged(LoRConnector sender, StateChangedEventArgs e) { Dispatcher.Invoke(() => { lblGameConnectionStatus.Content = "Client: " + e.NextState.ToString(); switch (e.NextState) { case ClientConnectionStatus.CONNECTED: lblGameConnectionStatus.Foreground = new SolidColorBrush(Colors.Green); break; case ClientConnectionStatus.CONNECTING: lblGameConnectionStatus.Foreground = new SolidColorBrush(Colors.DarkOrange); break; case ClientConnectionStatus.DISCONNECTED: lblGameConnectionStatus.Foreground = new SolidColorBrush(Colors.Red); break; case ClientConnectionStatus.UNKNOWN: lblGameConnectionStatus.Foreground = new SolidColorBrush(Colors.Black); break; } }); }
public MainWindow() { InitializeComponent(); ClientConnector = new LoRConnector(21337); ClientConnector.StateChanged += ClientStatusChanged; ClientConnector.Connect(); }