]> granicus.if.org Git - handbrake/commitdiff
WinGui:
authorsr55 <sr55.hb@outlook.com>
Fri, 19 Dec 2008 13:57:08 +0000 (13:57 +0000)
committersr55 <sr55.hb@outlook.com>
Fri, 19 Dec 2008 13:57:08 +0000 (13:57 +0000)
- Fixes for a few rather stupid issues with the new queue/mainwindow encode link.
- Got rid of the queue encode progress bar. It's just a pain to keep it working and doesn't really offer much.

git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@2040 b64f7644-9d1e-0410-96f1-a4d463321fa5

win/C#/Properties/Settings.Designer.cs
win/C#/Properties/Settings.settings
win/C#/app.config
win/C#/frmMain.cs
win/C#/frmQueue.Designer.cs
win/C#/frmQueue.cs

index 429e3503c2cf230527120aed426d11f24ab9b1da..17391563f790f4af755a63e7e059f71e06453a1c 100644 (file)
@@ -301,7 +301,7 @@ namespace Handbrake.Properties {
         \r
         [global::System.Configuration.UserScopedSettingAttribute()]\r
         [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]\r
-        [global::System.Configuration.DefaultSettingValueAttribute("T:\\\\Program Files\\\\VideoLAN\\\\vlc\\\\vlc.exe")]\r
+        [global::System.Configuration.DefaultSettingValueAttribute("T:\\Program Files\\VideoLAN\\vlc\\vlc.exe")]\r
         public string VLC_Path {\r
             get {\r
                 return ((string)(this["VLC_Path"]));\r
index a652153066aaebb584538f98fc5876d273dcd365..42af2949d08aa89c07bf024ed0dacb067328d7c0 100644 (file)
@@ -72,7 +72,7 @@
       <Value Profile="(Default)" />\r
     </Setting>\r
     <Setting Name="VLC_Path" Type="System.String" Scope="User">\r
-      <Value Profile="(Default)">T:\\Program Files\\VideoLAN\\vlc\\vlc.exe</Value>\r
+      <Value Profile="(Default)">T:\Program Files\VideoLAN\vlc\vlc.exe</Value>\r
     </Setting>\r
     <Setting Name="MainWindowMinimize" Type="System.String" Scope="User">\r
       <Value Profile="(Default)">Checked</Value>\r
index f6a004dedfbcb9b148b24a2f4d47115b92eba262..dcaf46f718dfd6092d2531c01ff4812b781fe3ff 100644 (file)
@@ -77,7 +77,7 @@
                 <value />\r
             </setting>\r
             <setting name="VLC_Path" serializeAs="String">\r
-                <value>T:\\Program Files\\VideoLAN\\vlc\\vlc.exe</value>\r
+                <value>T:\Program Files\VideoLAN\vlc\vlc.exe</value>\r
             </setting>\r
             <setting name="MainWindowMinimize" serializeAs="String">\r
                 <value>Checked</value>\r
index d5b70e363948b80537c62e75aa8cb8ec371629dd..6f971eb99681d9d367165df72f14a18d7c798519 100644 (file)
@@ -47,73 +47,80 @@ namespace Handbrake
 \r
         public frmMain()\r
         {\r
-            // Load the splash screen in this thread\r
-            Form splash = new frmSplashScreen();\r
-            splash.Show();\r
-\r
-            //Create a label that can be updated from the parent thread.\r
-            Label lblStatus = new Label();\r
-            lblStatus.Size = new Size(250, 20);\r
-            lblStatus.Location = new Point(10, 280);\r
-            splash.Controls.Add(lblStatus);\r
-            InitializeComponent();\r
-\r
-            // Update the users config file with the CLI version data.\r
-            lblStatus.Text = "Setting Version Data ...";\r
-            Application.DoEvents();\r
-            ArrayList x = hb_common_func.getCliVersionData();\r
-            Properties.Settings.Default.hb_build = int.Parse(x[1].ToString());\r
-            Properties.Settings.Default.hb_version = x[0].ToString();\r
-\r
-            // show the form, but leave disabled until preloading is complete then show the main form\r
-            this.Enabled = false;\r
-            this.Show();\r
-            Application.DoEvents(); // Forces frmMain to draw\r
-\r
-            // update the status\r
-            if (Properties.Settings.Default.updateStatus == "Checked")\r
-            {\r
-                lblStatus.Text = "Checking for updates ...";\r
+            try\r
+            {\r
+                // Load the splash screen in this thread\r
+                Form splash = new frmSplashScreen();\r
+                splash.Show();\r
+\r
+                //Create a label that can be updated from the parent thread.\r
+                Label lblStatus = new Label();\r
+                lblStatus.Size = new Size(250, 20);\r
+                lblStatus.Location = new Point(10, 280);\r
+                splash.Controls.Add(lblStatus);\r
+                InitializeComponent();\r
+\r
+                // Update the users config file with the CLI version data.\r
+                lblStatus.Text = "Setting Version Data ...";\r
                 Application.DoEvents();\r
-                Thread updateCheckThread = new Thread(startupUpdateCheck);\r
-                updateCheckThread.Start();\r
-            }\r
+                ArrayList x = hb_common_func.getCliVersionData();\r
+                Properties.Settings.Default.hb_build = int.Parse(x[1].ToString());\r
+                Properties.Settings.Default.hb_version = x[0].ToString();\r
 \r
-            // Setup the GUI components\r
-            lblStatus.Text = "Setting up the GUI ...";\r
-            Application.DoEvents();\r
-            x264PanelFunctions.reset2Defaults(this); // Initialize all the x264 widgets to their default values\r
-            loadPresetPanel();                       // Load the Preset Panel\r
-            treeView_presets.ExpandAll();\r
-            lbl_encode.Text = "";\r
-            queueWindow = new frmQueue(this);        // Prepare the Queue\r
+                // show the form, but leave disabled until preloading is complete then show the main form\r
+                this.Enabled = false;\r
+                this.Show();\r
+                Application.DoEvents(); // Forces frmMain to draw\r
 \r
-            // Load the user's default settings or Normal Preset\r
-            if (Properties.Settings.Default.defaultSettings == "Checked" && Properties.Settings.Default.defaultUserSettings != "")\r
-            {\r
-                Functions.QueryParser presetQuery = Functions.QueryParser.Parse(Properties.Settings.Default.defaultUserSettings);\r
-                presetLoader.presetLoader(this, presetQuery, "User Defaults ");\r
-            }\r
-            else\r
-                loadNormalPreset();\r
+                // update the status\r
+                if (Properties.Settings.Default.updateStatus == "Checked")\r
+                {\r
+                    lblStatus.Text = "Checking for updates ...";\r
+                    Application.DoEvents();\r
+                    Thread updateCheckThread = new Thread(startupUpdateCheck);\r
+                    updateCheckThread.Start();\r
+                }\r
 \r
-            // Enabled GUI tooltip's if Required\r
-            if (Properties.Settings.Default.tooltipEnable == "Checked")\r
-                ToolTip.Active = true;\r
+                // Setup the GUI components\r
+                lblStatus.Text = "Setting up the GUI ...";\r
+                Application.DoEvents();\r
+                x264PanelFunctions.reset2Defaults(this); // Initialize all the x264 widgets to their default values\r
+                loadPresetPanel();                       // Load the Preset Panel\r
+                treeView_presets.ExpandAll();\r
+                lbl_encode.Text = "";\r
+                queueWindow = new frmQueue(this);        // Prepare the Queue\r
 \r
-            //Finished Loading\r
-            lblStatus.Text = "Loading Complete!";\r
-            Application.DoEvents();\r
-            splash.Close();\r
-            splash.Dispose();\r
-            this.Enabled = true;\r
+                // Load the user's default settings or Normal Preset\r
+                if (Properties.Settings.Default.defaultSettings == "Checked" && Properties.Settings.Default.defaultUserSettings != "")\r
+                {\r
+                    Functions.QueryParser presetQuery = Functions.QueryParser.Parse(Properties.Settings.Default.defaultUserSettings);\r
+                    presetLoader.presetLoader(this, presetQuery, "User Defaults ");\r
+                }\r
+                else\r
+                    loadNormalPreset();\r
 \r
-            // Event Handlers\r
-            if (Properties.Settings.Default.MainWindowMinimize == "Checked")\r
-                this.Resize += new EventHandler(frmMain_Resize);\r
+                // Enabled GUI tooltip's if Required\r
+                if (Properties.Settings.Default.tooltipEnable == "Checked")\r
+                    ToolTip.Active = true;\r
 \r
-            // Queue Recovery\r
-            queueRecovery();\r
+                //Finished Loading\r
+                lblStatus.Text = "Loading Complete!";\r
+                Application.DoEvents();\r
+                splash.Close();\r
+                splash.Dispose();\r
+                this.Enabled = true;\r
+\r
+                // Event Handlers\r
+                if (Properties.Settings.Default.MainWindowMinimize == "Checked")\r
+                    this.Resize += new EventHandler(frmMain_Resize);\r
+\r
+                // Queue Recovery\r
+                queueRecovery();\r
+            }\r
+            catch (Exception e)\r
+            {\r
+                MessageBox.Show("Error at startup: \n\n" + e);\r
+            }\r
         }\r
 \r
         // Startup Functions\r
@@ -457,30 +464,47 @@ namespace Handbrake
         }\r
         private void btn_start_Click(object sender, EventArgs e)\r
         {\r
-            if (text_source.Text == string.Empty || text_source.Text == "Click 'Source' to continue" || text_destination.Text == string.Empty)\r
-                MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
+            if (btn_start.Text == "Stop")\r
+            {\r
+                DialogResult result = MessageBox.Show("Are you sure you wish to cancel the encode? Please note that this may break the encoded file. \nTo safely cancel your encode, press ctrl-c on your keyboard in the CLI window. This *may* allow you to preview your encoded content.", "Cancel Encode?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);\r
+\r
+                if (result == DialogResult.Yes)\r
+                {\r
+                    queueWindow.frmMain_cancelEncode();\r
+                    if (!queueWindow.isEncoding())\r
+                        setEncodeStatus(0);\r
+                }\r
+            }\r
             else\r
             {\r
-                // Set the last action to encode. \r
-                // This is used for tracking which file to load in the activity window\r
-                lastAction = "encode";\r
+                if (encodeQueue.count() != 0 || (text_source.Text != string.Empty && text_source.Text != "Click 'Source' to continue" && text_destination.Text != string.Empty))\r
+                {\r
+                    // Set the last action to encode. \r
+                    // This is used for tracking which file to load in the activity window\r
+                    lastAction = "encode";\r
 \r
-                String query;\r
-                if (rtf_query.Text != "")\r
-                    query = rtf_query.Text;\r
-                else\r
-                    query = queryGen.GenerateTheQuery(this);\r
+                    String query;\r
+                    if (rtf_query.Text != "")\r
+                        query = rtf_query.Text;\r
+                    else\r
+                        query = queryGen.GenerateTheQuery(this);\r
 \r
-                if (encodeQueue.count() == 0)\r
-                {\r
-                    encodeQueue.add(query, text_source.Text, text_destination.Text);\r
-                    encodeQueue.write2disk("hb_queue_recovery.xml");\r
+                    if (encodeQueue.count() == 0)\r
+                    {\r
+                        encodeQueue.add(query, text_source.Text, text_destination.Text);\r
+                        encodeQueue.write2disk("hb_queue_recovery.xml");\r
+                    }\r
+                    queueWindow.setQueue(encodeQueue);\r
+                    if (encodeQueue.count() > 1)\r
+                        queueWindow.Show();\r
+\r
+                    queueWindow.frmMain_encode();\r
+\r
+                    setEncodeStatus(1); // Encode is running, so setup the GUI appropriately\r
                 }\r
-                queueWindow.setQueue(encodeQueue);\r
-                queueWindow.Show();\r
-                queueWindow.frmMain_encode();\r
+                else if (text_source.Text == string.Empty || text_source.Text == "Click 'Source' to continue" || text_destination.Text == string.Empty)\r
+                    MessageBox.Show("No source OR destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
 \r
-                setEncodeStatus(1); // Encode is running, so setup the GUI appropriately\r
             }\r
         }\r
         private void btn_add2Queue_Click(object sender, EventArgs e)\r
@@ -1962,9 +1986,6 @@ namespace Handbrake
 \r
         #endregion\r
 \r
-\r
-\r
-\r
         // This is the END of the road ------------------------------------------------------------------------------\r
     }\r
 }
\ No newline at end of file
index bb0635c7a56aa826e84ac2d15c4813fc95fc23eb..0682c3c852797b2175821f14e838f856f8b5baae 100644 (file)
@@ -67,9 +67,6 @@ namespace Handbrake
             this.Audio = new System.Windows.Forms.ColumnHeader();\r
             this.statusStrip1 = new System.Windows.Forms.StatusStrip();\r
             this.lbl_encodesPending = new System.Windows.Forms.ToolStripStatusLabel();\r
-            this.toolStripStatusLabel1 = new System.Windows.Forms.ToolStripStatusLabel();\r
-            this.progressBar = new System.Windows.Forms.ToolStripProgressBar();\r
-            this.lbl_progressValue = new System.Windows.Forms.ToolStripStatusLabel();\r
             this.OpenFile = new System.Windows.Forms.OpenFileDialog();\r
             this.splitContainer1 = new System.Windows.Forms.SplitContainer();\r
             this.panel3 = new System.Windows.Forms.Panel();\r
@@ -316,7 +313,7 @@ namespace Handbrake
             this.list_queue.Location = new System.Drawing.Point(15, 0);\r
             this.list_queue.MultiSelect = false;\r
             this.list_queue.Name = "list_queue";\r
-            this.list_queue.Size = new System.Drawing.Size(749, 210);\r
+            this.list_queue.Size = new System.Drawing.Size(749, 219);\r
             this.list_queue.TabIndex = 72;\r
             this.list_queue.UseCompatibleStateImageBehavior = false;\r
             this.list_queue.View = System.Windows.Forms.View.Details;\r
@@ -355,13 +352,10 @@ namespace Handbrake
             // statusStrip1\r
             // \r
             this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
-            this.lbl_encodesPending,\r
-            this.toolStripStatusLabel1,\r
-            this.progressBar,\r
-            this.lbl_progressValue});\r
-            this.statusStrip1.Location = new System.Drawing.Point(0, 359);\r
+            this.lbl_encodesPending});\r
+            this.statusStrip1.Location = new System.Drawing.Point(0, 368);\r
             this.statusStrip1.Name = "statusStrip1";\r
