}\r
\r
/// <summary>\r
+ /// Create a CSV file with the data from the Main Window Chapters tab\r
+ /// </summary>\r
+ /// <param name="mainWindow">Main Window</param>\r
+ /// <param name="filePathName">Path to save the csv file</param>\r
+ /// <returns>True if successful </returns>\r
+ public static bool SaveChapterMarkersToCsv(frmMain mainWindow, string filePathName)\r
+ {\r
+ try\r
+ {\r
+ string csv = string.Empty;\r
+\r
+ foreach (DataGridViewRow row in mainWindow.data_chpt.Rows)\r
+ {\r
+ csv += row.Cells[0].Value.ToString();\r
+ csv += ",";\r
+ csv += row.Cells[1].Value.ToString().Replace(",", "\\,");\r
+ csv += Environment.NewLine;\r
+ }\r
+ StreamWriter file = new StreamWriter(filePathName);\r
+ file.Write(csv);\r
+ file.Close();\r
+ file.Dispose();\r
+ return true;\r
+ }\r
+ catch (Exception exc)\r
+ {\r
+ frmExceptionWindow exceptionWindow = new frmExceptionWindow();\r
+ exceptionWindow.Setup("Unable to save Chapter Makrers file! \nChapter marker names will NOT be saved in your encode", exc.ToString());\r
+ exceptionWindow.ShowDialog();\r
+ return false;\r
+ }\r
+ }\r
+\r
+ /// <summary>\r
/// Function which generates the filename and path automatically based on \r
/// the Source Name, DVD title and DVD Chapters\r
/// </summary>\r
// Get the Source Name \r
string sourceName = mainWindow.SourceName;\r
\r
+ // Remove any illeagal characters from the source name\r
+ foreach (char character in Path.GetInvalidFileNameChars())\r
+ {\r
+ if (autoNamePath != null)\r
+ {\r
+ sourceName = sourceName.Replace(character.ToString(), string.Empty);\r
+ }\r
+ }\r
+\r
if (Properties.Settings.Default.AutoNameRemoveUnderscore)\r
sourceName = sourceName.Replace("_", " ");\r
\r
else // Otherwise, use the path that is already there.\r
{\r
// Use the path and change the file extension to match the previous destination\r
- autoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text), destinationFilename);\r
+ autoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text),\r
+ destinationFilename);\r
\r
if (Path.HasExtension(mainWindow.text_destination.Text))\r
- autoNamePath = Path.ChangeExtension(autoNamePath, Path.GetExtension(mainWindow.text_destination.Text));\r
+ autoNamePath = Path.ChangeExtension(autoNamePath,\r
+ Path.GetExtension(mainWindow.text_destination.Text));\r
}\r
}\r
\r
}\r
catch (Exception e)\r
{\r
- MessageBox.Show("Unable to retrieve version information from the CLI. \nError:\n" + e);\r
+ frmExceptionWindow exceptionWindow = new frmExceptionWindow();\r
+ exceptionWindow.Setup("Unable to retrieve version information from the CLI.", e.ToString());\r
+ exceptionWindow.ShowDialog();\r
}\r
}\r
\r
MessageBox.Show(\r
"It appears you are trying to use a CLI executable that is too old for this version of the HandBrake GUI.\n" +\r
"Please update the HandBrakeCLI.exe to a newer build.\n\n" +\r
- "HandBrake Detected: " + Properties.Settings.Default.hb_version,\r
+ "HandBrake build Detected: " + Properties.Settings.Default.hb_version,\r
"Error",\r
MessageBoxButtons.OK,\r
MessageBoxIcon.Error);\r
\r
return sb.ToString().Trim();\r
}\r
+\r
+ /// <summary>\r
+ /// Show the Exception Window\r
+ /// </summary>\r
+ /// <param name="shortError">\r
+ /// The short error.\r
+ /// </param>\r
+ /// <param name="longError">\r
+ /// The long error.\r
+ /// </param>\r
+ public static void ShowExceptiowWindow(string shortError, string longError)\r
+ {\r
+ frmExceptionWindow exceptionWindow = new frmExceptionWindow();\r
+ exceptionWindow.Setup(shortError, longError);\r
+ exceptionWindow.Show();\r
+ }\r
}\r
}
\ No newline at end of file