OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 12 Jun 2009 14:19:19 +0000 (14:19 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Fri, 12 Jun 2009 14:19:19 +0000 (14:19 +0000)
- Move all DllImports into win32.cs

git-svn-id: svn://localhost/HandBrake/trunk@2523 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/EncodeQueue/Encode.cs
win/C#/EncodeQueue/QueueHandler.cs
win/C#/Functions/PresetLoader.cs
win/C#/Functions/QueryGenerator.cs
win/C#/Functions/Win32.cs
win/C#/frmActivityWindow.cs
win/C#/frmMain.Designer.cs
win/C#/frmMain.cs
win/C#/frmPreview.cs

index 77b2b29..22518bf 100644 (file)
@@ -8,19 +8,12 @@ using System;
 using System.Diagnostics;\r
 using System.Windows.Forms;\r
 using System.IO;\r
-using System.Runtime.InteropServices;\r
 using Handbrake.Functions;\r
 \r
 namespace Handbrake.EncodeQueue\r
 {\r
     public class Encode\r
     {\r
-        // DLL Imports\r
-        [DllImport("user32.dll")]\r
-        private static extern void LockWorkStation();\r
-        [DllImport("user32.dll")]\r
-        private static extern int ExitWindowsEx(int uFlags, int dwReason);\r
\r
         /// <summary>\r
         /// Execute a HandBrakeCLI process.\r
         /// </summary>\r
@@ -121,7 +114,7 @@ namespace Handbrake.EncodeQueue
                     Process.Start("Shutdown", "-s -t 60");\r
                     break;\r
                 case "Log Off":\r
-                    ExitWindowsEx(0, 0);\r
+                    Win32.ExitWindowsEx(0, 0);\r
                     break;\r
                 case "Suspend":\r
                     Application.SetSuspendState(PowerState.Suspend, true, true);\r
@@ -130,7 +123,7 @@ namespace Handbrake.EncodeQueue
                     Application.SetSuspendState(PowerState.Hibernate, true, true);\r
                     break;\r
                 case "Lock System":\r
-                    LockWorkStation();\r
+                    Win32.LockWorkStation();\r
                     break;\r
                 case "Quit HandBrake":\r
                     Application.Exit();\r
index f34de01..d16f10f 100644 (file)
@@ -10,7 +10,6 @@ using System.IO;
 using System.Windows.Forms;\r
 using System.Xml.Serialization;\r
 using System.Threading;\r
-using System.Diagnostics;\r
 \r
 namespace Handbrake.EncodeQueue\r
 {\r
index 7d5e479..44f9016 100644 (file)
@@ -100,7 +100,6 @@ namespace Handbrake.Functions
             mainWindow.pictureSettings.txt_parHeight.Text = presetQuery.pixelAspectHeight.ToString();\r
             mainWindow.pictureSettings.drop_modulus.SelectedItem = presetQuery.AnamorphicModulus;\r
 \r
-\r
             // Reset maxWidth and MaxHeight to 0\r
             mainWindow.pictureSettings.maxWidth = 0;\r
             mainWindow.pictureSettings.maxHeight = 0;\r
index 595c9c1..c90d7db 100644 (file)
@@ -5,7 +5,6 @@
           It may be used under the terms of the GNU General Public License. */\r
 \r
 using System;\r
-using System.Text;\r
 using System.Windows.Forms;\r
 using System.Globalization;\r
 using System.IO;\r
@@ -20,7 +19,7 @@ namespace Handbrake.Functions
         /// </summary>\r
         /// <param name="mainWindow"></param>\r
         /// <returns>The CLI String</returns>\r
-        public string GenerateTheQuery(frmMain mainWindow)\r
+        public string generateTheQuery(frmMain mainWindow)\r
         {\r
             // Source tab\r
             string query = "";\r
@@ -61,7 +60,7 @@ namespace Handbrake.Functions
         /// <param name="duration">Duration</param>\r
         /// <param name="preview">Start at preview</param>\r
         /// <returns>Returns a CLI query String.</returns>\r
-        public string GeneratePreviewQuery(frmMain mainWindow, string duration, string preview)\r
+        public string generatePreviewQuery(frmMain mainWindow, string duration, string preview)\r
         {\r
             int seconds;\r
             int.TryParse(duration, out seconds);\r
@@ -141,7 +140,7 @@ namespace Handbrake.Functions
             else\r
             {\r
                 if (mainWindow.pictureSettings.text_height.Text != "")\r
-                        query += " -Y " + mainWindow.pictureSettings.text_height.Text;\r
+                    query += " -Y " + mainWindow.pictureSettings.text_height.Text;\r
             }\r
 \r
             string cropTop = mainWindow.pictureSettings.crop_top.Text;\r
@@ -179,7 +178,7 @@ namespace Handbrake.Functions
                     if (mainWindow.pictureSettings.txt_parWidth.Text != "" && mainWindow.pictureSettings.txt_parHeight.Text != "")\r
                         query += " --pixel-aspect " + mainWindow.pictureSettings.txt_parWidth.Text + ":" + mainWindow.pictureSettings.txt_parHeight.Text + " ";\r
                     break;\r
-            }           \r
+            }\r
             #endregion\r
 \r
             #region Filters\r
@@ -227,7 +226,7 @@ namespace Handbrake.Functions
                 switch (mainWindow.drp_videoEncoder.Text)\r
                 {\r
                     case "MPEG-4 (FFmpeg)":\r
-                        value = 31 - (mainWindow.slider_videoQuality.Value -1);\r
+                        value = 31 - (mainWindow.slider_videoQuality.Value - 1);\r
                         query += " -q " + value.ToString(new CultureInfo("en-US"));\r
                         break;\r
                     case "H.264 (x264)":\r
@@ -245,8 +244,8 @@ namespace Handbrake.Functions
                         value = mainWindow.slider_videoQuality.Value;\r
                         query += " -q " + value.ToString(new CultureInfo("en-US"));\r
                         break;\r
-                } \r
-            }     \r
+                }\r
+            }\r
 \r
             if (mainWindow.check_2PassEncode.Checked)\r
                 query += " -2 ";\r
@@ -325,7 +324,7 @@ namespace Handbrake.Functions
             // Audio Codec (-E)\r
             foreach (String item in codecs)\r
             {\r
-                \r
+\r
                 if (firstLoop)\r
                 {\r
                     audioItems = item; firstLoop = false;\r
@@ -411,7 +410,7 @@ namespace Handbrake.Functions
 \r
             // Attach Source name and dvd title to the start of the chapters.csv filename.\r
             // This is for the queue. It allows different chapter name files for each title.\r
-            string[] destName =  mainWindow.text_destination.Text.Split('\\');\r
+            string[] destName = mainWindow.text_destination.Text.Split('\\');\r
             string dest_name = destName[destName.Length - 1];\r
             dest_name = dest_name.Replace("\"", "");\r
             dest_name = dest_name.Replace(".mp4", "").Replace(".m4v", "").Replace(".mkv", "");\r
@@ -424,8 +423,8 @@ namespace Handbrake.Functions
             {\r
                 if (dest_name.Trim() != String.Empty)\r
                 {\r
-                    string path = source_title != "Automatic" \r
-                                      ? Path.Combine(Path.GetTempPath(), dest_name + "-" + source_title + "-chapters.csv") \r
+                    string path = source_title != "Automatic"\r
+                                      ? Path.Combine(Path.GetTempPath(), dest_name + "-" + source_title + "-chapters.csv")\r
                                       : Path.Combine(Path.GetTempPath(), dest_name + "-chapters.csv");\r
 \r
                     if (chapterCSVSave(mainWindow, path) == false)\r
@@ -450,19 +449,13 @@ namespace Handbrake.Functions
 \r
             query += " -v " + Properties.Settings.Default.verboseLevel;\r
 \r
-            if (Properties.Settings.Default.dvdnav =="Checked")\r
+            if (Properties.Settings.Default.dvdnav == "Checked")\r
                 query += " --dvdnav";\r
             #endregion\r
 \r
             return query;\r
         }\r
 \r
-        /// <summary>\r
-        /// Get the CLI equive of the audio mixdown from the widget name.\r
-        /// </summary>\r
-        /// <param name="selectedAudio"></param>\r
-        /// <returns></returns>\r
-        /// \r
         private static string getMixDown(string selectedAudio)\r
         {\r
             switch (selectedAudio)\r
@@ -483,13 +476,6 @@ namespace Handbrake.Functions
                     return "auto";\r
             }\r
         }\r
-\r
-        /// <summary>\r
-        /// Get the CLI equiv of the audio encoder from the widget name.\r
-        /// </summary>\r
-        /// <param name="selectedEncoder"></param>\r
-        /// <returns></returns>\r
-        /// \r
         private static string getAudioEncoder(string selectedEncoder)\r
         {\r
             switch (selectedEncoder)\r
@@ -508,29 +494,21 @@ namespace Handbrake.Functions
                     return "";\r
             }\r
         }\r
-\r
-        /// <summary>\r
-        /// This function saves the data in the chapters tab, dataGridView into a CSV file called chapters.csv\r
-        /// in a directory specified by file_path_name\r
-        /// </summary>\r
-        /// <param name="mainWindow"></param>\r
-        /// <param name="file_path_name"></param>\r
-        /// <returns></returns>\r
-        private static Boolean chapterCSVSave(frmMain mainWindow, string file_path_name)\r
+        private static Boolean chapterCSVSave(frmMain mainWindow, string filePathName)\r
         {\r
             try\r
             {\r
-                StringBuilder csv = new StringBuilder();\r
+                string csv = "";\r
 \r
                 foreach (DataGridViewRow row in mainWindow.data_chpt.Rows)\r
                 {\r
-                    csv.Append(row.Cells[0].Value.ToString());\r
-                    csv.Append(",");\r
-                    csv.Append(row.Cells[1].Value.ToString());\r
-                    csv.Append(Environment.NewLine);\r
+                    csv += row.Cells[0].Value.ToString();\r
+                    csv += ",";\r
+                    csv += row.Cells[1].Value.ToString();\r
+                    csv += Environment.NewLine;\r
                 }\r
-                StreamWriter file = new StreamWriter(file_path_name);\r
-                file.Write(csv.ToString());\r
+                StreamWriter file = new StreamWriter(filePathName);\r
+                file.Write(csv);\r
                 file.Close();\r
                 file.Dispose();\r
                 return true;\r
index 2d067b4..2bc47e6 100644 (file)
@@ -1,4 +1,5 @@
-using System.Runtime.InteropServices;\r
+using System;\r
+using System.Runtime.InteropServices;\r
 \r
 namespace Handbrake.Functions\r
 {\r
@@ -6,5 +7,29 @@ namespace Handbrake.Functions
     {\r
         [DllImport("user32.dll")]\r
         public static extern int SetForegroundWindow(int hWnd);\r
+\r
+        [DllImport("user32.dll")]\r
+        public static extern void LockWorkStation();\r
+\r
+        [DllImport("user32.dll")]\r
+        public static extern int ExitWindowsEx(int uFlags, int dwReason);\r
+\r
+        public struct MEMORYSTATUS // Unused var's are requred here.\r
+        {\r
+            public UInt32 dwLength;\r
+            public UInt32 dwMemoryLoad;\r
+            public UInt32 dwTotalPhys; // Used\r
+            public UInt32 dwAvailPhys;\r
+            public UInt32 dwTotalPageFile;\r
+            public UInt32 dwAvailPageFile;\r
+            public UInt32 dwTotalVirtual;\r
+            public UInt32 dwAvailVirtual;\r
+        }\r
+\r
+        [DllImport("kernel32.dll")]\r
+        public static extern void GlobalMemoryStatus\r
+        (\r
+            ref MEMORYSTATUS lpBuffer\r
+        );\r
     }\r
 }\r
index 981ed2f..76364d7 100644 (file)
@@ -8,8 +8,8 @@ using System;
 using System.Windows.Forms;\r
 using System.IO;\r
 using System.Threading;\r
-using System.Runtime.InteropServices;\r
 using Handbrake.EncodeQueue;\r
+using Handbrake.Functions;\r
 using Microsoft.Win32;\r
 \r
 \r
@@ -304,23 +304,7 @@ namespace Handbrake
         #endregion\r
 \r
         #region System Information\r
-        private struct MEMORYSTATUS // Unused var's are requred here.\r
-        {\r
-            public UInt32 dwLength;\r
-            public UInt32 dwMemoryLoad;\r
-            public UInt32 dwTotalPhys; // Used\r
-            public UInt32 dwAvailPhys;\r
-            public UInt32 dwTotalPageFile;\r
-            public UInt32 dwAvailPageFile;\r
-            public UInt32 dwTotalVirtual;\r
-            public UInt32 dwAvailVirtual;\r
-        }\r
-\r
-        [DllImport("kernel32.dll")]\r
-        private static extern void GlobalMemoryStatus\r
-        (\r
-            ref MEMORYSTATUS lpBuffer\r
-        );\r
+        \r
 \r
         /// <summary>\r
         /// Returns the total physical ram in a system\r
@@ -328,8 +312,8 @@ namespace Handbrake
         /// <returns></returns>\r
         public uint TotalPhysicalMemory()\r
         {\r
-            MEMORYSTATUS memStatus = new MEMORYSTATUS();\r
-            GlobalMemoryStatus(ref memStatus);\r
+            Win32.MEMORYSTATUS memStatus = new Win32.MEMORYSTATUS();\r
+            Win32.GlobalMemoryStatus(ref memStatus);\r
 \r
             uint MemoryInfo = memStatus.dwTotalPhys;\r
             MemoryInfo = MemoryInfo / 1024 / 1024;\r
index 7411f23..912b49f 100644 (file)
@@ -941,6 +941,7 @@ namespace Handbrake
             this.audioPanel.Name = "audioPanel";\r
             this.audioPanel.Size = new System.Drawing.Size(715, 310);\r
             this.audioPanel.TabIndex = 0;\r
+\r
             // \r
             // AudioMenuRowHeightHack\r
             // \r
index 3f67f3b..33a177a 100644 (file)
@@ -301,7 +301,7 @@ namespace Handbrake
         }\r
         private void btn_new_preset_Click(object sender, EventArgs e)\r
         {\r
-            Form preset = new frmAddPreset(this, queryGen.GenerateTheQuery(this), presetHandler);\r
+            Form preset = new frmAddPreset(this, queryGen.generateTheQuery(this), presetHandler);\r
             preset.ShowDialog();\r
         }\r
         #endregion\r
@@ -549,7 +549,7 @@ namespace Handbrake
                     // This is used for tracking which file to load in the activity window\r
                     lastAction = "encode";\r
 \r
-                    String query = rtf_query.Text != "" ? rtf_query.Text : queryGen.GenerateTheQuery(this);\r
+                    String query = rtf_query.Text != "" ? rtf_query.Text : queryGen.generateTheQuery(this);\r
 \r
                     if (encodeQueue.count() == 0)\r
                     {\r
@@ -575,7 +575,7 @@ namespace Handbrake
                 MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
             else\r
             {\r
-                String query = queryGen.GenerateTheQuery(this);\r
+                String query = queryGen.generateTheQuery(this);\r
                 if (rtf_query.Text != "")\r
                     query = rtf_query.Text;\r
 \r
@@ -1235,7 +1235,7 @@ namespace Handbrake
         // Query Editor Tab\r
         private void btn_generate_Query_Click(object sender, EventArgs e)\r
         {\r
-            rtf_query.Text = queryGen.GenerateTheQuery(this);\r
+            rtf_query.Text = queryGen.generateTheQuery(this);\r
         }\r
         private void btn_clear_Click(object sender, EventArgs e)\r
         {\r
@@ -1613,6 +1613,8 @@ namespace Handbrake
         }\r
         #endregion\r
 \r
+\r
+\r
         // This is the END of the road ****************************************\r
     }\r
 }
\ No newline at end of file
index 7ea4727..f38ee5c 100644 (file)
@@ -4,7 +4,6 @@ using System.Threading;
 using System.Diagnostics;\r
 using System.Runtime.InteropServices;\r
 using System.IO;\r
-using AxQTOControlLib;\r
 using Handbrake.EncodeQueue;\r
 using Handbrake.Functions;\r
 using QTOControlLib;\r
@@ -32,7 +31,7 @@ namespace Handbrake
             }\r
             catch (Exception exc)\r
             {\r
-                MessageBox.Show(mw, "It would appear QuickTime 7 is not installed. QuickTime preview functionality will be disabled! \n\n Debug Info:\n" + exc, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+                MessageBox.Show(mw, "It would appear QuickTime 7 is not installed or not accessible. QuickTime preview functionality will be disabled! \n\n Debug Info:\n" + exc, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
                 btn_playQT.Enabled = false;\r
                 noQT = true;\r
             }\r
@@ -59,7 +58,7 @@ namespace Handbrake
             btn_playQT.Enabled = false;\r
             btn_playVLC.Enabled = false;\r
             lbl_status.Text = "Encoding Sample for (VLC) ...";\r
-            String query = hb_common_func.GeneratePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text);\r
+            String query = hb_common_func.generatePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text);\r
             ThreadPool.QueueUserWorkItem(procMonitor, query);\r
         }\r
         private void btn_playQT_Click(object sender, EventArgs e)\r
@@ -79,7 +78,7 @@ namespace Handbrake
             btn_playQT.Enabled = false;\r
             btn_playVLC.Enabled = false;\r
             lbl_status.Text = "Encoding Sample for (QT) ...";\r
-            String query = hb_common_func.GeneratePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text);\r
+            String query = hb_common_func.generatePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text);\r
             ThreadPool.QueueUserWorkItem(procMonitor, query);\r
         }\r
         private void procMonitor(object state)\r