From 2ed63a9cb194d041dc7af94caa221162a7de60dd Mon Sep 17 00:00:00 2001 From: sr55 Date: Sat, 11 Sep 2010 14:23:01 +0000 Subject: [PATCH] WinGui: - Some fixes and improvements to the preview window. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3512 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/frmPreview.Designer.cs | 60 ++++++++++++++++-------------- win/C#/frmPreview.cs | 70 ++++++++++++++++++++--------------- win/C#/frmPreview.resx | 2 +- 3 files changed, 75 insertions(+), 57 deletions(-) diff --git a/win/C#/frmPreview.Designer.cs b/win/C#/frmPreview.Designer.cs index d37a8f53e..729e65b2b 100644 --- a/win/C#/frmPreview.Designer.cs +++ b/win/C#/frmPreview.Designer.cs @@ -39,18 +39,19 @@ this.cb_duration = new System.Windows.Forms.ToolStripComboBox(); this.btn_playQT = new System.Windows.Forms.ToolStripButton(); this.btn_playVLC = new System.Windows.Forms.ToolStripButton(); - this.QTControl = new AxQTOControlLib.AxQTControl(); - this.panel1 = new System.Windows.Forms.Panel(); this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator(); this.ProgressBarStatus = new System.Windows.Forms.ToolStripProgressBar(); this.lbl_encodeStatus = new System.Windows.Forms.ToolStripLabel(); + this.panel1 = new System.Windows.Forms.Panel(); + this.QTControl = new AxQTOControlLib.AxQTControl(); this.toolBar.SuspendLayout(); - ((System.ComponentModel.ISupportInitialize)(this.QTControl)).BeginInit(); this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.QTControl)).BeginInit(); this.SuspendLayout(); // // toolBar // + this.toolBar.AutoSize = false; this.toolBar.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden; this.toolBar.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { this.lbl_preview, @@ -65,7 +66,7 @@ this.toolBar.Location = new System.Drawing.Point(0, 0); this.toolBar.Name = "toolBar"; this.toolBar.RenderMode = System.Windows.Forms.ToolStripRenderMode.Professional; - this.toolBar.Size = new System.Drawing.Size(772, 25); + this.toolBar.Size = new System.Drawing.Size(722, 25); this.toolBar.TabIndex = 37; this.toolBar.Text = "toolStrip1"; // @@ -134,7 +135,7 @@ this.btn_playQT.Name = "btn_playQT"; this.btn_playQT.Size = new System.Drawing.Size(96, 22); this.btn_playQT.Text = "Play with QT"; - this.btn_playQT.Click += new System.EventHandler(this.PlayQT_Click); + this.btn_playQT.Click += new System.EventHandler(this.PlayQtClick); // // btn_playVLC // @@ -144,26 +145,7 @@ this.btn_playVLC.Name = "btn_playVLC"; this.btn_playVLC.Size = new System.Drawing.Size(101, 22); this.btn_playVLC.Text = "Play with VLC"; - this.btn_playVLC.Click += new System.EventHandler(this.PlayVLC_Click); - // - // QTControl - // - this.QTControl.Enabled = true; - this.QTControl.Location = new System.Drawing.Point(0, 0); - this.QTControl.Name = "QTControl"; - this.QTControl.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("QTControl.OcxState"))); - this.QTControl.Size = new System.Drawing.Size(64, 72); - this.QTControl.TabIndex = 39; - this.QTControl.Visible = false; - // - // panel1 - // - this.panel1.Controls.Add(this.QTControl); - this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; - this.panel1.Location = new System.Drawing.Point(0, 25); - this.panel1.Name = "panel1"; - this.panel1.Size = new System.Drawing.Size(772, 481); - this.panel1.TabIndex = 40; + this.btn_playVLC.Click += new System.EventHandler(this.PlayVlcClick); // // toolStripSeparator1 // @@ -183,23 +165,47 @@ this.lbl_encodeStatus.Text = "0.00%"; this.lbl_encodeStatus.Visible = false; // + // panel1 + // + this.panel1.AutoSize = true; + this.panel1.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; + this.panel1.Controls.Add(this.QTControl); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(0, 25); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(722, 481); + this.panel1.TabIndex = 40; + // + // QTControl + // + this.QTControl.Enabled = true; + this.QTControl.Location = new System.Drawing.Point(0, 0); + this.QTControl.Name = "QTControl"; + this.QTControl.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("QTControl.OcxState"))); + this.QTControl.Size = new System.Drawing.Size(64, 72); + this.QTControl.TabIndex = 39; + this.QTControl.Visible = false; + // // frmPreview // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.AutoSize = true; + this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; this.BackColor = System.Drawing.Color.Black; - this.ClientSize = new System.Drawing.Size(772, 506); + this.ClientSize = new System.Drawing.Size(722, 506); this.Controls.Add(this.panel1); this.Controls.Add(this.toolBar); this.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); + this.MinimumSize = new System.Drawing.Size(730, 32); this.Name = "frmPreview"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "Video Preview"; this.toolBar.ResumeLayout(false); this.toolBar.PerformLayout(); - ((System.ComponentModel.ISupportInitialize)(this.QTControl)).EndInit(); this.panel1.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.QTControl)).EndInit(); this.ResumeLayout(false); this.PerformLayout(); diff --git a/win/C#/frmPreview.cs b/win/C#/frmPreview.cs index d68841b49..bbf8c78e4 100644 --- a/win/C#/frmPreview.cs +++ b/win/C#/frmPreview.cs @@ -25,6 +25,7 @@ namespace Handbrake public partial class frmPreview : Form { #region Private Variables + /// /// The Main Window /// @@ -33,7 +34,7 @@ namespace Handbrake /// /// True if QT is not installed /// - private readonly bool noQT; + private readonly bool noQt; /// /// The encode queue @@ -48,13 +49,15 @@ namespace Handbrake /// /// Play With VLC tracker /// - private bool playWithVLC; + private bool playWithVlc; /// /// A Thread for the video player /// private Thread player; + #endregion + /// /// Initializes a new instance of the class. /// @@ -69,21 +72,27 @@ namespace Handbrake } catch (Exception) { - this.noQT = true; + this.noQt = true; } + this.mainWindow = mw; + cb_preview.SelectedIndex = 0; cb_duration.SelectedIndex = 1; cb_preview.Items.Clear(); for (int i = 1; i <= Properties.Settings.Default.previewScanCount; i++) + { cb_preview.Items.Add(i.ToString()); + } + cb_preview.SelectedIndex = 0; - encodeQueue.EncodeStarted += this.EncodeQueue_EncodeStarted; - encodeQueue.EncodeEnded += this.EncodeQueue_EncodeEnded; + encodeQueue.EncodeStarted += this.EncodeQueueEncodeStarted; + encodeQueue.EncodeEnded += this.EncodeQueueEncodeEnded; } + #region Delegates /// /// Update UI Delegate /// @@ -93,15 +102,15 @@ namespace Handbrake /// /// The e. /// - private delegate void UpdateUIHandler(object sender, EventArgs e); + private delegate void UpdateUiHandler(object sender, EventArgs e); /// /// The Open Movie Handler /// private delegate void OpenMovieHandler(); - #endregion + #region Event Handlers /// /// The encode has started /// @@ -111,9 +120,9 @@ namespace Handbrake /// /// The e. /// - private void EncodeQueue_EncodeStarted(object sender, EventArgs e) + private void EncodeQueueEncodeStarted(object sender, EventArgs e) { - encodeQueue.EncodeStatusChanged += this.EncodeQueue_EncodeStatusChanged; + encodeQueue.EncodeStatusChanged += this.EncodeQueueEncodeStatusChanged; } /// @@ -125,22 +134,22 @@ namespace Handbrake /// /// The e. /// - private void EncodeQueue_EncodeEnded(object sender, EventArgs e) + private void EncodeQueueEncodeEnded(object sender, EventArgs e) { - encodeQueue.EncodeStatusChanged -= this.EncodeQueue_EncodeStatusChanged; + encodeQueue.EncodeStatusChanged -= this.EncodeQueueEncodeStatusChanged; try { if (this.InvokeRequired) { - this.BeginInvoke(new UpdateUIHandler(EncodeQueue_EncodeEnded), new[] { sender, e }); + this.BeginInvoke(new UpdateUiHandler(EncodeQueueEncodeEnded), new[] { sender, e }); return; } ProgressBarStatus.Visible = false; lbl_encodeStatus.Visible = false; - if (!this.noQT) + if (!this.noQt) btn_playQT.Enabled = true; btn_playVLC.Enabled = true; @@ -153,10 +162,10 @@ namespace Handbrake Replace(".mkv", "_sample.mkv"); // Play back in QT or VLC - if (!playWithVLC) + if (!playWithVlc) Play(); else - PlayVLC(); + PlayVlc(); } catch (Exception exc) { @@ -173,17 +182,18 @@ namespace Handbrake /// /// The e. /// - private void EncodeQueue_EncodeStatusChanged(object sender, HandBrake.ApplicationServices.EncodeProgressEventArgs e) + private void EncodeQueueEncodeStatusChanged(object sender, HandBrake.ApplicationServices.EncodeProgressEventArgs e) { if (this.InvokeRequired) { - this.BeginInvoke(new Encode.EncodeProgessStatus(this.EncodeQueue_EncodeStatusChanged), new[] { sender, e }); + this.BeginInvoke(new Encode.EncodeProgessStatus(this.EncodeQueueEncodeStatusChanged), new[] { sender, e }); return; } lbl_encodeStatus.Text = e.PercentComplete + "%"; ProgressBarStatus.Value = (int)Math.Round(e.PercentComplete); } + #endregion #region Encode Sample @@ -196,16 +206,17 @@ namespace Handbrake /// /// The e. /// - private void PlayVLC_Click(object sender, EventArgs e) + private void PlayVlcClick(object sender, EventArgs e) { ProgressBarStatus.Visible = true; ProgressBarStatus.Value = 0; lbl_encodeStatus.Visible = true; - playWithVLC = true; - + playWithVlc = true; + this.panel1.Visible = false; + try { - if (!this.noQT) + if (!this.noQt) QTControl.URL = string.Empty; if (File.Exists(this.currentlyPlaying)) @@ -235,10 +246,11 @@ namespace Handbrake /// /// The e. /// - private void PlayQT_Click(object sender, EventArgs e) + private void PlayQtClick(object sender, EventArgs e) { - playWithVLC = false; - if (this.noQT) + playWithVlc = false; + this.panel1.Visible = true; + if (this.noQt) { MessageBox.Show(this, "It would appear QuickTime 7 is not installed or not accessible. Please (re)install QuickTime.", @@ -248,7 +260,7 @@ namespace Handbrake if (this.mainWindow.text_destination.Text.Contains(".mkv")) { MessageBox.Show(this, - "The QuickTime Control does not support MKV files, It is recommended you use VLC option instead.", + "The QuickTime Control does not support MKV files, It is recommended you use the VLC option instead.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else @@ -294,7 +306,7 @@ namespace Handbrake MessageBox.Show( this, "Handbrake is already encoding a video!", - "Status", + "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); @@ -320,7 +332,7 @@ namespace Handbrake /// /// Play the video back in an external VLC Player /// - private void PlayVLC() + private void PlayVlc() { // Launch VLC and Play video. if (this.currentlyPlaying != string.Empty) @@ -411,8 +423,8 @@ namespace Handbrake /// protected override void OnClosing(System.ComponentModel.CancelEventArgs e) { - encodeQueue.EncodeStarted -= this.EncodeQueue_EncodeStarted; - encodeQueue.EncodeEnded -= this.EncodeQueue_EncodeEnded; + encodeQueue.EncodeStarted -= this.EncodeQueueEncodeStarted; + encodeQueue.EncodeEnded -= this.EncodeQueueEncodeEnded; base.OnClosing(e); } } diff --git a/win/C#/frmPreview.resx b/win/C#/frmPreview.resx index f75a67ce1..85ca67137 100644 --- a/win/C#/frmPreview.resx +++ b/win/C#/frmPreview.resx @@ -122,7 +122,7 @@ - AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj0yLjAuMC4w + AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAVQAAAAIB AAAAAQAAAAAAAAAAAAAAAEAAAAAACAAAnQYAAHEHAAATAA8AAIATAAAAAAADAAAAAAALAP//AwAAAAAA -- 2.40.0