-            this.statusStrip1.Size = new System.Drawing.Size(779, 31);\r
+            this.statusStrip1.Size = new System.Drawing.Size(779, 22);\r
             this.statusStrip1.TabIndex = 73;\r
             this.statusStrip1.Text = "statusStrip1";\r
             // \r
@@ -370,28 +364,9 @@ namespace Handbrake
             this.lbl_encodesPending.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;\r
             this.lbl_encodesPending.Margin = new System.Windows.Forms.Padding(0, 3, 10, 2);\r
             this.lbl_encodesPending.Name = "lbl_encodesPending";\r
-            this.lbl_encodesPending.Size = new System.Drawing.Size(122, 26);\r
+            this.lbl_encodesPending.Size = new System.Drawing.Size(122, 17);\r
             this.lbl_encodesPending.Text = "0 encode(s) pending";\r
             // \r
-            // toolStripStatusLabel1\r
-            // \r
-            this.toolStripStatusLabel1.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Text;\r
-            this.toolStripStatusLabel1.Name = "toolStripStatusLabel1";\r
-            this.toolStripStatusLabel1.Size = new System.Drawing.Size(57, 26);\r
-            this.toolStripStatusLabel1.Text = "Progress:";\r
-            // \r
-            // progressBar\r
-            // \r
-            this.progressBar.Name = "progressBar";\r
-            this.progressBar.Size = new System.Drawing.Size(500, 25);\r
-            this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;\r
-            // \r
-            // lbl_progressValue\r
-            // \r
-            this.lbl_progressValue.Name = "lbl_progressValue";\r
-            this.lbl_progressValue.Size = new System.Drawing.Size(34, 26);\r
-            this.lbl_progressValue.Text = " 0 %";\r
-            // \r
             // OpenFile\r
             // \r
             this.OpenFile.Filter = "HandBrake Queue|*.queue";\r
