diff --git a/INTV.LtoFlash/Model/Device.cs b/INTV.LtoFlash/Model/Device.cs index e12a2bc8..d47afffc 100644 --- a/INTV.LtoFlash/Model/Device.cs +++ b/INTV.LtoFlash/Model/Device.cs @@ -569,6 +569,15 @@ public static IPeripheral GetLtoFlashDevice(IConnection connection, object state { var creationInfo = state as DeviceCreationInfo; if (creationInfo == null) + { + var stateDictionaryData = state as Dictionary; + object creationInfoObject = null; + if ((stateDictionaryData != null) && stateDictionaryData.TryGetValue(DeviceCreationInfo.ConfigName, out creationInfoObject)) + { + creationInfo = (DeviceCreationInfo)creationInfoObject; + } + } + if (creationInfo == null) { creationInfo = new DeviceCreationInfo(Properties.Settings.Default.AutomaticallyConnectToDevices, false, Properties.Settings.Default.AutomaticallyConnectToDevices ? ActivationMode.ActivateIfFirst : ActivationMode.UserSettings); } diff --git a/INTV.LtoFlash/ViewModel/LtoFlashViewModel.cs b/INTV.LtoFlash/ViewModel/LtoFlashViewModel.cs index fb6e11ff..fdb51aed 100644 --- a/INTV.LtoFlash/ViewModel/LtoFlashViewModel.cs +++ b/INTV.LtoFlash/ViewModel/LtoFlashViewModel.cs @@ -457,6 +457,16 @@ internal void PromptForDeviceSelection(IList ports) { SelectionDialogShowing = true; SingleInstanceApplication.Instance.IsBusy = true; + if (!ports.Select(p => Connection.CreatePseudoConnection(p, ConnectionType.Serial)).Where(p => IsLtoFlashSerialPortConnection(p)).Any()) + { + // The newly arrived ports do does not appear to contain any LTO Flash! hardware, so skip showing the dialog. + return; + } + foreach (var additionalKnownLtoFlashPort in PotentialDevicePorts.Select(p => p.Name).Except(ports)) + { + ports.Add(additionalKnownLtoFlashPort); + } + OSWindow dialog = null; var multiSelect = ports.Count() > 1; var title = multiSelect ? Resources.Strings.SelectDeviceDialog_Title : Resources.Strings.ConnectToDevice_Title; @@ -511,6 +521,13 @@ internal void ResetCachedFileSystemsCompareResult() _cachedFileSystemsCompareResult = null; } + private static bool IsLtoFlashSerialPortConnection(IConnection connection) + { + // Always check the given connection regardless of the user setting. We *really* want to know if this is an LTO Flash! device. + var isLtoFlashPort = SerialConnectionPolicy.Instance.ExclusiveAccess(connection); + return isLtoFlashPort; + } + private static bool MessageBoxExceptionFilter(System.Exception exception) { var report = true;