예제 #1
0
        /// <summary>
        /// Get a complete list of active disc drives and fill the combo box
        /// </summary>
        /// <remarks>TODO: Find a way for this to periodically run, or have it hook to a "drive change" event</remarks>
        private void PopulateDrives()
        {
            LogOutput.VerboseLogLn("Scanning for drives..");

            // Always enable the media scan
            MediaScanButton.IsEnabled = true;

            // Populate the list of drives and add it to the combo box
            Drives = Validators.CreateListOfDrives(Options.IgnoreFixedDrives);
            DriveLetterComboBox.ItemsSource = Drives;

            if (DriveLetterComboBox.Items.Count > 0)
            {
                LogOutput.VerboseLogLn($"Found {Drives.Count} drives: {string.Join(", ", Drives.Select(d => d.Letter))}");

                // Check for active optical drives first
                int index = Drives.FindIndex(d => d.MarkedActive && d.InternalDriveType == InternalDriveType.Optical);

                // Then we check for floppy drives
                if (index == -1)
                {
                    index = Drives.FindIndex(d => d.MarkedActive && d.InternalDriveType == InternalDriveType.Floppy);
                }

                // Then we try all other drive types
                if (index == -1)
                {
                    index = Drives.FindIndex(d => d.MarkedActive);
                }

                // Set the selected index
                DriveLetterComboBox.SelectedIndex = (index != -1 ? index : 0);
                StatusLabel.Content             = "Valid drive found! Choose your Media Type";
                CopyProtectScanButton.IsEnabled = true;

                // Get the current system type
                if (index != -1)
                {
                    DetermineSystemType();
                }

                // Only enable the start/stop if we don't have the default selected
                StartStopButton.IsEnabled = ShouldEnableDumpingButton();
            }
            else
            {
                LogOutput.VerboseLogLn("Found no drives");
                DriveLetterComboBox.SelectedIndex = -1;
                StatusLabel.Content             = "No valid drive found!";
                StartStopButton.IsEnabled       = false;
                CopyProtectScanButton.IsEnabled = false;
            }
        }
예제 #2
0
        /// <summary>
        /// Get a complete list of active disc drives and fill the combo box
        /// </summary>
        /// <remarks>TODO: Find a way for this to periodically run, or have it hook to a "drive change" event</remarks>
        private void PopulateDrives()
        {
            ViewModels.LoggerViewModel.VerboseLogLn("Scanning for drives..");

            // Always enable the media scan
            MediaScanButton.IsEnabled = true;

            // Populate the list of drives and add it to the combo box
            Drives = Validators.CreateListOfDrives(UIOptions.Options.IgnoreFixedDrives);
            DriveLetterComboBox.ItemsSource = Drives;

            if (DriveLetterComboBox.Items.Count > 0)
            {
                // Check for active optical drives first
                int index = Drives.FindIndex(d => d.MarkedActive && d.InternalDriveType == InternalDriveType.Optical);

                // Then we check for floppy drives
                if (index == -1)
                {
                    index = Drives.FindIndex(d => d.MarkedActive && d.InternalDriveType == InternalDriveType.Floppy);
                }

                // Then we try all other drive types
                if (index == -1)
                {
                    index = Drives.FindIndex(d => d.MarkedActive);
                }

                // Set the selected index
                DriveLetterComboBox.SelectedIndex = (index != -1 ? index : 0);
                StatusLabel.Content             = "Valid drive found! Choose your Media Type";
                CopyProtectScanButton.IsEnabled = true;

                // Get the current media type
                if (!UIOptions.Options.SkipSystemDetection && index != -1)
                {
                    ViewModels.LoggerViewModel.VerboseLog("Trying to detect system for drive {0}.. ", Drives[index].Letter);
                    var currentSystem = Validators.GetKnownSystem(Drives[index]);
                    ViewModels.LoggerViewModel.VerboseLogLn(currentSystem == null || currentSystem == KnownSystem.NONE ? "unable to detect." : ("detected " + currentSystem.LongName() + "."));

                    if (currentSystem != null && currentSystem != KnownSystem.NONE)
                    {
                        int sysIndex = Systems.FindIndex(s => s == currentSystem);
                        SystemTypeComboBox.SelectedIndex = sysIndex;
                    }
                }

                // Only enable the start/stop if we don't have the default selected
                StartStopButton.IsEnabled = (SystemTypeComboBox.SelectedItem as KnownSystemComboBoxItem) != KnownSystem.NONE;

                ViewModels.LoggerViewModel.VerboseLogLn("Found {0} drives: {1}", Drives.Count, string.Join(", ", Drives.Select(d => d.Letter)));
            }
            else
            {
                DriveLetterComboBox.SelectedIndex = -1;
                StatusLabel.Content             = "No valid drive found!";
                StartStopButton.IsEnabled       = false;
                CopyProtectScanButton.IsEnabled = false;

                ViewModels.LoggerViewModel.VerboseLogLn("Found no drives");
            }
        }