OSDN Git Service

WinGui:
authorsr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 12 Apr 2009 20:10:47 +0000 (20:10 +0000)
committersr55 <sr55@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 12 Apr 2009 20:10:47 +0000 (20:10 +0000)
- Improvements to the preview window design.
- Code tweaks to make it less crash / error prone (QT Control)

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

win/C#/HandBrakeCS.csproj
win/C#/Properties/Resources.Designer.cs
win/C#/Properties/Resources.resx
win/C#/Resources/Play_small.png [new file with mode: 0644]
win/C#/frmPreview.Designer.cs
win/C#/frmPreview.cs
win/C#/frmPreview.resx

index 7542e60..f892112 100644 (file)
     <None Include="Resources\Pause.png" />\r
     <None Include="Resources\Play.png" />\r
     <None Include="Resources\picture.png" />\r
+    <None Include="Resources\Play_small.png" />\r
     <Content Include="Resources\Pref_Small.png" />\r
     <Content Include="Resources\Queue.png" />\r
     <Content Include="Resources\Queue_Small.png" />\r
index 70b73b7..36b3388 100644 (file)
@@ -200,6 +200,13 @@ namespace Handbrake.Properties {
             }\r
         }\r
         \r
+        internal static System.Drawing.Bitmap Play_small {\r
+            get {\r
+                object obj = ResourceManager.GetObject("Play_small", resourceCulture);\r
+                return ((System.Drawing.Bitmap)(obj));\r
+            }\r
+        }\r
+        \r
         internal static System.Drawing.Bitmap Pref_Small {\r
             get {\r
                 object obj = ResourceManager.GetObject("Pref_Small", resourceCulture);\r
index 7807b0e..d5524c8 100644 (file)
   <data name="AddToQueue_small" type="System.Resources.ResXFileRef, System.Windows.Forms">\r
     <value>..\Resources\AddToQueue_small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>\r
   </data>\r
+  <data name="Play_small" type="System.Resources.ResXFileRef, System.Windows.Forms">\r
+    <value>..\Resources\Play_small.png;System.Drawing.Bitmap, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>\r
+  </data>\r
 </root>
\ No newline at end of file
diff --git a/win/C#/Resources/Play_small.png b/win/C#/Resources/Play_small.png
new file mode 100644 (file)
index 0000000..3e4647a
Binary files /dev/null and b/win/C#/Resources/Play_small.png differ
index 0beebf6..464ac25 100644 (file)
             this.cb_duration = new System.Windows.Forms.ToolStripComboBox();\r
             this.btn_playQT = new System.Windows.Forms.ToolStripButton();\r
             this.btn_playVLC = new System.Windows.Forms.ToolStripButton();\r
-            this.statusStrip = new System.Windows.Forms.StatusStrip();\r
-            this.lbl_status = new System.Windows.Forms.ToolStripStatusLabel();\r
             this.QTControl = new AxQTOControlLib.AxQTControl();\r
+            this.panel1 = new System.Windows.Forms.Panel();\r
+            this.lbl_status = new System.Windows.Forms.Label();\r
             this.toolBar.SuspendLayout();\r
-            this.statusStrip.SuspendLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.QTControl)).BeginInit();\r
+            this.panel1.SuspendLayout();\r
             this.SuspendLayout();\r
             // \r
             // toolBar\r
@@ -60,7 +60,7 @@
             this.toolBar.Location = new System.Drawing.Point(0, 0);\r
             this.toolBar.Name = "toolBar";\r
             this.toolBar.RenderMode = System.Windows.Forms.ToolStripRenderMode.System;\r
-            this.toolBar.Size = new System.Drawing.Size(774, 39);\r
+            this.toolBar.Size = new System.Drawing.Size(774, 25);\r
             this.toolBar.TabIndex = 37;\r
             this.toolBar.Text = "toolStrip1";\r
             // \r
@@ -68,7 +68,7 @@
             // \r
             this.lbl_preview.BackColor = System.Drawing.Color.Transparent;\r
             this.lbl_preview.Name = "lbl_preview";\r