@@ -426,7 +401,7 @@ namespace Handbrake
             this.splitContainer1.Panel2.Controls.Add(this.panel3);\r
             this.splitContainer1.Panel2.Controls.Add(this.panel2);\r
             this.splitContainer1.Panel2.Controls.Add(this.panel1);\r
-            this.splitContainer1.Size = new System.Drawing.Size(779, 320);\r
+            this.splitContainer1.Size = new System.Drawing.Size(779, 329);\r
             this.splitContainer1.SplitterDistance = 94;\r
             this.splitContainer1.SplitterWidth = 1;\r
             this.splitContainer1.TabIndex = 74;\r
@@ -434,7 +409,7 @@ namespace Handbrake
             // panel3\r
             // \r
             this.panel3.Dock = System.Windows.Forms.DockStyle.Bottom;\r
-            this.panel3.Location = new System.Drawing.Point(15, 210);\r
+            this.panel3.Location = new System.Drawing.Point(15, 219);\r
             this.panel3.Name = "panel3";\r
             this.panel3.Size = new System.Drawing.Size(749, 15);\r
             this.panel3.TabIndex = 77;\r
@@ -444,7 +419,7 @@ namespace Handbrake
             this.panel2.Dock = System.Windows.Forms.DockStyle.Right;\r
             this.panel2.Location = new System.Drawing.Point(764, 0);\r
             this.panel2.Name = "panel2";\r
