Esempio n. 1
0
 /// <summary>
 /// Default constructor, better if first run uses this one, since it sets all the options to default values and the temp folder to the user's Winodws-based temp folder.
 /// </summary>
 /// <param name="firstRun">Whether or not this is the first run of the program.</param>
 public OptionsDialog(bool firstRun)
 {
     ShowCovers            = true;
     DownloadFromWeb       = true;                                       //Set everything to their default values, and load in the user's Windows-based temp folder as the default path for temp folder
     EnableRarExtraction   = true;
     TempDirectory         = Path.Combine(Path.GetTempPath(), "WBFSTemp");
     AutomaticUpdateChecks = true;
     CoverDirs             = new ObservableCollection <String>();
     SrcWadFile            = String.Empty;
     KeyFile               = String.Empty;
     LoaderFile            = String.Empty;
     OriginalTitleId       = String.Empty;
     EnableChannelCreation = false;
     PartitionToUse        = libwbfsNET.WbfsIntermWrapper.PartitionSelector.ONLY_GAME_PARTITION;
     InitializeComponent();
     if (firstRun)
     {
         CancelButton.IsEnabled = false;
         _allowClosing          = false;
     }
     LoadPartitionChoices(libwbfsNET.WbfsIntermWrapper.PartitionSelector.ONLY_GAME_PARTITION);
     LoadPresets();
     xmlPresetComboBox.ItemsSource       = _presets;
     xmlPresetComboBox.DisplayMemberPath = "Description";
     if (firstRun && xmlPresetComboBox.Items.Count > 0)
     {
         xmlPresetComboBox.SelectedIndex = 0;
     }
 }
