///<summary>Updates the newFilemane Atrubute of the given FileElement.</summary> ///<param name="file">the FileElement to update newFilename.</param> ///<param name="pos">the position index in the files List.</param> private void Series_updateFileName(FileElement file, int pos) { string fileName; int episodeCounter; //number of the episode string episodeNumber; //leading zeroes + episodeCounter string LanguageString; string episodeTitle; //calculate episodeNumber episodeCounter = pos * (int)series_counterStepsizeNumericUpDown.Value + (int)series_counterStartvalueNumericUpDown.Value; episodeNumber = episodeCounter.ToString(); while (episodeNumber.Length < series_counterLeadingzerosLengthNumericUpDown.Value && !ReferenceEquals((ComboBoxItem)series_counterLeadingzerosTypeComboBox.SelectedItem, series_counterLeadingzerosTypeNoneComboBoxItem)) { if (ReferenceEquals((ComboBoxItem)series_counterLeadingzerosTypeComboBox.SelectedItem, series_counterLeadingzerosTypeZeroComboBoxItem)) { episodeNumber = "0" + episodeNumber; } else if (ReferenceEquals((ComboBoxItem)series_counterLeadingzerosTypeComboBox.SelectedItem, series_counterLeadingzerosTypeSpaceComboBoxItem)) { episodeNumber = " " + episodeNumber; } else if (ReferenceEquals((ComboBoxItem)series_counterLeadingzerosTypeComboBox.SelectedItem, series_counterLeadingzerosTypeUnderscoreComboBoxItem)) { episodeNumber = "_" + episodeNumber; } } //calculate Language if (ReferenceEquals((ComboBoxItem)series_newFileNameLangugageComboBox.SelectedItem, series_newFileNameLangugageNoneComboBoxItem)) { LanguageString = ""; } else { LanguageString = " " + ((ComboBoxItem)series_newFileNameLangugageComboBox.SelectedItem).Content; } //calculate EpisodeTitle episodeTitle = Series_CalculateEpisodeTitle(episodeCounter); //join fileName fileName = series_newFileNameSeriesNameTextBox.Text; fileName += " Folge "; fileName += episodeNumber; fileName += LanguageString; if (series_newFileNameMinusCheckBox.IsChecked == true) { fileName += " - "; } fileName += episodeTitle; //remove illegal Characters fileName = RemoveIllegalChars(fileName); //Dateiendung hinzufügen //fileName += System.IO.Path.GetExtension(file.GetFullPath()); file.SetNewFilename(fileName); }
//Replace ========================================================================= ///<summary>Updates the newFilemane Atrubute of the given FileElement.</summary> ///<param name="file">the FileElement to update newFilename.</param> ///<param name="pos">the position index in the files List.</param> private void Replace_updateFileName(FileElement file) { string newFileName; if (replace_extensionCheckBox.IsChecked != true) { newFileName = file.GetFileNameWithoutExtension(); } else { newFileName = file.GetFilename(); } if (replace_searchTextBox.Text != "") { newFileName = newFileName.Replace(replace_searchTextBox.Text, replace_replaceTextBox.Text); } if (replace_extensionCheckBox.IsChecked != true) { newFileName += file.GetExtension(); } file.SetNewFilename(newFileName); }
//Normal Tab ========================================================================= ///<summary>Updates the newFilemane Atrubute of the given FileElement.</summary> ///<param name="file">the FileElement to update newFilename.</param> ///<param name="pos">the position index in the files List.</param> private void Normal_updateFileName(FileElement file, int pos) { string newFileName; string counterString; //includes leading zeroes //calculate counter counterString = ((int)normal_counterStartvalueNumericUpDown.Value + pos * (int)normal_counterStepsizeNumericUpDown.Value).ToString(); while (counterString.Length < normal_counterLeadingzerosLengthNumericUpDown.Value && !ReferenceEquals((ComboBoxItem)normal_counterLeadingzerosTypeComboBox.SelectedItem, normal_counterLeadingzerosTypeNoneComboBoxItem)) { if (ReferenceEquals((ComboBoxItem)normal_counterLeadingzerosTypeComboBox.SelectedItem, normal_counterLeadingzerosTypeZeroComboBoxItem)) { counterString = "0" + counterString; } else if (ReferenceEquals((ComboBoxItem)normal_counterLeadingzerosTypeComboBox.SelectedItem, normal_counterLeadingzerosTypeSpaceComboBoxItem)) { counterString = " " + counterString; } else if (ReferenceEquals((ComboBoxItem)normal_counterLeadingzerosTypeComboBox.SelectedItem, normal_counterLeadingzerosTypeUnderscoreComboBoxItem)) { counterString = "_" + counterString; } } //calculate newFilemame newFileName = normal_newFileNameTextBox.Text; //replace [NAME] while (newFileName.IndexOf("[NAME]") != -1) { newFileName = newFileName.Replace("[NAME]", file.GetFileNameWithoutExtension()); } //replace [C] while (newFileName.IndexOf("[C]") != -1) { newFileName = newFileName.Replace("[C]", counterString); } //add extension newFileName += file.GetExtension(); file.SetNewFilename(newFileName); }