-            this.panel2.Size = new System.Drawing.Size(15, 225);\r
+            this.panel2.Size = new System.Drawing.Size(15, 234);\r
             this.panel2.TabIndex = 76;\r
             // \r
             // panel1\r
@@ -452,7 +427,7 @@ namespace Handbrake
             this.panel1.Dock = System.Windows.Forms.DockStyle.Left;\r
             this.panel1.Location = new System.Drawing.Point(0, 0);\r
             this.panel1.Name = "panel1";\r
-            this.panel1.Size = new System.Drawing.Size(15, 225);\r
+            this.panel1.Size = new System.Drawing.Size(15, 234);\r
             this.panel1.TabIndex = 75;\r
             // \r
             // frmQueue\r
@@ -510,9 +485,6 @@ namespace Handbrake
         private System.Windows.Forms.ColumnHeader EncoderVideo;\r
         private System.Windows.Forms.ColumnHeader Audio;\r
         private System.Windows.Forms.StatusStrip statusStrip1;\r
-        private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel1;\r
-        private System.Windows.Forms.ToolStripProgressBar progressBar;\r
-        private System.Windows.Forms.ToolStripStatusLabel lbl_progressValue;\r
         private System.Windows.Forms.ToolStripDropDownButton drop_button_queue;\r
         private System.Windows.Forms.ToolStripMenuItem mnu_batch;\r
         private System.Windows.Forms.ToolStripMenuItem mnu_import;\r
