Esempio n. 1
0
        // Builds a folder name given various information
        private string buildFolderName(string baseDir, string series, string season, string extras)
        {
            if (baseDir == null || series == null || season == null || baseDir.Length < 1 || series.Length < 1 || season.Length < 1)
            {
                return(null);
            }
            string dir = trimmed(baseDir) + "\\" + trimmed(series) + "\\" + season;

            if (extras != null && extras.Length > 0 && !season.Equals(SpecialsSeason))
            {
                dir += "\\" + trimmed(extras);
            }
            return(FilenameCleaner.cleanPath(dir));
        }
Esempio n. 2
0
 private void ExtrasTextBox_TextChanged(object sender, EventArgs e)
 {
     ExtrasTextBox.Text = FilenameCleaner.scrubFilename(ExtrasTextBox.Text.TrimStart());
     updateDialog();
 }
Esempio n. 3
0
        // Update the dialog as fields are updated - gives us a highly interactive GUI. Not terribly efficient, but it works...
        private FieldResult updateDialog()
        {
            if (skipUpdate)
            {
                return(FieldResult.Success);
            }

            // We do a lot of GUI manipulations (sometimes just temporarily) - turn off updates
            SuspendLayout();

            // We assume everything is perfect and sadly discover the truth.
            FieldResult result = FieldResult.Success;

            // Reset the various statuses and colors to "no error"
            toolStripStatusLabel.Text   = String.Empty;
            BaseFolderTextBox.BackColor = SystemColors.Window;
            SeriesTextBox.BackColor     = SystemColors.Window;
            SeasonUpDown.BackColor      = SystemColors.Window;
            ExtrasTextBox.BackColor     = SystemColors.Window;

            // Assume we have no folders to create (right now, everything is "perfect", remember?)
            NewSeriesFolderButton.Visible = false;
            NewSeasonFolderButton.Visible = false;
            NewExtrasFolderButton.Visible = false;

            // If this is the "Specials" season, we can't have Extras
            if (Season.Equals(SpecialsSeason))
            {
                ExtrasTextBox.Text    = String.Empty;
                ExtrasTextBox.Visible = false;
            }
            else
            {
                ExtrasTextBox.Visible = true;
            }

            // See if the base folder exists
            if (!folderExists(BaseFolderTextBox.Text))
            {
                // Nope - highlight that fact
                BaseFolderTextBox.BackColor = Color.Red;
                toolStripStatusLabel.Text   = "Base folder does not exist.";
                result = FieldResult.BadBase;
            }
            // See if the series folder exists
            else if (!folderExists(BaseFolderTextBox.Text, SeriesTextBox.Text))
            {
                // Nope - but that might be because the user is modifying the base folder and isn't done yet
                if (!BaseFolderTextBox.Focused)
                {
                    // Nope - it's because the folder as typed so far doesn't exist
                    SeriesTextBox.BackColor = Color.Red;
                    if (SeriesTextBox.Text.Length > 0)
                    {
                        NewSeriesFolderButton.Visible = true;
                    }
                }
                result = FieldResult.BadSeries;
            }
            // See if the season folder exists
            else if (!folderExists(BaseFolderTextBox.Text, SeriesTextBox.Text, Season))
            {
                // Nope - the folder as typed (so far) does not exist
                SeasonUpDown.BackColor        = Color.Red;
                NewSeasonFolderButton.Visible = true;
                result = FieldResult.BadSeason;
            }
            // See if the (optional) extras folder exists
            else if (!folderExists(BaseFolderTextBox.Text, SeriesTextBox.Text, Season, ExtrasTextBox.Text))
            {
                // Nope - the folder as typed (so far) does not exist
                ExtrasTextBox.BackColor = Color.Red;
                if (ExtrasTextBox.Text.Length > 0)
                {
                    NewExtrasFolderButton.Visible = true;
                }
                result = FieldResult.BadExtras;
            }

            // If everything passed, we have a valid folder
            if (result == FieldResult.Success)
            {
                // If we have a valid folder, we can create a file
                SaveButton.Enabled = true;

                // If we have a media extension, we have enough info to create its name
                if (MediaExtensionTextBox.Text.Length > 0)
                {
                    MediaFilenameCopyButton.Enabled = true;
                }

                string seasonEpisode = String.Format("S{0:00}E{1:00}", SeasonUpDown.Value, EpisodeUpDown.Value);
                string newFolder     = buildFolderName(BaseFolderTextBox.Text, SeriesTextBox.Text, Season, ExtrasTextBox.Text);

                // If we've changed folders, we need to reload the folder and regenerate the NFO/Media filenames
                if (!newFolder.Equals(watcher.Path))
                {
                    watcher.Path = newFolder;
                    loadList();
                }

                // We need to update the filenames
                NFOFilename.Text   = newFolder + "\\" + FilenameCleaner.cleanFilename(seasonEpisode + " - " + trimmed(TitleTextBox.Text) + ".nfo");
                MediaFilename.Text = newFolder + "\\" + FilenameCleaner.cleanFilename(seasonEpisode + " - " + trimmed(TitleTextBox.Text) + "." + MediaExtensionTextBox.Text.ToLower());
            }
            else
            {
                // We don't have a valid folder, so we can't save anything
                SaveButton.Enabled = false;
                MediaFilenameCopyButton.Enabled = false;

                // So, don't display any filenames
                NFOFilename.Text   = String.Empty;
                MediaFilename.Text = String.Empty;

                // And there's no folder items to display either
                clearList();
            }

            ResumeLayout();
            return(result);
        }