X-Git-Url: http://git.osdn.jp/view?a=blobdiff_plain;f=win%2FC%23%2FfrmPreview.cs;h=f2356ae6057d1d9bcfd9be419135d307261c29d7;hb=b3d9b074e43038194d0936fa7cdb268145bba52e;hp=e2022ca2b4e7f7bb2eac675a41f71256997a5d63;hpb=8949d123568c92fc6955ddfb26131e4831389689;p=handbrake-jp%2Fhandbrake-jp-git.git diff --git a/win/C#/frmPreview.cs b/win/C#/frmPreview.cs index e2022ca2..f2356ae6 100644 --- a/win/C#/frmPreview.cs +++ b/win/C#/frmPreview.cs @@ -4,6 +4,9 @@ using System.Threading; using System.Diagnostics; using System.Runtime.InteropServices; using System.IO; +using Handbrake.EncodeQueue; +using Handbrake.Functions; +using QTOControlLib; using QTOLibrary; namespace Handbrake @@ -12,11 +15,10 @@ namespace Handbrake { QueryGenerator hb_common_func = new QueryGenerator(); - Functions.Encode process = new Functions.Encode(); + Encode process = new Encode(); private delegate void UpdateUIHandler(); String currently_playing = ""; readonly frmMain mainWindow; - private Process hbProc; private Thread player; private Boolean noQT; @@ -28,7 +30,7 @@ namespace Handbrake } catch (Exception exc) { - 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); + 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); btn_playQT.Enabled = false; noQT = true; } @@ -36,34 +38,61 @@ namespace Handbrake cb_preview.SelectedIndex = 0; cb_duration.SelectedIndex = 1; } - + #region Encode Sample private void btn_playVLC_Click(object sender, EventArgs e) { + lbl_status.Visible = true; + try + { + QTControl.URL = ""; + if (File.Exists(currently_playing)) + File.Delete(currently_playing); + } + catch (Exception) + { + MessageBox.Show(this, "Unable to delete previous preview file. You may need to restart the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + btn_playQT.Enabled = false; btn_playVLC.Enabled = false; lbl_status.Text = "Encoding Sample for (VLC) ..."; - String query = hb_common_func.GeneratePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text); - ThreadPool.QueueUserWorkItem(procMonitor, query); + String query = hb_common_func.generatePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text); + ThreadPool.QueueUserWorkItem(procMonitor, query); } private void btn_playQT_Click(object sender, EventArgs e) { + lbl_status.Visible = true; + try + { + QTControl.URL = ""; + if (File.Exists(currently_playing)) + File.Delete(currently_playing); + } + catch (Exception) + { + MessageBox.Show(this, "Unable to delete previous preview file. You may need to restart the application.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + } + btn_playQT.Enabled = false; btn_playVLC.Enabled = false; lbl_status.Text = "Encoding Sample for (QT) ..."; - String query = hb_common_func.GeneratePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text); + String query = hb_common_func.generatePreviewQuery(mainWindow, cb_duration.Text, cb_preview.Text); ThreadPool.QueueUserWorkItem(procMonitor, query); } private void procMonitor(object state) { // Make sure we are not already encoding and if we are then display an error. - if (hbProc != null) + if (process.hbProcess != null) MessageBox.Show(this, "Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning); else { - hbProc = process.runCli(this, (string)state); - hbProc.WaitForExit(); - hbProc = null; + process.runCli((string)state); + if (process.hbProcess != null) + { + process.hbProcess.WaitForExit(); + process.hbProcess = null; + } encodeCompleted(); } } @@ -87,14 +116,14 @@ namespace Handbrake // Get the sample filename if (mainWindow.text_destination.Text != "") - currently_playing = mainWindow.text_destination.Text.Replace(".mp4", "_sample.mp4").Replace(".m4v", "_sample.m4v").Replace(".avi", "_sample.avi").Replace(".ogm", "_sample.ogm"); + currently_playing = mainWindow.text_destination.Text.Replace(".mp4", "_sample.mp4").Replace(".m4v", "_sample.m4v").Replace(".mkv", "_sample.mkv");; // Play back in QT or VLC if (playerSelection == "QT") play(); - else + else playVLC(); - + lbl_status.Text = ""; } catch (Exception exc) @@ -113,6 +142,7 @@ namespace Handbrake { player = new Thread(OpenMovie) { IsBackground = true }; player.Start(); + lbl_status.Visible = false; } /// @@ -138,6 +168,7 @@ namespace Handbrake else 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); } + lbl_status.Visible = false; } /// @@ -153,18 +184,13 @@ namespace Handbrake BeginInvoke(new UpdateUIHandler(OpenMovie)); return; } + QTControl.Sizing = QTSizingModeEnum.qtControlFitsMovie; QTControl.URL = currently_playing; - QTControl.Width = QTControl.Movie.Width; - QTControl.Height = QTControl.Movie.Height; - // The initial control size is 64,64. If we do not reload the clip here - // it'll scale the video from 64,64. - // Unsure why as it correctly resizes the control to the movies actual size. - QTControl.URL = currently_playing; - QTControl.SetScale(0); + QTControl.Sizing = QTSizingModeEnum.qtMovieFitsControl; QTControl.Show(); - this.Width = QTControl.Width + 5; - this.Height = QTControl.Height + 90; + this.ClientSize = QTControl.Size; + this.Height += 25; } catch (COMException ex) {