index 648deef8972abd39a064c70a560c0b31c6bf12ce..ed1eb5a9be828d5884d10942ac343b937ae463be 100644 (file)
@@ -44,18 +44,6 @@ namespace Handbrake
             queue = qw;\r
             redrawQueue();\r
             lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";\r
-\r
-            // Recalculate the progress bar, but only if the queue has already started.       \r
-            if (progressBar.Value != 0)\r
-            {\r
-                progressBar.Value = 0;\r
-                if (queue.count() == 0)\r
-                    progressBar.Step = 100;\r
-                else\r
-                    progressBar.Step = 100 / queue.count();\r
-                progressBar.PerformStep();\r
-                lbl_progressValue.Text = string.Format("{0} %", progressBar.Value);\r
-            }\r
         }\r
 \r
         /// <summary>\r
@@ -84,12 +72,7 @@ namespace Handbrake
                     // Setup or reset some values\r
                     btn_encode.Enabled = false;\r
                     btn_stop.Visible = true;\r
-                    progressBar.Value = 0;\r
-                    lbl_progressValue.Text = "0 %";\r
-                    if (queue.count() == 0)\r
-                        progressBar.Step = 100;\r
-                    else\r
-                        progressBar.Step = 100 / queue.count();\r
+\r
                     Thread theQ = new Thread(startProc);\r
                     theQ.IsBackground = true;\r
                     theQ.Start();\r
@@ -101,6 +84,17 @@ namespace Handbrake
             }\r
         }\r
 \r
+        public void frmMain_cancelEncode()\r
+        {\r
+            Process[] aProc = Process.GetProcessesByName("HandBrakeCLI");\r
+            Process HandBrakeCLI;\r
+            if (aProc.Length > 0)\r
+            {\r
+                HandBrakeCLI = aProc[0];\r
+                HandBrakeCLI.Kill();\r
+            }\r
+        }\r
+\r
         // Redraw's the queue with the latest data from the Queue class\r
         private void redrawQueue()\r
         {\r
@@ -158,12 +152,7 @@ namespace Handbrake
                     // Setup or reset some values\r
                     btn_encode.Enabled = false;\r
                     btn_stop.Visible = true;\r
-                    progressBar.Value = 0;\r
-                    lbl_progressValue.Text = "0 %";\r
-                    if (queue.count() == 0)\r
-                        progressBar.Step = 100;\r
-                    else\r
-                        progressBar.Step = 100 / queue.count();\r
+\r
                     Thread theQ = new Thread(startProc);\r
                     theQ.IsBackground = true;\r
                     theQ.Start();\r
@@ -233,17 +222,6 @@ namespace Handbrake
                 btn_stop.Visible = false;\r
                 btn_encode.Enabled = true;\r
 \r
-                if (cancel == true)\r
-                {\r
-                    lbl_progressValue.Text = "Encode Queue Cancelled!";\r
-                }\r
-                else\r
-                {\r
-                    lbl_progressValue.Text = "Encode Queue Completed!";\r
-                }\r
-\r
-                progressBar.Value = 0;\r
-\r
                 lbl_source.Text = "-";\r
                 lbl_dest.Text = "-";\r
                 lbl_vEnc.Text = "-";\r
@@ -280,9 +258,6 @@ namespace Handbrake
                 }\r
 \r
                 redrawQueue();\r
-\r
-                progressBar.PerformStep();\r
-                lbl_progressValue.Text = string.Format("{0} %", progressBar.Value);\r
                 lbl_encodesPending.Text = list_queue.Items.Count + " encode(s) pending";\r
             }\r
             catch (Exception exc)\r