コード例 #1
0
        private void renameButton_Click(object sender, EventArgs e)
        {
            try
            {
                if (!CheckFileTypeMatch())
                {
                    MessageBox.Show("Rename aborted", "Info", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    return;
                }
                FileList      finalFilePaths = InitializeRenameList();
                List <string> errorList      = RenameOperations.RenameFiles(subtitleFilePathList, finalFilePaths);

                if (errorList.Count > 0)
                {
                    if (
                        MessageBox.Show("At least an error occurred during renaming. Do you want to check details?", "Warning", MessageBoxButtons.YesNo,
                                        MessageBoxIcon.Warning) == DialogResult.Yes)
                    {
                        ResultForm previewForm = new ResultForm(subtitleFilePathList, finalFilePaths, errorList);
                        previewForm.RenameTitle("Result");
                        previewForm.ShowDialog();
                    }
                }
                else
                {
                    MessageBox.Show("All files have been renamed successfully.", "Conguratulations", MessageBoxButtons.OK, MessageBoxIcon.Information);

                    if (optionClearSubtitlesAfterRename.Checked)
                    {
                        clearSubtitleList();
                    }
                    if (optionClearMoviesAfterRename.Checked)
                    {
                        clearMovieList();
                    }
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show("An error occurred\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (InvalidOperationException ex)
            {
                MessageBox.Show("An error occurred\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }
コード例 #2
0
        private FileList InitializeRenameList()
        {
            RenameOptions renameOptions = new RenameOptions
            {
                SubtitleFileList = subtitleFilePathList,
                MovieFileList    = movieFilePathList,

                Template = renameTemplateTextBox.Text,

                SpecifySubtitleGroup = optionSpecifySubtitleGroup.Checked,
                SubtitleGroup        = optionSubtitleGroup.Text,

                SpecifyLanguage = optionSpecifyLanguage.Checked,
                Language        = optionLanguage.Text,

                SpecifyExtension = optionSpecifyExtension.Checked,
                Extension        = optionExtension.Text,

                MoveToMovieFolder = optionMoveToMovieFolder.Checked
            };

            return(RenameOperations.GenerateRenameList(renameOptions));
        }