-            this.lbl_preview.Size = new System.Drawing.Size(100, 36);\r
+            this.lbl_preview.Size = new System.Drawing.Size(100, 22);\r
             this.lbl_preview.Text = "Start at Preview:";\r
             // \r
             // cb_preview\r
             "9",\r
             "10"});\r
             this.cb_preview.Name = "cb_preview";\r
-            this.cb_preview.Size = new System.Drawing.Size(75, 39);\r
+            this.cb_preview.Size = new System.Drawing.Size(75, 25);\r
             // \r
             // toolStripLabel2\r
             // \r
             this.toolStripLabel2.BackColor = System.Drawing.Color.Transparent;\r
             this.toolStripLabel2.Name = "toolStripLabel2";\r
-            this.toolStripLabel2.Size = new System.Drawing.Size(111, 36);\r
+            this.toolStripLabel2.Size = new System.Drawing.Size(111, 22);\r
             this.toolStripLabel2.Text = "Duration (seconds)";\r
             // \r
             // cb_duration\r
             "60"});\r
             this.cb_duration.Margin = new System.Windows.Forms.Padding(0);\r
             this.cb_duration.Name = "cb_duration";\r
-            this.cb_duration.Size = new System.Drawing.Size(75, 39);\r
+            this.cb_duration.Size = new System.Drawing.Size(75, 25);\r
             // \r
             // btn_playQT\r
             // \r
-            this.btn_playQT.Image = global::Handbrake.Properties.Resources.Play;\r
+            this.btn_playQT.Image = global::Handbrake.Properties.Resources.Play_small;\r
             this.btn_playQT.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
             this.btn_playQT.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.btn_playQT.Name = "btn_playQT";\r
-            this.btn_playQT.Size = new System.Drawing.Size(113, 36);\r
+            this.btn_playQT.Size = new System.Drawing.Size(99, 22);\r
             this.btn_playQT.Text = "Play with QT";\r
             this.btn_playQT.Click += new System.EventHandler(this.btn_playQT_Click);\r
             // \r
             // btn_playVLC\r
             // \r
-            this.btn_playVLC.Image = global::Handbrake.Properties.Resources.Play;\r
+            this.btn_playVLC.Image = global::Handbrake.Properties.Resources.Play_small;\r
             this.btn_playVLC.ImageScaling = System.Windows.Forms.ToolStripItemImageScaling.None;\r
             this.btn_playVLC.ImageTransparentColor = System.Drawing.Color.Magenta;\r
             this.btn_playVLC.Name = "btn_playVLC";\r
-            this.btn_playVLC.Size = new System.Drawing.Size(117, 36);\r
+            this.btn_playVLC.Size = new System.Drawing.Size(103, 22);\r
             this.btn_playVLC.Text = "Play with VLC";\r
             this.btn_playVLC.Click += new System.EventHandler(this.btn_playVLC_Click);\r
             // \r
-            // statusStrip\r
-            // \r
-            this.statusStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {\r
-            this.lbl_status});\r
-            this.statusStrip.Location = new System.Drawing.Point(0, 486);\r
-            this.statusStrip.Name = "statusStrip";\r
-            this.statusStrip.Size = new System.Drawing.Size(774, 22);\r
-            this.statusStrip.TabIndex = 38;\r
-            this.statusStrip.Text = "statusStrip1";\r
-            // \r
-            // lbl_status\r
-            // \r
-            this.lbl_status.BackColor = System.Drawing.Color.Transparent;\r
-            this.lbl_status.Font = new System.Drawing.Font("Verdana", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
-            this.lbl_status.Name = "lbl_status";\r
-            this.lbl_status.Size = new System.Drawing.Size(31, 17);\r
-            this.lbl_status.Text = "{0}";\r
-            // \r
             // QTControl\r
             // \r
             this.QTControl.Enabled = true;\r
-            this.QTControl.Location = new System.Drawing.Point(0, 42);\r
+            this.QTControl.Location = new System.Drawing.Point(0, 0);\r
             this.QTControl.Name = "QTControl";\r
             this.QTControl.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("QTControl.OcxState")));\r