Esempio n. 2
0
        /// <summary>
        /// Event handler for when the OK button is clicked. Makes a final check on the temp directory and gives a warning if theres no space or cancels the ok if no value has been entered for it.
        /// </summary>
        private void OkButton_Click(object sender, RoutedEventArgs e)
        {
            //Make sure the directory that's been entered is not an empty string and that it actually exists. If not, show an error message and stay on the options dialog.
            if (TempDirectory.Length == 0)
            {
                MessageBox.Show(this, Properties.Resources.MustSelectValidFolderText, Properties.Resources.InvalidTempFolderStr, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (!Directory.Exists(TempDirectory))
            {
                try
                {
                    Directory.CreateDirectory(TempDirectory);
                }
                catch
                {
                    MessageBox.Show(this, Properties.Resources.ErrorUnableToCreateTempDirStr + TempDirectory, Properties.Resources.ErrorUnableToCreateDirShortStr, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
            }
            //Make sure the drive the temp folder is on has enough space for at least a single layer DVD
            if (!Utils.CheckTempForSpace(TempDirectory))
            {
                // If there isnt enough space, show a warning and give the user the option to go ahead anyway.
                MessageBoxResult result = MessageBox.Show(this, Properties.Resources.WarningNotEnoughSpaceTempStr, Properties.Resources.ErrorNotEnoughSpaceShortStr, MessageBoxButton.OKCancel, MessageBoxImage.Warning);
                if (result != MessageBoxResult.OK)     //If the user hits cancel, they've decided not to go ahead with the selected directory which doesnt have enough space.
                {
                    return;
                }
            }
            if (EnableChannelCreation && (SrcWadFile.Trim().Length == 0 || LoaderFile.Trim().Length == 0 || KeyFile.Trim().Length == 0 || OriginalTitleId.Trim().Length == 0))
            {
                MessageBox.Show(this, Properties.Resources.ErrorInvalidChanCreationValsStr, Properties.Resources.ErrorInvalidValsShortStr, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (PartitionsToUseComboBox.SelectedIndex < 0)
            {
                MessageBox.Show(this, Properties.Resources.ErrorInvalidPartitionSettingStr, Properties.Resources.ErrorInvalidValsShortStr, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }
            if (PartitionsToUseComboBox.SelectedIndex == 0)
            {
                PartitionToUse = libwbfsNET.WbfsIntermWrapper.PartitionSelector.ONLY_GAME_PARTITION;
            }
            else if (PartitionsToUseComboBox.SelectedIndex == 1)
            {
                PartitionToUse = libwbfsNET.WbfsIntermWrapper.PartitionSelector.REMOVE_UPDATE_PARTITION;
            }
            else
            {
                PartitionToUse = libwbfsNET.WbfsIntermWrapper.PartitionSelector.ALL_PARTITIONS;
            }

            _allowClosing = true;       //Allow closing now that everything checks out.
            DialogResult  = true;       //Set the result of this dialog to true, meaning the OK button was clicked and was successful. This automatically closes the dialog since it's shown modally.
        }
Esempio n. 3
0
 private void LoadPartitionChoices(libwbfsNET.WbfsIntermWrapper.PartitionSelector partitionToUse)
 {
     PartitionsToUseComboBox.Items.Add(Properties.Resources.PartitonOptionOnlyGameStr);
     PartitionsToUseComboBox.Items.Add(Properties.Resources.ParitionOptionRemoveUpdateStr);
     PartitionsToUseComboBox.Items.Add(Properties.Resources.PartitionOptionAllPartStr);
     if (partitionToUse == libwbfsNET.WbfsIntermWrapper.PartitionSelector.ONLY_GAME_PARTITION)
     {
         PartitionsToUseComboBox.SelectedIndex = 0;
     }
     else if (partitionToUse == libwbfsNET.WbfsIntermWrapper.PartitionSelector.REMOVE_UPDATE_PARTITION)
     {
         PartitionsToUseComboBox.SelectedIndex = 1;
     }
     else
     {
         PartitionsToUseComboBox.SelectedIndex = 2;
     }
 }
Esempio n. 4
0
 /// <summary>
 /// Parameterized constructor for the options dialog which sets the values of the different options to the values passed in as parameters.
 /// </summary>
 /// <param name="automaticUpdateChecks"></param>
 /// <param name="firstRun">A flag indicating whether this is the first run (if so closing/cancelling out is not possible)</param>
 /// <param name="showCovers">Whether or not showing covers is enabled.</param>
 /// <param name="downloadFromWeb">Whether or not downloading covers from the web is enabled.</param>
 /// <param name="tempFolder">The temporary folder for RAR extraction and indirect drive-to-drive copying.</param>
 /// <param name="coverDirs">The list of user selected cover directories.</param>
 /// <param name="enableRarExtraction">Whether or not RAR extraction is enabled.</param>
 /// <param name="srcWadFile">The path to the source (base) WAD file.</param>
 /// <param name="enableChannelCreation">Whether or not to enable channel creation.</param>
 /// <param name="partitionToUse">The settings for Wii disc partitions to save when adding games to the WBFS drive.</param>
 /// <param name="keyFile">The path to the common-key.bin file</param>
 /// <param name="loaderFile">The path to the loader .dol file.</param>
 /// <param name="originalTitleId">The base WAD file's placeholder title ID.</param>
 public OptionsDialog(bool firstRun, bool showCovers, bool downloadFromWeb, String tempFolder, StringCollection coverDirs, bool enableRarExtraction, bool automaticUpdateChecks, String srcWadFile, String keyFile, String loaderFile, String originalTitleId, bool enableChannelCreation, libwbfsNET.WbfsIntermWrapper.PartitionSelector partitionToUse)
 {
     ShowCovers            = showCovers;
     DownloadFromWeb       = downloadFromWeb;
     TempDirectory         = tempFolder;                         //Initialize all these values before calling initialize component otherwise values will be null causing wierd UI acting up.
     CoverDirs             = new ObservableCollection <String>();
     EnableRarExtraction   = enableRarExtraction;
     AutomaticUpdateChecks = automaticUpdateChecks;
     if (coverDirs != null)
     {
         foreach (String item in coverDirs)
         {
             CoverDirs.Add(item);
         }
     }
     SrcWadFile            = srcWadFile;
     KeyFile               = keyFile;
     LoaderFile            = loaderFile;
     OriginalTitleId       = originalTitleId;
     EnableChannelCreation = enableChannelCreation;
     PartitionToUse        = partitionToUse;
     InitializeComponent();                                      //Initialize the UI components
     if (firstRun)                                               //If this is the first run disable the cancel button and don't allow closing.
     {
         CancelButton.IsEnabled = false;
         _allowClosing          = false;
     }
     LoadPartitionChoices(partitionToUse);
     LoadPresets();
     xmlPresetComboBox.ItemsSource       = _presets;
     xmlPresetComboBox.DisplayMemberPath = "Description";
     if (firstRun && xmlPresetComboBox.Items.Count > 0)
     {
         xmlPresetComboBox.SelectedIndex = 0;
     }
 }