OSDN Git Service

LinGui: make Help->Guide work on windows/mingw
[handbrake-jp/handbrake-jp-git.git] / win / C# / Functions / Main.cs
index 80d806b..d7380b2 100644 (file)
@@ -136,6 +136,40 @@ namespace Handbrake.Functions
         }\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
@@ -296,7 +330,9 @@ namespace Handbrake.Functions
             }\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
@@ -779,5 +815,21 @@ namespace Handbrake.Functions
 \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