public void ExecuteConnect() { if (!IsConnected) { _serialPort.PortName = ComPort; _serialPort.BaudRate = 9600; _serialPort.Parity = Parity.None; _serialPort.StopBits = StopBits.One; _serialPort.DataBits = 8; _serialPort.Handshake = Handshake.None; _serialPort.DataReceived += SerialPortDataReceivedHandler; _serialPort.ReceivedBytesThreshold = Vallox.TelegramLength; _serialPort.ReadBufferSize = 1024; _serialPort.Open(); ConnectCommand.RaiseCanExecuteChanged(); DisconnectCommand.RaiseCanExecuteChanged(); SetFanSpeedCommand.RaiseCanExecuteChanged(); ReadVariableCommand.RaiseCanExecuteChanged(); WriteVariableCommand.RaiseCanExecuteChanged(); RaisePropertyChanged("IsConnected"); } }
private void InvalidateCommands() { RaisePropertyChanged(() => IsSessionActive); CloseCommand.RaiseCanExecuteChanged(); ExportCommand.RaiseCanExecuteChanged(); ConnectCommand.RaiseCanExecuteChanged(); DisconnectCommand.RaiseCanExecuteChanged(); }
private void OnCasparCgConnectionStatusChanged(object sender, ConnectionEventArgs e) { RaisePropertyChanged(nameof(IsConnected)); ConnectCommand?.RaiseCanExecuteChanged(); DisconnectCommand?.RaiseCanExecuteChanged(); PlayCommand?.RaiseCanExecuteChanged(); VersionCommand?.RaiseCanExecuteChanged(); }
public void ExecuteDisconnect() { if (IsConnected) { _serialPort.Close(); ConnectCommand.RaiseCanExecuteChanged(); DisconnectCommand.RaiseCanExecuteChanged(); SetFanSpeedCommand.RaiseCanExecuteChanged(); ReadVariableCommand.RaiseCanExecuteChanged(); WriteVariableCommand.RaiseCanExecuteChanged(); } }
/// <summary> /// toggles between the states of enable/disable of the connect/disconnect command buttons, with a slight delay to prevent connection spamming /// </summary> /// <param name="delay"></param> private async void ToggleBlockConnectionCommands(bool delay) { if (delay) { await Task.Factory.StartNew(() => Thread.Sleep(1000)); } BlockConnectionCommands = !BlockConnectionCommands; ConnectCommand.RaiseCanExecuteChanged(); DisconnectCommand.RaiseCanExecuteChanged(); SendTextCommand.RaiseCanExecuteChanged(); RollDiceCommand.RaiseCanExecuteChanged(); }