-            this.QTControl.Size = new System.Drawing.Size(64, 64);\r
+            this.QTControl.Size = new System.Drawing.Size(64, 72);\r
             this.QTControl.TabIndex = 39;\r
             this.QTControl.Visible = false;\r
             // \r
+            // panel1\r
+            // \r
+            this.panel1.Controls.Add(this.lbl_status);\r
+            this.panel1.Controls.Add(this.QTControl);\r
+            this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;\r
+            this.panel1.Location = new System.Drawing.Point(0, 25);\r
+            this.panel1.Name = "panel1";\r
+            this.panel1.Size = new System.Drawing.Size(774, 483);\r
+            this.panel1.TabIndex = 40;\r
+            // \r
+            // lbl_status\r
+            // \r
+            this.lbl_status.AutoSize = true;\r
+            this.lbl_status.BackColor = System.Drawing.Color.Transparent;\r
+            this.lbl_status.Dock = System.Windows.Forms.DockStyle.Top;\r
+            this.lbl_status.Font = new System.Drawing.Font("Tahoma", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));\r
+            this.lbl_status.ForeColor = System.Drawing.Color.White;\r
+            this.lbl_status.Location = new System.Drawing.Point(0, 0);\r
+            this.lbl_status.Name = "lbl_status";\r
+            this.lbl_status.Size = new System.Drawing.Size(51, 25);\r
+            this.lbl_status.TabIndex = 40;\r
+            this.lbl_status.Text = "{0}";\r
+            this.lbl_status.Visible = false;\r
+            // \r
             // frmPreview\r
             // \r
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);\r
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;\r
             this.BackColor = System.Drawing.Color.Black;\r
             this.ClientSize = new System.Drawing.Size(774, 508);\r
-            this.Controls.Add(this.QTControl);\r
-            this.Controls.Add(this.statusStrip);\r
+            this.Controls.Add(this.panel1);\r
             this.Controls.Add(this.toolBar);\r
             this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));\r
             this.Name = "frmPreview";\r
             this.TopMost = true;\r
             this.toolBar.ResumeLayout(false);\r
             this.toolBar.PerformLayout();\r
-            this.statusStrip.ResumeLayout(false);\r
-            this.statusStrip.PerformLayout();\r
             ((System.ComponentModel.ISupportInitialize)(this.QTControl)).EndInit();\r
+            this.panel1.ResumeLayout(false);\r
+            this.panel1.PerformLayout();\r
             this.ResumeLayout(false);\r
             this.PerformLayout();\r
 \r
 \r
         private System.Windows.Forms.ToolStrip toolBar;\r
         private System.Windows.Forms.ToolStripButton btn_playQT;\r
-        private System.Windows.Forms.StatusStrip statusStrip;\r
         private AxQTOControlLib.AxQTControl QTControl;\r
         private System.Windows.Forms.ToolStripComboBox cb_preview;\r
         private System.Windows.Forms.ToolStripLabel lbl_preview;\r
         private System.Windows.Forms.ToolStripLabel toolStripLabel2;\r
         private System.Windows.Forms.ToolStripComboBox cb_duration;\r
-        private System.Windows.Forms.ToolStripStatusLabel lbl_status;\r
         private System.Windows.Forms.ToolStripButton btn_playVLC;\r
+        private System.Windows.Forms.Panel panel1;\r
+        private System.Windows.Forms.Label lbl_status;\r
     }\r
 }
\ No newline at end of file
index e5ebd21..4591b3d 100644 (file)
@@ -4,6 +4,8 @@ using System.Threading;
 using System.Diagnostics;\r
 using System.Runtime.InteropServices;\r
 using System.IO;\r
+using AxQTOControlLib;\r
+using QTOControlLib;\r
 using QTOLibrary;\r
 \r
 namespace Handbrake\r
