Ejemplo n.º 1
0
        public MainWindow()
        {
            _logic = new Logic();

            _refreshPortListCommand = new RelayCommand<object>(param => _logic.RefreshPortList(),
                param => !_logic.IsConnectionOpen);
            _startCommunicationCommand = new RelayCommand<object>(param => OpenConnection(),
                param => _logic.CanOpenConnection);
            _stopCommunicationCommand = new RelayCommand<object>(param => CloseConnection(),
                param => _logic.IsConnectionOpen);
            _syncDisplayCommand = new RelayCommand<object>(param => SendDisplayData(),
                param => _logic.CanSendCommand);
            _requestAccelerometerValuesCommandCommand = new RelayCommand<object>(param => RequestAccelerometerValues(),
                param => _logic.CanSendCommand && _logic.IsAccelerometerOn);
            _requestBrightnessCommand = new RelayCommand<object>(param => RequestBrightness(),
                param => _logic.CanSendCommand);
            _setNumericDisplayValueCommand = new RelayCommand<object>(param => SetNumericDisplayValue(),
                param => _logic.CanSendCommand);

            _log = new ConcurrentObservableLog(Dispatcher);

            _logic.DeviceReady += OnDeviceReady;
            _logic.ButtonStateChanged += OnButtonStateChanged;
            _logic.BrightnessReceived += OnBrightnessReceived;
            _logic.AccelerometerStateReceived += OnAccelerometerStateReceived;
            _logic.AccelerometerValuesReceived += OnAccelerometerValuesReceived;
            _logic.EmptyPortList += OnEmptyPortList;
            _logic.ComPortTimeout += OnComPortTimeout;

            _logic.RefreshPortList();

            DataContext = this;
            InitializeComponent();
        }
Ejemplo n.º 2
0
 private void MainWindowClosing(object sender, EventArgs e)
 {
     DataContext = null;
     _logic.Dispose();
     _logic = null;
 }