Esempio n. 1
0
        /// <summary>
        /// Set the current disc type in the combo box
        /// </summary>
        private void SetCurrentDiscType()
        {
            // If we have an invalid current type, we don't care and return
            if (CurrentMediaType == null || CurrentMediaType == MediaType.NONE)
            {
                return;
            }

            // Now set the selected item, if possible
            int index = MediaTypes.FindIndex(kvp => kvp.Value == CurrentMediaType);

            if (index != -1)
            {
                MediaTypeComboBox.SelectedIndex = index;
            }
            else
            {
                StatusLabel.Content = $"Disc of type '{Converters.LongName(CurrentMediaType)}' found, but the current system does not support it!";
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Populate media type according to system type
        /// </summary>
        private void PopulateMediaType()
        {
            KnownSystem?currentSystem = SystemTypeComboBox.SelectedItem as KnownSystemComboBoxItem;

            if (currentSystem != null)
            {
                var mediaTypeValues = Validators.GetValidMediaTypes(currentSystem);
                MediaTypes = Element <MediaType> .GenerateElements().Where(m => mediaTypeValues.Contains(m.Value)).ToList();

                MediaTypeComboBox.ItemsSource = MediaTypes;

                MediaTypeComboBox.IsEnabled = MediaTypes.Count > 1;
                int currentIndex = MediaTypes.FindIndex(m => m == CurrentMediaType);
                MediaTypeComboBox.SelectedIndex = (currentIndex > -1 ? currentIndex : 0);
            }
            else
            {
                MediaTypeComboBox.IsEnabled     = false;
                MediaTypeComboBox.ItemsSource   = null;
                MediaTypeComboBox.SelectedIndex = -1;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Process the current custom parameters back into UI values
        /// </summary>
        private void ProcessCustomParameters()
        {
            Env.SetParameters(ParametersTextBox.Text);
            if (Env.Parameters == null)
            {
                return;
            }

            int driveIndex = Drives.Select(d => d.Letter).ToList().IndexOf(Env.Parameters.InputPath[0]);

            if (driveIndex > -1)
            {
                DriveLetterComboBox.SelectedIndex = driveIndex;
            }

            int driveSpeed = Env.Parameters.Speed ?? -1;

            if (driveSpeed > 0)
            {
                DriveSpeedComboBox.SelectedValue = driveSpeed;
            }
            else
            {
                Env.Parameters.Speed = DriveSpeedComboBox.SelectedValue as int?;
            }

            // Disable automatic reprocessing of the textboxes until we're done
            RemovePathEventHandlers();

            // Save the current cursor positions
            int outputDirectorySelectionStart = OutputDirectoryTextBox.SelectionStart;
            int outputFilenameSelectionStart  = OutputFilenameTextBox.SelectionStart;

            string trimmedPath     = Env.Parameters.OutputPath?.Trim('"') ?? string.Empty;
            string outputDirectory = Path.GetDirectoryName(trimmedPath);
            string outputFilename  = Path.GetFileName(trimmedPath);

            (outputDirectory, outputFilename) = DumpEnvironment.NormalizeOutputPaths(outputDirectory, outputFilename, Options.InternalProgram == InternalProgram.DiscImageCreator);
            if (!string.IsNullOrWhiteSpace(outputDirectory))
            {
                OutputDirectoryTextBox.Text = outputDirectory;
            }
            else
            {
                outputDirectory = OutputDirectoryTextBox.Text;
            }
            if (!string.IsNullOrWhiteSpace(outputFilename))
            {
                OutputFilenameTextBox.Text = outputFilename;
            }
            else
            {
                outputFilename = OutputFilenameTextBox.Text;
            }

            // Set the cursor position back to where it was
            OutputDirectoryTextBox.SelectionStart  = outputDirectorySelectionStart;
            OutputDirectoryTextBox.SelectionLength = 0;
            OutputFilenameTextBox.SelectionStart   = outputFilenameSelectionStart;
            OutputFilenameTextBox.SelectionLength  = 0;

            // Re-enable automatic reprocessing of textboxes
            AddPathEventHandlers();

            MediaType?mediaType      = Env.Parameters.GetMediaType();
            int       mediaTypeIndex = MediaTypes.FindIndex(m => m == mediaType);

            if (mediaTypeIndex > -1)
            {
                MediaTypeComboBox.SelectedIndex = mediaTypeIndex;
            }
        }