private bool SelectedUSBDevicePredicate(FTDIDeviceInfo device) { if (device != null) { if (SelectedDeviceInfo != null) { if ((SelectedDeviceInfo.Description != device.Description) || (SelectedDeviceInfo.SerialNumber != device.SerialNumber) || (SelectedDeviceInfo.Type != device.Type) || (SelectedDeviceInfo.ID != device.ID)) { return(false); } } } return(true); }
private void OnRefreshDevices() { RefreshDevices(); FTDIDeviceInfo matchedInfoInList = FTDIDevices.FirstOrDefault(this.SelectedUSBDevicePredicate); if (matchedInfoInList == null) { //couldn't find the the selected device in the list, try to use the first one in the list SelectedDeviceInfo = FTDIDevices.FirstOrDefault(); } else { //use the one in the list SelectedDeviceInfo = matchedInfoInList; } CollectionViewSource.GetDefaultView(FTDIDevices).MoveCurrentToFirst(); }