X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=win%2FC%23%2FfrmPreview.cs;h=3a8a2207c8b663327de134d8eb5f54c64024b87d;hb=4560ade3c833f282f02d15a9473e233488617df9;hp=2c9e6c87d4db3c0dceee0ca26e837b7c78d48b16;hpb=d64752a15a5bf0e96c5e27b60b4d7aa76efdaf5d;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/win/C#/frmPreview.cs b/win/C#/frmPreview.cs index 2c9e6c87..3a8a2207 100644 --- a/win/C#/frmPreview.cs +++ b/win/C#/frmPreview.cs @@ -10,6 +10,7 @@ namespace Handbrake using System.IO; using System.Runtime.InteropServices; using System.Threading; + using System.Windows; using System.Windows.Forms; using Functions; @@ -19,11 +20,15 @@ namespace Handbrake using QTOControlLib; using QTOLibrary; + using MessageBox = System.Windows.Forms.MessageBox; + /// /// The Preview Window /// public partial class frmPreview : Form { + #region Private Variables + /// /// The Main Window /// @@ -32,7 +37,7 @@ namespace Handbrake /// /// True if QT is not installed /// - private readonly bool noQT; + private readonly bool noQt; /// /// The encode queue @@ -47,13 +52,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. /// @@ -68,21 +75,34 @@ namespace Handbrake } catch (Exception) { - this.noQT = true; + this.noQt = true; + + int borderWidth = (this.Width - this.ClientSize.Width) / 2; + int titlebarAndBorder = this.Height - this.ClientSize.Height; + + this.Height = toolBar.Height + titlebarAndBorder + 1; + btn_playQT.Enabled = false; + btn_playQT.Visible = false; } + 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 /// @@ -92,13 +112,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 /// @@ -108,9 +130,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; } /// @@ -122,22 +144,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; @@ -150,10 +172,10 @@ namespace Handbrake Replace(".mkv", "_sample.mkv"); // Play back in QT or VLC - if (!playWithVLC) + if (!playWithVlc) Play(); else - PlayVLC(); + PlayVlc(); } catch (Exception exc) { @@ -170,17 +192,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 @@ -193,16 +216,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)) @@ -219,7 +243,7 @@ namespace Handbrake this.Text += " (Encoding)"; int duration; int.TryParse(cb_duration.Text, out duration); - string query = QueryGenerator.GenerateCliQuery(this.mainWindow, 3, duration, cb_preview.Text); + string query = QueryGenerator.GeneratePreviewQuery(this.mainWindow, duration, cb_preview.Text); ThreadPool.QueueUserWorkItem(this.CreatePreview, query); } @@ -232,10 +256,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.", @@ -245,7 +270,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 @@ -271,7 +296,7 @@ namespace Handbrake this.Text += " (Encoding)"; int duration; int.TryParse(cb_duration.Text, out duration); - string query = QueryGenerator.GenerateCliQuery(this.mainWindow, 3, duration, cb_preview.Text); + string query = QueryGenerator.GeneratePreviewQuery(this.mainWindow, duration, cb_preview.Text); ThreadPool.QueueUserWorkItem(this.CreatePreview, query); } @@ -291,7 +316,7 @@ namespace Handbrake MessageBox.Show( this, "Handbrake is already encoding a video!", - "Status", + "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); @@ -317,7 +342,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) @@ -385,7 +410,7 @@ namespace Handbrake QTControl.Show(); this.ClientSize = QTControl.Size; - this.Height += 25; + this.Height += toolBar.Height; } catch (COMException ex) { @@ -408,8 +433,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); } }