Exemple #1
0
 private void HardQueryOfDevices()
 {
     _available_port_list = BehaviorBoard.QueryConnectedArduinoDevices();
     NotifyPropertyChanged("AvailablePorts");
     NotifyPropertyChanged("AvailablePortCount");
     NotifyPropertyChanged("NoBoothsTextVisibility");
 }
Exemple #2
0
        /// <summary>
        /// Kicks off a refresh of the booth listing in the booth selection box
        /// </summary>
        public void ToggleRefresh()
        {
            if (_refresh_thread == null || !_refresh_thread.IsBusy)
            {
                //Set up the necessary code for the background thread to refresh the booth listing
                _refresh_thread = new BackgroundWorker();
                _refresh_thread.WorkerReportsProgress      = true;
                _refresh_thread.WorkerSupportsCancellation = true;
                _refresh_thread.DoWork += delegate
                {
                    _available_port_list = BehaviorBoard.QueryConnectedArduinoDevices();
                    foreach (var port in _available_port_list)
                    {
                        bool success = BehaviorBoard.QueryIndividualArduinoDevice(port.DeviceID);
                        port.IsPortBusy = !success;
                    }
                };
                _refresh_thread.ProgressChanged += delegate
                {
                    //code goes here
                };
                _refresh_thread.RunWorkerCompleted += delegate
                {
                    _currently_refreshing = false;
                    NotifyPropertyChanged("AvailablePorts");
                    NotifyPropertyChanged("AvailablePortCount");
                    NotifyPropertyChanged("NoBoothsTextVisibility");
                    NotifyPropertyChanged("NoBoothsDetectedText");
                    NotifyPropertyChanged("SelectBoothButtonContent");
                    NotifyPropertyChanged("SelectBoothButtonEnabled");
                };

                //Set a flag indicating that the booth list is being refreshed
                _currently_refreshing = true;

                //Run the background thread to refresh the booth listing
                _refresh_thread.RunWorkerAsync();
            }
        }