コード例 #1
0
        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");
            }
        }
コード例 #2
0
 private void InvalidateCommands()
 {
     RaisePropertyChanged(() => IsSessionActive);
     CloseCommand.RaiseCanExecuteChanged();
     ExportCommand.RaiseCanExecuteChanged();
     ConnectCommand.RaiseCanExecuteChanged();
     DisconnectCommand.RaiseCanExecuteChanged();
 }
コード例 #3
0
 private void OnCasparCgConnectionStatusChanged(object sender, ConnectionEventArgs e)
 {
     RaisePropertyChanged(nameof(IsConnected));
     ConnectCommand?.RaiseCanExecuteChanged();
     DisconnectCommand?.RaiseCanExecuteChanged();
     PlayCommand?.RaiseCanExecuteChanged();
     VersionCommand?.RaiseCanExecuteChanged();
 }
コード例 #4
0
        public void ExecuteDisconnect()
        {
            if (IsConnected)
            {
                _serialPort.Close();

                ConnectCommand.RaiseCanExecuteChanged();
                DisconnectCommand.RaiseCanExecuteChanged();
                SetFanSpeedCommand.RaiseCanExecuteChanged();
                ReadVariableCommand.RaiseCanExecuteChanged();
                WriteVariableCommand.RaiseCanExecuteChanged();
            }
        }
コード例 #5
0
        /// <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();
        }