From 15678a6a29c5a4fdd8e9c644fa3727060bfb07de Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 28 Dec 2009 19:47:34 +0000 Subject: WinGui: - Improve VLC detection for the preview window. - Put in the infrastructure for the new Frame / Duration(Seconds) feature - Some Re-factoring git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3050 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Functions/QueryGenerator.cs | 82 +++++++++++-------- win/C#/Functions/Scan.cs | 10 +-- win/C#/frmMain.Designer.cs | 161 +++++++++++++++++++------------------ win/C#/frmMain.cs | 51 +++++++----- win/C#/frmPreview.cs | 108 +++++++++++++------------ 5 files changed, 227 insertions(+), 185 deletions(-) (limited to 'win') diff --git a/win/C#/Functions/QueryGenerator.cs b/win/C#/Functions/QueryGenerator.cs index 2d2bd2a81..bfe456dc7 100644 --- a/win/C#/Functions/QueryGenerator.cs +++ b/win/C#/Functions/QueryGenerator.cs @@ -18,16 +18,16 @@ namespace Handbrake.Functions /// Generates a full CLI query for either encoding or previe encoeds if duration and preview are defined. /// /// + /// /// /// /// - public string GenerateCLIQuery(frmMain mainWindow, int duration, string preview) + public string GenerateCLIQuery(frmMain mainWindow, int mode, int duration, string preview) { string query = ""; - - if (!string.IsNullOrEmpty(mainWindow.sourcePath)) - if (mainWindow.sourcePath.Trim() != "Select \"Source\" to continue") - query = " -i " + '"' + mainWindow.sourcePath + '"'; + + if (!string.IsNullOrEmpty(mainWindow.sourcePath) && mainWindow.sourcePath.Trim() != "Select \"Source\" to continue") + query = " -i " + '"' + mainWindow.sourcePath + '"'; if (mainWindow.drp_dvdtitle.Text != "") { @@ -35,32 +35,46 @@ namespace Handbrake.Functions query += " -t " + titleInfo[0]; } - if (!Properties.Settings.Default.noDvdNav) - if (mainWindow.drop_angle.Items.Count != 0) - query += " --angle " + mainWindow.drop_angle.SelectedItem; - + if (!Properties.Settings.Default.noDvdNav && mainWindow.drop_angle.Items.Count != 0) + query += " --angle " + mainWindow.drop_angle.SelectedItem; - if (duration != 0 && preview != null) // Preivew Query + // Decide what part of the video we want to encode. + switch (mode) { - query += " --previews " + Properties.Settings.Default.previewScanCount + " "; - query += " --start-at-preview " + preview; - query += " --stop-at duration:" + duration + " "; + case 0: // Chapters + if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "") + query += string.Format(" -c {0}", mainWindow.drop_chapterStart.Text); + else if (mainWindow.drop_chapterStart.Text != "" && mainWindow.drop_chapterFinish.Text != "") + query += string.Format(" -c {0}-{1}", mainWindow.drop_chapterStart.Text, mainWindow.drop_chapterFinish.Text); + break; + case 1: // Seconds + int start, end; + int.TryParse(mainWindow.drop_chapterStart.Text, out start); + int.TryParse(mainWindow.drop_chapterFinish.Text, out end); + int calculatedDuration = end - start; - if (mainWindow.text_destination.Text != "") - query += " -o " + '"' + mainWindow.text_destination.Text.Replace(".m", "_sample.m") + '"'; - } - else // Non Preview Query - { - if (mainWindow.drop_chapterFinish.Text == mainWindow.drop_chapterStart.Text && mainWindow.drop_chapterStart.Text != "") - query += " -c " + mainWindow.drop_chapterStart.Text; - else if (mainWindow.drop_chapterStart.Text == "Auto" && mainWindow.drop_chapterFinish.Text != "Auto") - query += " -c " + "0-" + mainWindow.drop_chapterFinish.Text; - else if (mainWindow.drop_chapterStart.Text != "Auto" && mainWindow.drop_chapterFinish.Text != "Auto" && mainWindow.drop_chapterStart.Text != "") - query += " -c " + mainWindow.drop_chapterStart.Text + "-" + mainWindow.drop_chapterFinish.Text; - - if (mainWindow.text_destination.Text != "") - query += " -o " + '"' + mainWindow.text_destination.Text + '"'; + query += string.Format(" --start-at duration:{0} --stop-at duration:{1}", mainWindow.drop_chapterStart.Text, calculatedDuration); + break; + case 2: // Frames + int.TryParse(mainWindow.drop_chapterStart.Text, out start); + int.TryParse(mainWindow.drop_chapterFinish.Text, out end); + calculatedDuration = end - start; + + query += string.Format(" --start-at frame:{0} --stop-at frame:{1}", mainWindow.drop_chapterStart.Text, calculatedDuration); + break; + case 3: // Preview + query += " --previews " + Properties.Settings.Default.previewScanCount + " "; + query += " --start-at-preview " + preview; + query += " --stop-at duration:" + duration + " "; + + if (mainWindow.text_destination.Text != "") + query += string.Format(" -o \"{0}\" ", mainWindow.text_destination.Text.Replace(".m", "_sample.m")); + break; + default: + break; } + if (mode != 3) + query += string.Format(" -o \"{0}\" ", mainWindow.text_destination.Text); query += GenerateTabbedComponentsQuery(mainWindow); @@ -258,11 +272,11 @@ namespace Handbrake.Functions // Audio Codec (-E) if (row.SubItems[2].Text != String.Empty) - codecs.Add(getAudioEncoder(row.SubItems[2].Text)); + codecs.Add(GetAudioEncoder(row.SubItems[2].Text)); // Audio Mixdown (-6) if (row.SubItems[3].Text != String.Empty) - mixdowns.Add(getMixDown(row.SubItems[3].Text)); + mixdowns.Add(GetMixDown(row.SubItems[3].Text)); // Sample Rate (-R) if (row.SubItems[4].Text != String.Empty) @@ -377,7 +391,7 @@ namespace Handbrake.Functions string subtitleForced = String.Empty; string subtitleBurn = String.Empty; string subtitleDefault = String.Empty; - + // SRT string srtFile = String.Empty; string srtCodeset = String.Empty; @@ -499,7 +513,7 @@ namespace Handbrake.Functions ? Path.Combine(Path.GetTempPath(), dest_name + "-" + source_title + "-chapters.csv") : Path.Combine(Path.GetTempPath(), dest_name + "-chapters.csv"); - if (chapterCSVSave(mainWindow, path) == false) + if (ChapterCSVSave(mainWindow, path) == false) query += " -m "; else query += " --markers=" + "\"" + path + "\""; @@ -528,7 +542,7 @@ namespace Handbrake.Functions return query; } - private static string getMixDown(string selectedAudio) + private static string GetMixDown(string selectedAudio) { switch (selectedAudio) { @@ -548,7 +562,7 @@ namespace Handbrake.Functions return "auto"; } } - private static string getAudioEncoder(string selectedEncoder) + private static string GetAudioEncoder(string selectedEncoder) { switch (selectedEncoder) { @@ -566,7 +580,7 @@ namespace Handbrake.Functions return ""; } } - private static Boolean chapterCSVSave(frmMain mainWindow, string filePathName) + private static Boolean ChapterCSVSave(frmMain mainWindow, string filePathName) { try { diff --git a/win/C#/Functions/Scan.cs b/win/C#/Functions/Scan.cs index aca3399f3..1aadf0afd 100644 --- a/win/C#/Functions/Scan.cs +++ b/win/C#/Functions/Scan.cs @@ -23,10 +23,10 @@ namespace Handbrake.Functions public event EventHandler ScanCompleted; public event EventHandler ScanStatusChanged; - public void ScanSource(string sourcePath) + public void ScanSource(string sourcePath, int title) { - Thread t = new Thread(new ParameterizedThreadStart(RunScan)); - t.Start(sourcePath); + Thread t = new Thread(unused => RunScan(sourcePath, title)); + t.Start(); } public DVD SouceData() @@ -49,7 +49,7 @@ namespace Handbrake.Functions return _hbProc; } - private void RunScan(object sourcePath) + private void RunScan(object sourcePath, int title) { try { @@ -73,7 +73,7 @@ namespace Handbrake.Functions StartInfo = { FileName = handbrakeCLIPath, - Arguments = String.Format(@" -i ""{0}"" -t0 {1} -v ", sourcePath, dvdnav), + Arguments = String.Format(@" -i ""{0}"" -t{1} {2} -v ", sourcePath, title, dvdnav), RedirectStandardOutput = true, RedirectStandardError = true, UseShellExecute = false, diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index 57ba75590..856192468 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -68,6 +68,7 @@ namespace Handbrake this.drop_angle = new System.Windows.Forms.ComboBox(); this.drp_dvdtitle = new System.Windows.Forms.ComboBox(); this.btn_importChapters = new System.Windows.Forms.Button(); + this.drop_mode = new System.Windows.Forms.ComboBox(); this.DVD_Open = new System.Windows.Forms.FolderBrowserDialog(); this.File_Open = new System.Windows.Forms.OpenFileDialog(); this.ISO_Open = new System.Windows.Forms.OpenFileDialog(); @@ -99,7 +100,6 @@ namespace Handbrake this.Label47 = new System.Windows.Forms.Label(); this.Label3 = new System.Windows.Forms.Label(); this.tab_audio = new System.Windows.Forms.TabPage(); - this.AudioSettings = new Handbrake.Controls.AudioPanel(); this.AudioMenuRowHeightHack = new System.Windows.Forms.ImageList(this.components); this.tab_video = new System.Windows.Forms.TabPage(); this.lbl_qualityValue = new System.Windows.Forms.Label(); @@ -112,17 +112,13 @@ namespace Handbrake this.lbl_SliderValue = new System.Windows.Forms.Label(); this.Label46 = new System.Windows.Forms.Label(); this.tab_picture = new System.Windows.Forms.TabPage(); - this.PictureSettings = new Handbrake.Controls.PictureSettings(); this.Check_ChapterMarkers = new System.Windows.Forms.CheckBox(); this.tabs_panel = new System.Windows.Forms.TabControl(); this.tab_filters = new System.Windows.Forms.TabPage(); - this.Filters = new Handbrake.Controls.Filters(); this.tab_subtitles = new System.Windows.Forms.TabPage(); - this.Subtitles = new Handbrake.Controls.Subtitles(); this.tab_chapters = new System.Windows.Forms.TabPage(); this.label31 = new System.Windows.Forms.Label(); this.tab_advanced = new System.Windows.Forms.TabPage(); - this.x264Panel = new Handbrake.Controls.x264Panel(); this.tab_query = new System.Windows.Forms.TabPage(); this.btn_clear = new System.Windows.Forms.Button(); this.label34 = new System.Windows.Forms.Label(); @@ -165,7 +161,6 @@ namespace Handbrake this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel(); this.Label10 = new System.Windows.Forms.Label(); this.lbl_angle = new System.Windows.Forms.Label(); - this.Label9 = new System.Windows.Forms.Label(); this.Label13 = new System.Windows.Forms.Label(); this.label_duration = new System.Windows.Forms.Label(); this.lbl_duration = new System.Windows.Forms.Label(); @@ -176,6 +171,11 @@ namespace Handbrake this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel(); this.openPreset = new System.Windows.Forms.OpenFileDialog(); this.File_ChapterImport = new System.Windows.Forms.OpenFileDialog(); + this.PictureSettings = new Handbrake.Controls.PictureSettings(); + this.Filters = new Handbrake.Controls.Filters(); + this.AudioSettings = new Handbrake.Controls.AudioPanel(); + this.Subtitles = new Handbrake.Controls.Subtitles(); + this.x264Panel = new Handbrake.Controls.x264Panel(); notifyIconMenu = new System.Windows.Forms.ContextMenuStrip(this.components); notifyIconMenu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.slider_videoQuality)).BeginInit(); @@ -480,7 +480,7 @@ namespace Handbrake // this.drop_chapterFinish.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.drop_chapterFinish.FormattingEnabled = true; - this.drop_chapterFinish.Location = new System.Drawing.Point(447, 3); + this.drop_chapterFinish.Location = new System.Drawing.Point(509, 3); this.drop_chapterFinish.Name = "drop_chapterFinish"; this.drop_chapterFinish.Size = new System.Drawing.Size(69, 21); this.drop_chapterFinish.TabIndex = 10; @@ -491,7 +491,7 @@ namespace Handbrake // this.drop_chapterStart.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.drop_chapterStart.FormattingEnabled = true; - this.drop_chapterStart.Location = new System.Drawing.Point(321, 3); + this.drop_chapterStart.Location = new System.Drawing.Point(383, 3); this.drop_chapterStart.Name = "drop_chapterStart"; this.drop_chapterStart.Size = new System.Drawing.Size(69, 21); this.drop_chapterStart.TabIndex = 9; @@ -537,6 +537,20 @@ namespace Handbrake this.btn_importChapters.UseVisualStyleBackColor = true; this.btn_importChapters.Click += new System.EventHandler(this.btn_importChapters_Click); // + // drop_mode + // + this.drop_mode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.drop_mode.FormattingEnabled = true; + this.drop_mode.Items.AddRange(new object[] { + "Chapters", + "Seconds", + "Frames"}); + this.drop_mode.Location = new System.Drawing.Point(295, 3); + this.drop_mode.Name = "drop_mode"; + this.drop_mode.Size = new System.Drawing.Size(77, 21); + this.drop_mode.TabIndex = 46; + this.drop_mode.SelectedIndexChanged += new System.EventHandler(this.drop_mode_SelectedIndexChanged); + // // DVD_Open // this.DVD_Open.Description = "Select the \"VIDEO_TS\" folder from your DVD Drive."; @@ -791,15 +805,6 @@ namespace Handbrake this.tab_audio.Text = "Audio"; this.tab_audio.UseVisualStyleBackColor = true; // - // AudioSettings - // - this.AudioSettings.BackColor = System.Drawing.Color.Transparent; - this.AudioSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.AudioSettings.Location = new System.Drawing.Point(0, 0); - this.AudioSettings.Name = "AudioSettings"; - this.AudioSettings.Size = new System.Drawing.Size(715, 310); - this.AudioSettings.TabIndex = 0; - // // AudioMenuRowHeightHack // this.AudioMenuRowHeightHack.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; @@ -948,16 +953,6 @@ namespace Handbrake this.tab_picture.Text = "Picture"; this.tab_picture.UseVisualStyleBackColor = true; // - // PictureSettings - // - this.PictureSettings.BackColor = System.Drawing.Color.Transparent; - this.PictureSettings.Enabled = false; - this.PictureSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.PictureSettings.Location = new System.Drawing.Point(0, 0); - this.PictureSettings.Name = "PictureSettings"; - this.PictureSettings.Size = new System.Drawing.Size(666, 279); - this.PictureSettings.TabIndex = 0; - // // Check_ChapterMarkers // this.Check_ChapterMarkers.AutoSize = true; @@ -997,15 +992,6 @@ namespace Handbrake this.tab_filters.Text = "Video Filters"; this.tab_filters.UseVisualStyleBackColor = true; // - // Filters - // - this.Filters.BackColor = System.Drawing.Color.Transparent; - this.Filters.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Filters.Location = new System.Drawing.Point(0, 0); - this.Filters.Name = "Filters"; - this.Filters.Size = new System.Drawing.Size(713, 310); - this.Filters.TabIndex = 0; - // // tab_subtitles // this.tab_subtitles.Controls.Add(this.Subtitles); @@ -1017,15 +1003,6 @@ namespace Handbrake this.tab_subtitles.Text = "Subtitles"; this.tab_subtitles.UseVisualStyleBackColor = true; // - // Subtitles - // - this.Subtitles.BackColor = System.Drawing.Color.Transparent; - this.Subtitles.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.Subtitles.Location = new System.Drawing.Point(0, 0); - this.Subtitles.Name = "Subtitles"; - this.Subtitles.Size = new System.Drawing.Size(722, 310); - this.Subtitles.TabIndex = 0; - // // tab_chapters // this.tab_chapters.BackColor = System.Drawing.Color.Transparent; @@ -1063,16 +1040,6 @@ namespace Handbrake this.tab_advanced.Text = "Advanced"; this.tab_advanced.UseVisualStyleBackColor = true; // - // x264Panel - // - this.x264Panel.BackColor = System.Drawing.Color.Transparent; - this.x264Panel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); - this.x264Panel.Location = new System.Drawing.Point(0, 0); - this.x264Panel.Name = "x264Panel"; - this.x264Panel.Size = new System.Drawing.Size(720, 306); - this.x264Panel.TabIndex = 0; - this.x264Panel.x264Query = ""; - // // tab_query // this.tab_query.Controls.Add(this.btn_clear); @@ -1492,12 +1459,14 @@ namespace Handbrake // tableLayoutPanel1 // this.tableLayoutPanel1.AutoSize = true; - this.tableLayoutPanel1.ColumnCount = 10; + this.tableLayoutPanel1.ColumnCount = 12; this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 35F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); + this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 5F)); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle()); @@ -1507,12 +1476,12 @@ namespace Handbrake this.tableLayoutPanel1.Controls.Add(this.drp_dvdtitle, 1, 0); this.tableLayoutPanel1.Controls.Add(this.lbl_angle, 2, 0); this.tableLayoutPanel1.Controls.Add(this.drop_angle, 3, 0); - this.tableLayoutPanel1.Controls.Add(this.Label9, 4, 0); - this.tableLayoutPanel1.Controls.Add(this.drop_chapterStart, 5, 0); - this.tableLayoutPanel1.Controls.Add(this.Label13, 6, 0); - this.tableLayoutPanel1.Controls.Add(this.drop_chapterFinish, 7, 0); - this.tableLayoutPanel1.Controls.Add(this.label_duration, 8, 0); - this.tableLayoutPanel1.Controls.Add(this.lbl_duration, 9, 0); + this.tableLayoutPanel1.Controls.Add(this.drop_chapterStart, 7, 0); + this.tableLayoutPanel1.Controls.Add(this.Label13, 8, 0); + this.tableLayoutPanel1.Controls.Add(this.drop_chapterFinish, 9, 0); + this.tableLayoutPanel1.Controls.Add(this.label_duration, 10, 0); + this.tableLayoutPanel1.Controls.Add(this.lbl_duration, 11, 0); + this.tableLayoutPanel1.Controls.Add(this.drop_mode, 5, 0); this.tableLayoutPanel1.Location = new System.Drawing.Point(21, 86); this.tableLayoutPanel1.Name = "tableLayoutPanel1"; this.tableLayoutPanel1.RowCount = 1; @@ -1542,22 +1511,11 @@ namespace Handbrake this.lbl_angle.TabIndex = 44; this.lbl_angle.Text = "Angle:"; // - // Label9 - // - this.Label9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); - this.Label9.AutoSize = true; - this.Label9.ForeColor = System.Drawing.Color.Black; - this.Label9.Location = new System.Drawing.Point(260, 7); - this.Label9.Name = "Label9"; - this.Label9.Size = new System.Drawing.Size(55, 13); - this.Label9.TabIndex = 8; - this.Label9.Text = "Chapters:"; - // // Label13 // this.Label13.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.Label13.AutoSize = true; - this.Label13.Location = new System.Drawing.Point(396, 7); + this.Label13.Location = new System.Drawing.Point(458, 7); this.Label13.Name = "Label13"; this.Label13.Size = new System.Drawing.Size(45, 13); this.Label13.TabIndex = 10; @@ -1568,7 +1526,7 @@ namespace Handbrake this.label_duration.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right))); this.label_duration.AutoSize = true; this.label_duration.BackColor = System.Drawing.Color.Transparent; - this.label_duration.Location = new System.Drawing.Point(522, 7); + this.label_duration.Location = new System.Drawing.Point(584, 7); this.label_duration.Name = "label_duration"; this.label_duration.Size = new System.Drawing.Size(52, 13); this.label_duration.TabIndex = 42; @@ -1579,7 +1537,7 @@ namespace Handbrake this.lbl_duration.Anchor = System.Windows.Forms.AnchorStyles.Left; this.lbl_duration.AutoSize = true; this.lbl_duration.BackColor = System.Drawing.Color.Transparent; - this.lbl_duration.Location = new System.Drawing.Point(580, 7); + this.lbl_duration.Location = new System.Drawing.Point(642, 7); this.lbl_duration.Name = "lbl_duration"; this.lbl_duration.Size = new System.Drawing.Size(39, 13); this.lbl_duration.TabIndex = 43; @@ -1646,6 +1604,53 @@ namespace Handbrake // this.File_ChapterImport.Filter = "CSV Files|*.csv"; // + // PictureSettings + // + this.PictureSettings.BackColor = System.Drawing.Color.Transparent; + this.PictureSettings.Enabled = false; + this.PictureSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.PictureSettings.Location = new System.Drawing.Point(0, 0); + this.PictureSettings.Name = "PictureSettings"; + this.PictureSettings.Size = new System.Drawing.Size(666, 279); + this.PictureSettings.TabIndex = 0; + // + // Filters + // + this.Filters.BackColor = System.Drawing.Color.Transparent; + this.Filters.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Filters.Location = new System.Drawing.Point(0, 0); + this.Filters.Name = "Filters"; + this.Filters.Size = new System.Drawing.Size(713, 310); + this.Filters.TabIndex = 0; + // + // AudioSettings + // + this.AudioSettings.BackColor = System.Drawing.Color.Transparent; + this.AudioSettings.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.AudioSettings.Location = new System.Drawing.Point(0, 0); + this.AudioSettings.Name = "AudioSettings"; + this.AudioSettings.Size = new System.Drawing.Size(715, 310); + this.AudioSettings.TabIndex = 0; + // + // Subtitles + // + this.Subtitles.BackColor = System.Drawing.Color.Transparent; + this.Subtitles.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.Subtitles.Location = new System.Drawing.Point(0, 0); + this.Subtitles.Name = "Subtitles"; + this.Subtitles.Size = new System.Drawing.Size(722, 310); + this.Subtitles.TabIndex = 0; + // + // x264Panel + // + this.x264Panel.BackColor = System.Drawing.Color.Transparent; + this.x264Panel.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.x264Panel.Location = new System.Drawing.Point(0, 0); + this.x264Panel.Name = "x264Panel"; + this.x264Panel.Size = new System.Drawing.Size(720, 306); + this.x264Panel.TabIndex = 0; + this.x264Panel.x264Query = ""; + // // frmMain // this.AllowDrop = true; @@ -1662,9 +1667,9 @@ namespace Handbrake this.Controls.Add(this.labelPreset); this.Controls.Add(this.groupBox2); this.Controls.Add(this.StatusStrip); - this.Controls.Add(this.labelStaticDestination); this.Controls.Add(this.tableLayoutPanel1); this.Controls.Add(this.tabs_panel); + this.Controls.Add(this.labelStaticDestination); this.DoubleBuffered = true; 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"))); @@ -1826,7 +1831,6 @@ namespace Handbrake private TableLayoutPanel tableLayoutPanel1; internal Label lbl_angle; internal ComboBox drop_angle; - internal Label Label9; internal ComboBox drop_chapterStart; internal Label Label13; internal ComboBox drop_chapterFinish; @@ -1849,5 +1853,6 @@ namespace Handbrake private ToolStripMenuItem pmnu_import; private ToolStripSeparator toolStripSeparator2; internal Label lbl_qualityValue; + internal ComboBox drop_mode; } } \ No newline at end of file diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 2f8690e78..f165bbb02 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -85,6 +85,7 @@ namespace Handbrake loadPresetPanel(); // Load the Preset Panel treeView_presets.ExpandAll(); lbl_encode.Text = ""; + drop_mode.SelectedIndex = 0; queueWindow = new frmQueue(encodeQueue); // Prepare the Queue if (!Properties.Settings.Default.QueryEditorTab) tabs_panel.TabPages.RemoveAt(7); // Remove the query editor tab if the user does not want it enabled. @@ -297,7 +298,10 @@ namespace Handbrake if (fileList != null) { if (fileList[0] != "") - StartScan(fileList[0]); + { + this.selectedSourceType = SourceType.VideoFile; + StartScan(fileList[0], 0); + } else UpdateSourceLabel(); } @@ -383,7 +387,7 @@ namespace Handbrake } private void btn_new_preset_Click(object sender, EventArgs e) { - Form preset = new frmAddPreset(this, queryGen.GenerateCLIQuery(this, 0, null), presetHandler); + Form preset = new frmAddPreset(this, queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), presetHandler); preset.ShowDialog(); } #endregion @@ -621,16 +625,16 @@ namespace Handbrake if (result == DialogResult.Yes) { PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings); - presetHandler.Update(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, 0, null), + presetHandler.Update(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings); } } else { PresetLoader.presetLoader(this, parsed, parsed.PresetName, parsed.UsesPictureSettings); - presetHandler.Add(parsed.PresetName, queryGen.GenerateCLIQuery(this, 0, null), parsed.UsesPictureSettings); + presetHandler.Add(parsed.PresetName, queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings); - if (presetHandler.Add(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, 0, null), parsed.UsesPictureSettings)) + if (presetHandler.Add(parsed.PresetName + " (Imported)", queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null), parsed.UsesPictureSettings)) { TreeNode preset_treeview = new TreeNode(parsed.PresetName + " (Imported)") { ForeColor = Color.Black }; treeView_presets.Nodes.Add(preset_treeview); @@ -670,8 +674,8 @@ namespace Handbrake { if (encodeQueue.Count != 0 || (!string.IsNullOrEmpty(sourcePath) && !string.IsNullOrEmpty(text_destination.Text))) { - string generatedQuery = queryGen.GenerateCLIQuery(this, 0, null); - string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : queryGen.GenerateCLIQuery(this, 0, null); + string generatedQuery = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null); + string specifiedQuery = rtf_query.Text != "" ? rtf_query.Text : queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null); string query = string.Empty; // Check to make sure the generated query matches the GUI settings @@ -740,7 +744,7 @@ namespace Handbrake MessageBox.Show("No source or destination selected.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); else { - String query = queryGen.GenerateCLIQuery(this, 0, null); + String query = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null); if (rtf_query.Text != "") query = rtf_query.Text; @@ -843,7 +847,7 @@ namespace Handbrake if (DVD_Open.ShowDialog() == DialogResult.OK) { this.selectedSourceType = SourceType.Folder; - selectSource(DVD_Open.SelectedPath); + SelectSource(DVD_Open.SelectedPath); } else UpdateSourceLabel(); @@ -853,7 +857,7 @@ namespace Handbrake if (ISO_Open.ShowDialog() == DialogResult.OK) { this.selectedSourceType = SourceType.VideoFile; - selectSource(ISO_Open.FileName); + SelectSource(ISO_Open.FileName); } else UpdateSourceLabel(); @@ -862,9 +866,9 @@ namespace Handbrake { if (this.dvdDrivePath == null) return; this.selectedSourceType = SourceType.DvdDrive; - selectSource(this.dvdDrivePath); + SelectSource(this.dvdDrivePath); } - private void selectSource(string file) + private void SelectSource(string file) { Check_ChapterMarkers.Enabled = true; lastAction = "scan"; @@ -877,7 +881,7 @@ namespace Handbrake } sourcePath = Path.GetFileName(file); - StartScan(file); + StartScan(file,0); } private void drp_dvdtitle_Click(object sender, EventArgs e) { @@ -970,6 +974,9 @@ namespace Handbrake } private void chapersChanged(object sender, EventArgs e) { + if (drop_mode.SelectedIndex != 0) // Function is not used if we are not in chapters mode. + return; + Control ctl = (Control)sender; int chapterStart, chapterEnd; int.TryParse(drop_chapterStart.Text, out chapterStart); @@ -1036,6 +1043,16 @@ namespace Handbrake } } } + private void drop_mode_SelectedIndexChanged(object sender, EventArgs e) + { + if (drop_mode.SelectedIndex == 0) return; + + if (drop_mode.SelectedIndex != 0) + drop_mode.SelectedIndex = 0; + + MessageBox.Show("This feature is not implemented yet! Switching Back to Chapters Mode.", "", + MessageBoxButtons.OK, MessageBoxIcon.Error); + } //Destination private void btn_destBrowse_Click(object sender, EventArgs e) @@ -1382,7 +1399,7 @@ namespace Handbrake // Query Editor Tab private void btn_generate_Query_Click(object sender, EventArgs e) { - rtf_query.Text = queryGen.GenerateCLIQuery(this, 0, null); + rtf_query.Text = queryGen.GenerateCLIQuery(this, drop_mode.SelectedIndex, 0, null); } private void btn_clear_Click(object sender, EventArgs e) { @@ -1396,7 +1413,7 @@ namespace Handbrake public Boolean isScanning { get; set; } private Scan SourceScan; - private void StartScan(String filename) + private void StartScan(String filename, int title) { // Setup the GUI components for the scan. sourcePath = filename; @@ -1419,11 +1436,9 @@ namespace Handbrake // Start the Scan try { - // if (ActivityWindow != null) - // ActivityWindow.SetupLogViewer(true); isScanning = true; SourceScan = new Scan(); - SourceScan.ScanSource(sourcePath); + SourceScan.ScanSource(sourcePath, title); SourceScan.ScanStatusChanged += new EventHandler(SourceScan_ScanStatusChanged); SourceScan.ScanCompleted += new EventHandler(SourceScan_ScanCompleted); } diff --git a/win/C#/frmPreview.cs b/win/C#/frmPreview.cs index 08b25e3a8..d0f5ebfa3 100644 --- a/win/C#/frmPreview.cs +++ b/win/C#/frmPreview.cs @@ -13,14 +13,13 @@ namespace Handbrake { public partial class frmPreview : Form { - - QueryGenerator hb_common_func = new QueryGenerator(); - EncodeAndQueueHandler process = new EncodeAndQueueHandler(); + readonly QueryGenerator HbCommonFunc = new QueryGenerator(); + readonly EncodeAndQueueHandler Process = new EncodeAndQueueHandler(); private delegate void UpdateUIHandler(); - String currently_playing = ""; - readonly frmMain mainWindow; - private Thread player; - private Boolean noQT; + String CurrentlyPlaying = ""; + readonly frmMain MainWindow; + private Thread Player; + private readonly Boolean NoQT; public frmPreview(frmMain mw) { @@ -30,9 +29,9 @@ namespace Handbrake } catch (Exception) { - noQT = true; + NoQT = true; } - this.mainWindow = mw; + this.MainWindow = mw; cb_preview.SelectedIndex = 0; cb_duration.SelectedIndex = 1; @@ -48,11 +47,11 @@ namespace Handbrake lbl_status.Visible = true; try { - if (!noQT) + if (!NoQT) QTControl.URL = ""; - if (File.Exists(currently_playing)) - File.Delete(currently_playing); + if (File.Exists(CurrentlyPlaying)) + File.Delete(CurrentlyPlaying); } catch (Exception) { @@ -64,17 +63,17 @@ namespace Handbrake lbl_status.Text = "Encoding Sample for (VLC) ..."; int duration; int.TryParse(cb_duration.Text, out duration); - String query = hb_common_func.GenerateCLIQuery(mainWindow, duration, cb_preview.Text); - ThreadPool.QueueUserWorkItem(procMonitor, query); + String query = HbCommonFunc.GenerateCLIQuery(MainWindow, 3, duration, cb_preview.Text); + ThreadPool.QueueUserWorkItem(ProcMonitor, query); } private void btn_playQT_Click(object sender, EventArgs e) { - if (noQT) + if (NoQT) { MessageBox.Show(this, "It would appear QuickTime 7 is not installed or not accessible. Please (re)install QuickTime.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } - if (mainWindow.text_destination.Text.Contains(".mkv")) + if (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.", @@ -86,8 +85,8 @@ namespace Handbrake try { QTControl.URL = ""; - if (File.Exists(currently_playing)) - File.Delete(currently_playing); + if (File.Exists(CurrentlyPlaying)) + File.Delete(CurrentlyPlaying); } catch (Exception) { @@ -99,60 +98,60 @@ namespace Handbrake lbl_status.Text = "Encoding Sample for (QT) ..."; int duration; int.TryParse(cb_duration.Text, out duration); - String query = hb_common_func.GenerateCLIQuery(mainWindow, duration, cb_preview.Text); + String query = HbCommonFunc.GenerateCLIQuery(MainWindow, 3, duration, cb_preview.Text); - ThreadPool.QueueUserWorkItem(procMonitor, query); + ThreadPool.QueueUserWorkItem(ProcMonitor, query); } } - private void procMonitor(object state) + private void ProcMonitor(object state) { // Make sure we are not already encoding and if we are then display an error. - if (process.hbProcess != null) + if (Process.hbProcess != null) MessageBox.Show(this, "Handbrake is already encoding a video!", "Status", MessageBoxButtons.OK, MessageBoxIcon.Warning); else { - process.RunCli((string)state); - if (process.hbProcess != null) + Process.RunCli((string)state); + if (Process.hbProcess != null) { - process.hbProcess.WaitForExit(); - process.hbProcess = null; + Process.hbProcess.WaitForExit(); + Process.hbProcess = null; } - encodeCompleted(); + EncodeCompleted(); } } - private void encodeCompleted() + private void EncodeCompleted() { try { if (InvokeRequired) { - BeginInvoke(new UpdateUIHandler(encodeCompleted)); + BeginInvoke(new UpdateUIHandler(EncodeCompleted)); return; } - if (!noQT) + if (!NoQT) btn_playQT.Enabled = true; btn_playVLC.Enabled = true; - // Decide which player to use. + // Decide which Player to use. String playerSelection = lbl_status.Text.Contains("QT") ? "QT" : "VLC"; lbl_status.Text = "Loading Clip ..."; // Get the sample filename - if (mainWindow.text_destination.Text != "") - currently_playing = mainWindow.text_destination.Text.Replace(".mp4", "_sample.mp4").Replace(".m4v", "_sample.m4v").Replace(".mkv", "_sample.mkv"); ; + if (MainWindow.text_destination.Text != "") + CurrentlyPlaying = 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(); + Play(); else - playVLC(); + PlayVLC(); lbl_status.Text = ""; } catch (Exception exc) { - MessageBox.Show(this, "frmPreview.cs encodeCompleted " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); + MessageBox.Show(this, "frmPreview.cs EncodeCompleted " + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } #endregion @@ -162,27 +161,36 @@ namespace Handbrake /// /// Play the video back in the QuickTime control /// - private void play() + private void Play() { - player = new Thread(OpenMovie) { IsBackground = true }; - player.Start(); + Player = new Thread(OpenMovie) { IsBackground = true }; + Player.Start(); lbl_status.Visible = false; } /// - /// Play the video back in an external VLC player + /// Play the video back in an external VLC Player /// - private void playVLC() + private void PlayVLC() { - // Launch VLC and play video. - if (currently_playing != "") + // Launch VLC and Play video. + if (CurrentlyPlaying != "") { - if (File.Exists(currently_playing)) + if (File.Exists(CurrentlyPlaying)) { // Attempt to find VLC if it doesn't exist in the default set location. + string vlcPath; + + if (8 == IntPtr.Size || (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432")))) + vlcPath = Environment.GetEnvironmentVariable("ProgramFiles(x86)"); + else + vlcPath = Environment.GetEnvironmentVariable("ProgramFiles"); + + vlcPath = vlcPath != null ? vlcPath + @"\VideoLAN\VLC\vlc.exe" : @"C:\Program Files (x86)\VideoLAN\VLC\vlc.exe"; + if (!File.Exists(Properties.Settings.Default.VLC_Path)) { - if (File.Exists("C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe")) + if (File.Exists(vlcPath)) { Properties.Settings.Default.VLC_Path = "C:\\Program Files (x86)\\VideoLAN\\VLC\\vlc.exe"; Properties.Settings.Default.Save(); // Save this new path if it does @@ -197,12 +205,12 @@ namespace Handbrake if (File.Exists(Properties.Settings.Default.VLC_Path)) { - String args = "\"" + currently_playing + "\""; + String args = "\"" + CurrentlyPlaying + "\""; ProcessStartInfo vlc = new ProcessStartInfo(Properties.Settings.Default.VLC_Path, args); - Process.Start(vlc); + System.Diagnostics.Process.Start(vlc); lbl_status.Text = "VLC will now launch."; } - + } 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); @@ -223,9 +231,9 @@ namespace Handbrake BeginInvoke(new UpdateUIHandler(OpenMovie)); return; } - QTControl.URL = currently_playing; + QTControl.URL = CurrentlyPlaying; QTControl.SetSizing(QTSizingModeEnum.qtControlFitsMovie, true); - QTControl.URL = currently_playing; + QTControl.URL = CurrentlyPlaying; QTControl.Show(); this.ClientSize = QTControl.Size; -- cgit v1.2.3