private void LoadProcessPicker(bool isAdd) { isPickerProcessActive = true; isPickerProcessAdd = isAdd; pkrProcess.Title = (isAdd) ? "Add a Process" : "Delete a Process"; if (oBlueToothCmds_Picker == null) { oBlueToothCmds_Picker = new BlueToothCmds(); } oBlueToothCmds_Picker.Clear(); try { //oBlueToothCmds_Picker.CreateTestCommands(oUserSetting.GetUserUnits(), false); oBlueToothCmds_Picker.RetrieveCommands(oUserSettings.GetUserUnits(), false); oBlueToothCmds_Picker.RemoveAll(x => (isPickerProcessAdd) ? x.isSelected : !x.isSelected); pkrProcess.ItemsSource = null; pkrProcess.ItemsSource = oBlueToothCmds_Picker; pkrProcess.IsEnabled = true; pkrProcess.IsVisible = true; pkrProcess.SelectedItem = null; pkrProcess.Focus(); } catch (Exception ex) { DisplayMessage(ex.Message); isPickerProcessActive = false; } }
private async Task <bool> OpenBluetooth(string name, string address, bool isTest) { //oBluetooth = null; //oBluetooth = new Bluetooth(true, isTest); // Create connection object if (!oUserSettings.GetIsTestMode()) { if (!Bluetooth.CheckAdapterPresent()) // Check if bluetooth is available on this device: display message and return on failure { ProcessConnectionError(ERROR_TYPE.ADAPTER_ERROR); return(false); } if (!Bluetooth.CheckAdapterEnabled()) // Check if bluetooth is enabled on this device: display message and return on failure { ProcessConnectionError(ERROR_TYPE.ADAPTER_DISABLED); return(false); } if (!oBluetooth.LoadPairedDevices()) // Attempt to load paired devices: display message and return on failure { ProcessConnectionError(ERROR_TYPE.PAIR_ERROR); return(false); } if (!oBluetooth.CheckPairedDevices()) // Check if there are paired devices available: display message and return on failure { ProcessConnectionError(ERROR_TYPE.PAIR_NONE); return(false); } if (!await oBluetooth.OpenPairedDevice(name, address, true)) // Attempt to open paired device: if failed get list of paired devices { ProcessConnectionError(ERROR_TYPE.PAIR_FAILED); return(false); } } // Load commands and run processing loop oBlueToothCmds = null; oBlueToothCmds = new BlueToothCmds(); // ToDo: replace with db values //oBlueToothCmds.CreateTestCommands(oUserSetting.GetUserUnits(), true); oBlueToothCmds.RetrieveCommands(oUserSettings.GetUserUnits(), true); InitCommands(oBlueToothCmds); InitListViewItems(oBlueToothCmds); RunProcesses(); return(true); }
private void UpdateListViewItems() { try { oBlueToothCmds = null; oBlueToothCmds = new BlueToothCmds(); oBlueToothCmds.RetrieveCommands(oUserSettings.GetUserUnits(), false); InitListViewItems(oBlueToothCmds); } catch (Exception e) { Debug.WriteLine("Error updating listview:" + e.Message); } }