@@ -36,18 +38,42 @@ namespace Handbrake
             cb_preview.SelectedIndex = 0;\r
             cb_duration.SelectedIndex = 1;\r
         }\r
\r
+\r
         #region Encode Sample\r
         private void btn_playVLC_Click(object sender, EventArgs e)\r
         {\r
+            lbl_status.Visible = true;\r
+            try\r
+            {\r
+                QTControl.URL = "";\r
+                if (File.Exists(currently_playing))\r
+                    File.Delete(currently_playing);\r
+            }\r
+            catch (Exception)\r
+            {\r
+                MessageBox.Show(this, "Unable to delete previous preview file. You may need to restart the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+            }\r
+\r
             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
-            ThreadPool.QueueUserWorkItem(procMonitor, query);  \r
+            ThreadPool.QueueUserWorkItem(procMonitor, query);\r
         }\r
         private void btn_playQT_Click(object sender, EventArgs e)\r
         {\r
+            lbl_status.Visible = true;\r
+            try\r
+            {\r
+                QTControl.URL = "";\r
+                if (File.Exists(currently_playing))\r
+                    File.Delete(currently_playing);\r
+            }\r
+            catch (Exception)\r
+            {\r
+                MessageBox.Show(this, "Unable to delete previous preview file. You may need to restart the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+            }\r
+\r
             btn_playQT.Enabled = false;\r
             btn_playVLC.Enabled = false;\r
             lbl_status.Text = "Encoding Sample for (QT) ...";\r
@@ -92,9 +118,9 @@ namespace Handbrake
                 // Play back in QT or VLC\r
                 if (playerSelection == "QT")\r
                     play();\r
-                else \r
+                else\r
                     playVLC();\r
-                \r
+\r
                 lbl_status.Text = "";\r
             }\r
             catch (Exception exc)\r
@@ -113,6 +139,7 @@ namespace Handbrake
         {\r
             player = new Thread(OpenMovie) { IsBackground = true };\r
             player.Start();\r
+            lbl_status.Visible = false;\r
         }\r
 \r
         /// <summary>\r
@@ -138,6 +165,7 @@ namespace Handbrake
                 else\r
                     MessageBox.Show(this, "Unable to find the preview file. Either the file was deleted or the encode failed. Check the activity log for details.", "VLC", MessageBoxButtons.OK, MessageBoxIcon.Warning);\r
             }\r
+            lbl_status.Visible = false;\r
         }\r
 \r
         /// <summary>\r
@@ -153,18 +181,13 @@ namespace Handbrake
                     BeginInvoke(new UpdateUIHandler(OpenMovie));\r
                     return;\r
                 }\r
+                QTControl.Sizing = QTSizingModeEnum.qtControlFitsMovie;\r
                 QTControl.URL = currently_playing;\r
-                QTControl.Width = QTControl.Movie.Width;\r
-                QTControl.Height = QTControl.Movie.Height;\r
-                // The initial control size is 64,64. If we do not reload the clip here\r
-                // it'll scale the video from 64,64. \r
-                // Unsure why as it correctly resizes the control to the movies actual size.\r
-                QTControl.URL = currently_playing;\r
-                QTControl.SetScale(0);\r
+                QTControl.Sizing = QTSizingModeEnum.qtMovieFitsControl;\r
                 QTControl.Show();\r
 \r
-                this.Width = QTControl.Width + 5;\r
-                this.Height = QTControl.Height + 90;\r
+                this.ClientSize = QTControl.Size;\r
+                this.Height += 25;\r
             }\r
             catch (COMException ex)\r
             {\r
index 0db6e01..ef2d4bc 100644 (file)
   <metadata name="toolBar.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
     <value>17, 17</value>\r
   </metadata>\r
-  <metadata name="statusStrip.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">\r
-    <value>116, 17</value>\r
-  </metadata>\r
   <data name="QTControl.OcxState" mimetype="application/x-microsoft.net.object.binary.base64">\r
     <value>\r
         AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w\r