private void OnGeoServerConnectionStatusChanged(object sender, ConnectionChangedEventArgs <GeographicalServer> e) { switch (e.State) { case 0: this.ShowDisconnected(); break; case 1: this.ShowDisconnecting(); break; case 2: this.ShowConnecting(e.Server); break; case 3: this.ShowConnected(e.Server); break; default: throw new NotSupportedException(); } this._currentServer = e.Server; this._currentState = e.State; }
private void ras_ConnectionChanged(object sender, ConnectionChangedEventArgs e) { Log("Connected:" + e.Connected.ToString()); if (!e.Connected) this.FireDisconnected(); }
private void ConnectionHandler_ConnectionChanged(object sender, ConnectionChangedEventArgs e) { //Enable/disable teamspeak menuitems try { Logging.Log($"Connection changed -> Type: {e.ConnectionType} Connected: {e.Connected}", LogLevel.LogLevel_DEBUG); switch (e.ConnectionType) { case ConnectionType.Discord: Functions.setPluginMenuEnabled(PluginID, MenuItems.MenuItemConnect, !e.Connected); Functions.setPluginMenuEnabled(PluginID, MenuItems.MenuItemJoin, e.Connected); Functions.setPluginMenuEnabled(PluginID, MenuItems.MenuItemDisconnect, e.Connected); Functions.setPluginMenuEnabled(PluginID, MenuItems.MenuItemLink, e.Connected); break; case ConnectionType.Voice: Functions.setPluginMenuEnabled(PluginID, MenuItems.MenuItemJoin, !e.Connected); Functions.setPluginMenuEnabled(PluginID, MenuItems.MenuItemLeave, e.Connected); Functions.setPluginMenuEnabled(PluginID, MenuItems.MenuItemConnectionInfo, e.Connected); ApplyTs3MuteStateToDiscord(); UpdateClientDescription(); DiscordAutoMuteAll(); break; case ConnectionType.Text: break; default: break; } } //When Teamspeak will be closed/exited and a discord user is logged in, this could trigger an access violation before teamspeak is exited catch (AccessViolationException) { } }
/// <summary> /// Incoming data received event handler method /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Client_ConnectionChanged(object sender, ConnectionChangedEventArgs e) { //event gets called by Listener thread via Delegate if (ConversationTextBox.InvokeRequired) //element is on a different thread { MethodInvoker invoker = new MethodInvoker(delegate() { if (e.ConnMsg.StartsWith("Received")) { ConversationTextBox.AppendText(e.ConnMsg, Color.Blue); ConversationTextBox.AppendText(Environment.NewLine); } else { ConversationTextBox.AppendText(e.ConnMsg, Color.Black); ConversationTextBox.AppendText(Environment.NewLine); } //ConversationTextBox.Text += e.ConnMsg; }); ConversationTextBox.BeginInvoke(invoker); } else { //business as usual //update the progress bar ConversationTextBox.Text += e.ConnMsg; } }
void OnConnectionChanged(object sender, ConnectionChangedEventArgs e) { if (e.IsConnected != connected) { string message = null; if (e.IsConnected) { message = "connected"; } else if (connected) { message = "lost connection"; } if (!e.IsConnected) { var nowait = Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, new Windows.UI.Core.DispatchedHandler(() => { Clear(); })); } DisplayMessage(message); } connected = e.IsConnected; }
//------------------------------------------------------------------------------------------------------------------- //In a real application you would use this eventhandler to inform the user, connect / disconnect the SerialPort etc.. // static void ConnectedTeensiesChanged(object sender, ConnectionChangedEventArgs e) { // Write information about the added or removed Teensy to the console USB_Device Teensy = e.changedDevice; switch (Teensy.Type) { case USB_Device.type.HalfKay: if (e.changeType == TeensyWatcher.ChangeType.add) { Console.WriteLine("Teensy {0} running HalfKay", Teensy.Serialnumber); } else { Console.WriteLine("Teensy {0} removed", Teensy.Serialnumber); } break; case USB_Device.type.UsbSerial: if (e.changeType == TeensyWatcher.ChangeType.add) { Console.WriteLine("Teensy {0} connected on {1}", Teensy.Serialnumber, Teensy.Port); } else { Console.WriteLine("Teensy {0} removed from {1}", Teensy.Serialnumber, Teensy.Port); } break; } }
void Connection_ConnectionChanged(object sender, ConnectionChangedEventArgs e) { // Update the connection info // this.Element.AccessoryConnections[e.ConnectionIndex - 1] = e.Connection; // Refresh the connection map information // this.StatusEditorControl.Refresh(); }
private void Comm_ConnectionChanged(object sender, ConnectionChangedEventArgs e) { if (SwitchToMainThread(sender, e)) { return; } RefreshStatus(); }
private static void Connector_ConnectionChanged(object sender, ConnectionChangedEventArgs args) { var connector = sender as Connector; var item = connector.ParentDesignerItem; var internalItem = (item.Content as Control); var vm = internalItem.DataContext as SimViewModelBase; vm.HandleConnectionAdded(connector); }
private void ras_ConnectionChanged(object sender, ConnectionChangedEventArgs e) { this.Log("Connected:" + e.Connected); if (!e.Connected) { this.FireDisconnected(); } }
void Communication_ConnectionChanged(object sender, ConnectionChangedEventArgs e) { if (SwitchToMainThread(sender, e)) { return; } RefreshStatus(); IsConnected = e.IsConnected; }
private void OnConnectionChangedEvent(object sender, ConnectionChangedEventArgs e) { try { _console.OutputEvent($"Connection changed. {e.Connection}, port: {e.PortName}"); } catch (Exception exception) { _console.OutputError(exception); } }
private void OnConnectionChanged() { EventHandler <ConnectionChangedEventArgs> action = this.ConnectionChanged; if (action != null) { var args = new ConnectionChangedEventArgs(); args.ConnectionExists = this._connectionExists; action(this, args); } }
private void ConnectedTeensiesChanged(object sender, ConnectionChangedEventArgs e) { Dispatcher.Invoke(() => { cbTeensy.Items.Clear(); foreach (var Teensy in watcher.ConnectedDevices.Where(t => t.UsbType == USB_Device.USBtype.UsbSerial)) { cbTeensy.Items.Add(Teensy); } cbTeensy.SelectedIndex = 0; Teensy = cbTeensy.SelectedItem as USB_Device; } ); }
private void myClient_ConnectionChanged(object sender, ConnectionChangedEventArgs e) { txbTemp.Dispatcher.BeginInvoke(new Action(delegate { if (e.isConnected) { txbTemp.Text = "Đã kết nối"; iconConnection.Foreground = new SolidColorBrush(Colors.YellowGreen); } else { txbTemp.Text = "Mất kết nối"; iconConnection.Foreground = new SolidColorBrush(Colors.Red); } })); }
private void AppStateChanged(object sender, ConnectionChangedEventArgs <GeographicalServer> e) { if (this.Coutry.get_Identifier().Equals(e.Server.get_Country())) { this.State = PinViewModel.Map(e.State); return; } if (e.State != null) { if (e.State != 1) { this.State = PinStates.Dimmed; return; } } this.State = PinStates.Disconnected; }
public event EventHandler <string> newResponse; // Inform listeners that a a new response was received // called whenever a Teensy is added / removed from the USB bus private void connectionChanged(object sender, ConnectionChangedEventArgs e) { var teensy = watcher.connectedDevices.FirstOrDefault(); // use first teensy found if (teensy != null) { try { teensyID = $"Teensy {teensy.serialnumber} on {teensy.port} "; if (port != null) { port.DataReceived -= dataReceived; // detatch incomming data handler port.Dispose(); // get rid of old port } port = new SerialPort(teensy.port); port.DataReceived += dataReceived; // attach handler for incoming data port.Open(); } catch { teensyID = "Error opening Port"; port?.Dispose(); port = null; } } else // no teensy on bus { if (port != null) { port.DataReceived -= dataReceived; port.Dispose(); port = null; } teensyID = "not found"; } connectedTeensyChanged?.Invoke(this, null); // inform listeners about the change }
private async Task ConnectionHandlerOnConnectionChanged(object sender, ConnectionChangedEventArgs args) { switch (args.Type) { case ConnectionChangedType.Opened: break; case ConnectionChangedType.Closed: await DisconnectPlayer(args.ConnectionId); break; case ConnectionChangedType.Login: break; case ConnectionChangedType.Logout: await DisconnectPlayer(args.ConnectionId); break; default: throw new ArgumentOutOfRangeException(); } }
private static void OnConnectionChanged(object?sender, ConnectionChangedEventArgs e) { Console.WriteLine($"OnConnectionChanged: {e.State}"); }
// TODO: abstractify ? private static void WatcherOnConnectionChanged(object sender, ConnectionChangedEventArgs eventArgs) { if (eventArgs.ChangedDevice.SerialNumber != UnitSerialNumber) { Console.WriteLine($"Ignoring event of device with undesired serial: {eventArgs.ChangedDevice.SerialNumber}"); return; } Console.Write($"{eventArgs} ~ "); switch (eventArgs.ChangeType) { case TeensyWatcher.ChangeType.Add: if (!Connected) { _mainCpu = eventArgs.ChangedDevice; Console.WriteLine("added"); try { _mainCpuPort = new SerialPort(_mainCpu.Port, ControlBaud) { DtrEnable = true }; _mainCpuPort.DataReceived += _mainCpuPort_DataReceived; _mainCpuPort.Open(); Console.WriteLine("Serial port opened at 4.5Mb/s! Sending init message after 500ms delay."); Thread.Sleep(500); var buf = new MemoryStream(); var msg = new InitReq(); Serializer.Serialize(buf, msg); var sendBytes = new byte[buf.Length + 1]; sendBytes[0] = (byte)F3Opcode.InitReq; Buffer.BlockCopy(buf.GetBuffer(), 0, sendBytes, 1, (int)buf.Length); _mainCpuPort.Write(sendBytes, 0, sendBytes.Length); Console.WriteLine($"Sent message. Length: {sendBytes.Length}, Opcode: {msg.Opcode}"); } catch (Exception e) { Console.WriteLine($"Failed to open serial port: \n {e.Message}"); } } else { Console.WriteLine("exists"); } break; case TeensyWatcher.ChangeType.Remove: Console.WriteLine(Connected ? "removed" : "already removed"); _mainCpu = null; break; default: throw new ArgumentOutOfRangeException(); } }
private void ras1_ConnectionChanged(object sender, ConnectionChangedEventArgs e) { }
private void OnConnectionChanged(object sender, ConnectionChangedEventArgs e) { logger.Debug($"CONTROLLER CONNECTION CHANGED: {e.Connected}"); }
private void Connection_ConnectionChanged(object sender, ConnectionChangedEventArgs e) { RaisePropertyChanged("InvertedConnectString"); }
private void HandleConnectionChanged(object sender, ConnectionChangedEventArgs e) { ConnectCommand.CanExecute(!dataConnection.IsConnected); ResetCommand.CanExecute(e.IsConnected); }
void _obd_ObdConnectionChanged(object sender, ConnectionChangedEventArgs e) { SetMessage("OBD " + (e.Connected ? "Connected" : "Disconnected")); }
public virtual void DriverStateChange(ConnectionChangedEventArgs e) { }
private void OnConnectionChanged(object sender, ConnectionChangedEventArgs e) { Console.WriteLine("CONTROLLER CONNECTION CHANGED: {0}", e.Connected); }