/// <summary> /// Cache the current disc type to internal variable /// </summary> private void CacheCurrentDiscType() { // If the selected item is invalid, we just skip if (!(DriveLetterComboBox.SelectedItem is Drive drive)) { return; } // Get reasonable default values based on the current system KnownSystem?currentSystem = Systems[SystemTypeComboBox.SelectedIndex]; MediaType? defaultMediaType = Validators.GetValidMediaTypes(currentSystem).FirstOrDefault() ?? MediaType.CDROM; if (defaultMediaType == MediaType.NONE) { defaultMediaType = MediaType.CDROM; } // If we're skipping detection, set the default value if (Options.SkipMediaTypeDetection) { LogOutput.VerboseLogLn($"Media type detection disabled, defaulting to {defaultMediaType.LongName()}."); CurrentMediaType = defaultMediaType; } // If the drive is marked active, try to read from it else if (drive.MarkedActive) { LogOutput.VerboseLog($"Trying to detect media type for drive {drive.Letter}.. "); (MediaType? detectedMediaType, string errorMessage) = Validators.GetMediaType(drive); // If we got an error message, post it to the log if (errorMessage != null) { LogOutput.VerboseLogLn($"Error in detecting media type: {errorMessage}"); } // If we got either an error or no media, default to the current System default if (detectedMediaType == null) { LogOutput.VerboseLogLn($"Unable to detect, defaulting to {defaultMediaType.LongName()}."); CurrentMediaType = defaultMediaType; } else { LogOutput.VerboseLogLn($"Detected {CurrentMediaType.LongName()}."); CurrentMediaType = detectedMediaType; } } // All other cases, just use the default else { LogOutput.VerboseLogLn($"Drive marked as empty, defaulting to {defaultMediaType.LongName()}."); CurrentMediaType = defaultMediaType; } }
/// <summary> /// Cache the current disc type to internal variable /// </summary> private void CacheCurrentDiscType() { // Get the drive letter from the selected item if (DriveLetterComboBox.SelectedItem is Drive drive) { // Get the current media type, if possible if (UIOptions.Options.SkipMediaTypeDetection) { ViewModels.LoggerViewModel.VerboseLog("Media type detection disabled, defaulting to CD-ROM"); CurrentMediaType = MediaType.CDROM; } else { ViewModels.LoggerViewModel.VerboseLog("Trying to detect media type for drive {0}.. ", drive.Letter); CurrentMediaType = Validators.GetMediaType(drive); ViewModels.LoggerViewModel.VerboseLogLn(CurrentMediaType == null ? "unable to detect, defaulting to CD-ROM." : ($"detected {CurrentMediaType.LongName()}.")); if (CurrentMediaType == null) { CurrentMediaType = MediaType.CDROM; } } } }