From 235ed25e597a01aee6d22e582d7984d0bad74d41 Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 6 Apr 2009 15:15:40 +0000 Subject: [PATCH] WinGui: - Add support for drag/drop of a source file onto the main window. Source will be scanned on drop. - Misc code tweaks. git-svn-id: svn://localhost/HandBrake/trunk@2306 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/frmAddPreset.cs | 6 +-- win/C#/frmMain.Designer.cs | 116 +++++++++++++++++++++++---------------------- win/C#/frmMain.cs | 82 ++++++++++++++++++++------------ 3 files changed, 114 insertions(+), 90 deletions(-) diff --git a/win/C#/frmAddPreset.cs b/win/C#/frmAddPreset.cs index 00b288cb..56bc5f5c 100644 --- a/win/C#/frmAddPreset.cs +++ b/win/C#/frmAddPreset.cs @@ -11,9 +11,9 @@ namespace Handbrake { public partial class frmAddPreset : Form { - private frmMain frmMainWindow; - Presets.PresetsHandler presetCode; - private string query = ""; + private readonly frmMain frmMainWindow; + readonly Presets.PresetsHandler presetCode; + private readonly string query = ""; public frmAddPreset(frmMain fmw, string query_string, Presets.PresetsHandler presetHandler) { diff --git a/win/C#/frmMain.Designer.cs b/win/C#/frmMain.Designer.cs index c14091da..6db93aac 100644 --- a/win/C#/frmMain.Designer.cs +++ b/win/C#/frmMain.Designer.cs @@ -4,6 +4,9 @@ Homepage: . It may be used under the terms of the GNU General Public License. */ +using System; +using System.Windows.Forms; + namespace Handbrake { partial class frmMain @@ -180,14 +183,9 @@ namespace Handbrake 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.ctl_deinterlace = new Handbrake.Deinterlace(); - this.ctl_denoise = new Handbrake.Denoise(); - this.ctl_decomb = new Handbrake.Decomb(); - this.ctl_detelecine = new Handbrake.Detelecine(); this.tab_chapters = new System.Windows.Forms.TabPage(); this.label31 = new System.Windows.Forms.Label(); this.h264Tab = 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(); @@ -221,6 +219,11 @@ namespace Handbrake this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components); this.StatusStrip = new System.Windows.Forms.StatusStrip(); this.lbl_encode = new System.Windows.Forms.ToolStripStatusLabel(); + this.ctl_deinterlace = new Handbrake.Deinterlace(); + this.ctl_denoise = new Handbrake.Denoise(); + this.ctl_decomb = new Handbrake.Decomb(); + this.ctl_detelecine = new Handbrake.Detelecine(); + this.x264Panel = new Handbrake.Controls.x264Panel(); notifyIconMenu = new System.Windows.Forms.ContextMenuStrip(this.components); notifyIconMenu.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.slider_videoQuality)).BeginInit(); @@ -1871,48 +1874,6 @@ namespace Handbrake this.tab_Filters.Text = "Video Filters"; this.tab_Filters.UseVisualStyleBackColor = true; // - // ctl_deinterlace - // - this.ctl_deinterlace.AutoSize = true; - this.ctl_deinterlace.Location = new System.Drawing.Point(19, 95); - this.ctl_deinterlace.Margin = new System.Windows.Forms.Padding(0); - this.ctl_deinterlace.MaximumSize = new System.Drawing.Size(400, 30); - this.ctl_deinterlace.Name = "ctl_deinterlace"; - this.ctl_deinterlace.Size = new System.Drawing.Size(275, 28); - this.ctl_deinterlace.TabIndex = 41; - this.ctl_deinterlace.onChange += new System.EventHandler(this.ctl_deinterlace_changed); - // - // ctl_denoise - // - this.ctl_denoise.AutoSize = true; - this.ctl_denoise.Location = new System.Drawing.Point(19, 123); - this.ctl_denoise.Margin = new System.Windows.Forms.Padding(0); - this.ctl_denoise.MaximumSize = new System.Drawing.Size(400, 30); - this.ctl_denoise.Name = "ctl_denoise"; - this.ctl_denoise.Size = new System.Drawing.Size(275, 28); - this.ctl_denoise.TabIndex = 40; - // - // ctl_decomb - // - this.ctl_decomb.AutoSize = true; - this.ctl_decomb.Location = new System.Drawing.Point(19, 66); - this.ctl_decomb.Margin = new System.Windows.Forms.Padding(0); - this.ctl_decomb.MaximumSize = new System.Drawing.Size(400, 30); - this.ctl_decomb.Name = "ctl_decomb"; - this.ctl_decomb.Size = new System.Drawing.Size(275, 28); - this.ctl_decomb.TabIndex = 39; - this.ctl_decomb.onChange += new System.EventHandler(this.ctl_decomb_changed); - // - // ctl_detelecine - // - this.ctl_detelecine.AutoSize = true; - this.ctl_detelecine.Location = new System.Drawing.Point(19, 38); - this.ctl_detelecine.Margin = new System.Windows.Forms.Padding(0); - this.ctl_detelecine.MaximumSize = new System.Drawing.Size(400, 30); - this.ctl_detelecine.Name = "ctl_detelecine"; - this.ctl_detelecine.Size = new System.Drawing.Size(275, 28); - this.ctl_detelecine.TabIndex = 38; - // // tab_chapters // this.tab_chapters.BackColor = System.Drawing.Color.Transparent; @@ -1950,14 +1911,6 @@ namespace Handbrake this.h264Tab.Text = "Advanced"; this.h264Tab.UseVisualStyleBackColor = true; // - // x264Panel - // - 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); @@ -2306,8 +2259,59 @@ namespace Handbrake this.lbl_encode.Size = new System.Drawing.Size(31, 17); this.lbl_encode.Text = "{0}"; // + // ctl_deinterlace + // + this.ctl_deinterlace.AutoSize = true; + this.ctl_deinterlace.Location = new System.Drawing.Point(19, 95); + this.ctl_deinterlace.Margin = new System.Windows.Forms.Padding(0); + this.ctl_deinterlace.MaximumSize = new System.Drawing.Size(400, 30); + this.ctl_deinterlace.Name = "ctl_deinterlace"; + this.ctl_deinterlace.Size = new System.Drawing.Size(275, 28); + this.ctl_deinterlace.TabIndex = 41; + this.ctl_deinterlace.onChange += new System.EventHandler(this.ctl_deinterlace_changed); + // + // ctl_denoise + // + this.ctl_denoise.AutoSize = true; + this.ctl_denoise.Location = new System.Drawing.Point(19, 123); + this.ctl_denoise.Margin = new System.Windows.Forms.Padding(0); + this.ctl_denoise.MaximumSize = new System.Drawing.Size(400, 30); + this.ctl_denoise.Name = "ctl_denoise"; + this.ctl_denoise.Size = new System.Drawing.Size(275, 28); + this.ctl_denoise.TabIndex = 40; + // + // ctl_decomb + // + this.ctl_decomb.AutoSize = true; + this.ctl_decomb.Location = new System.Drawing.Point(19, 66); + this.ctl_decomb.Margin = new System.Windows.Forms.Padding(0); + this.ctl_decomb.MaximumSize = new System.Drawing.Size(400, 30); + this.ctl_decomb.Name = "ctl_decomb"; + this.ctl_decomb.Size = new System.Drawing.Size(275, 28); + this.ctl_decomb.TabIndex = 39; + this.ctl_decomb.onChange += new System.EventHandler(this.ctl_decomb_changed); + // + // ctl_detelecine + // + this.ctl_detelecine.AutoSize = true; + this.ctl_detelecine.Location = new System.Drawing.Point(19, 38); + this.ctl_detelecine.Margin = new System.Windows.Forms.Padding(0); + this.ctl_detelecine.MaximumSize = new System.Drawing.Size(400, 30); + this.ctl_detelecine.Name = "ctl_detelecine"; + this.ctl_detelecine.Size = new System.Drawing.Size(275, 28); + this.ctl_detelecine.TabIndex = 38; + // + // x264Panel + // + 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; this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScroll = true; @@ -2556,6 +2560,6 @@ namespace Handbrake private System.Windows.Forms.Label lbl_max; private System.Windows.Forms.DataGridViewTextBoxColumn number; private System.Windows.Forms.DataGridViewTextBoxColumn name; - + } } \ No newline at end of file diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index fc6f98cf..c8bc46ea 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -13,6 +13,7 @@ using System.IO; using System.Diagnostics; using System.Threading; using Handbrake.Functions; +using Handbrake.Presets; namespace Handbrake { @@ -23,7 +24,7 @@ namespace Handbrake Main hb_common_func = new Main(); Encode encodeHandler = new Encode(); Queue.QueueHandler encodeQueue = new Queue.QueueHandler(); - Presets.PresetsHandler presetHandler = new Presets.PresetsHandler(); + PresetsHandler presetHandler = new PresetsHandler(); Parsing.Title selectedTitle; Parsing.DVD thisDVD; @@ -50,9 +51,7 @@ namespace Handbrake splash.Show(); //Create a label that can be updated from the parent thread. - Label lblStatus = new Label(); - lblStatus.Size = new Size(250, 20); - lblStatus.Location = new Point(10, 280); + Label lblStatus = new Label {Size = new Size(250, 20), Location = new Point(10, 280)}; splash.Controls.Add(lblStatus); InitializeComponent(); @@ -84,6 +83,7 @@ namespace Handbrake loadPresetPanel(); // Load the Preset Panel treeView_presets.ExpandAll(); lbl_encode.Text = ""; + lbl_max.Text = ""; queueWindow = new frmQueue(encodeQueue); // Prepare the Queue if (Properties.Settings.Default.QueryEditorTab != "Checked") tabs_panel.TabPages.RemoveAt(5); // Remove the query editor tab if the user does not want it enabled. @@ -186,10 +186,39 @@ namespace Handbrake if (Properties.Settings.Default.MainWindowMinimize == "Checked") this.Resize += new EventHandler(frmMain_Resize); - // Handle Encode Start + // Handle Encode Start / Finish / Pause encodeQueue.OnEncodeEnded += new EventHandler(encodeEnded); encodeQueue.OnPaused += new EventHandler(encodePaused); encodeQueue.OnEncodeStart += new EventHandler(encodeStarted); + + // Handle a file being draged onto the GUI. + this.DragEnter += new DragEventHandler(frmMain_DragEnter); + this.DragDrop += new DragEventHandler(frmMain_DragDrop); + } + + private static void frmMain_DragEnter(object sender, DragEventArgs e) + { + if (e.Data.GetDataPresent(DataFormats.FileDrop, false)) + e.Effect = DragDropEffects.All; + } + private void frmMain_DragDrop(object sender, DragEventArgs e) + { + string[] fileList = e.Data.GetData(DataFormats.FileDrop) as string[]; + if (fileList != null) + { + if (fileList[0].StartsWith("\\")) + MessageBox.Show("Sorry, HandBrake does not support UNC file paths. \nTry mounting the share as a network drive in My Computer", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); + else + { + if (fileList[0] != "") + { + setupGUIforScan(fileList[0]); + startScan(fileList[0]); + } + else + text_source.Text = "Click 'Source' to continue"; + } + } } private void encodeStarted(object sender, EventArgs e) { @@ -227,10 +256,7 @@ namespace Handbrake private void mnu_encodeLog_Click(object sender, EventArgs e) { String file; - if (lastAction == "scan") - file = "dvdinfo.dat"; - else - file = "hb_encode_log.dat"; + file = lastAction == "scan" ? "dvdinfo.dat" : "hb_encode_log.dat"; frmActivityWindow dvdInfoWindow = new frmActivityWindow(file, encodeHandler); dvdInfoWindow.Show(); @@ -309,7 +335,7 @@ namespace Handbrake private void mnu_UpdateCheck_Click(object sender, EventArgs e) { Boolean update = hb_common_func.updateCheck(true); - if (update == true) + if (update) { frmUpdater updateWindow = new frmUpdater(); updateWindow.Show(); @@ -467,7 +493,7 @@ namespace Handbrake x264Panel.reset2Defaults(); // Send the query from the file to the Query Parser class - Functions.QueryParser presetQuery = QueryParser.Parse(query); + QueryParser presetQuery = QueryParser.Parse(query); // Now load the preset presetLoader.presetLoader(this, presetQuery, presetName, loadPictureSettings); @@ -1599,8 +1625,8 @@ namespace Handbrake string strCmdLine = String.Format(@"cmd /c """"{0}"" -i ""{1}"" -t0 -v >""{2}"" 2>&1""", handbrakeCLIPath, inputFile, dvdInfoPath); - ProcessStartInfo hbParseDvd = new ProcessStartInfo("CMD.exe", strCmdLine); - hbParseDvd.WindowStyle = ProcessWindowStyle.Hidden; + ProcessStartInfo hbParseDvd = new ProcessStartInfo("CMD.exe", strCmdLine) + {WindowStyle = ProcessWindowStyle.Hidden}; using (hbproc = Process.Start(hbParseDvd)) { @@ -1707,8 +1733,8 @@ namespace Handbrake AppName = AppName.ToUpper(); - System.Diagnostics.Process[] prs = Process.GetProcesses(); - foreach (System.Diagnostics.Process proces in prs) + Process[] prs = Process.GetProcesses(); + foreach (Process proces in prs) { if (proces.ProcessName.ToUpper() == AppName) { @@ -1869,7 +1895,7 @@ namespace Handbrake drp_videoEncoder.Text = oldval; } } - private void setBitrateSelections384(ComboBox dropDown) + private static void setBitrateSelections384(ComboBox dropDown) { dropDown.Items.Clear(); dropDown.Items.Add("32"); @@ -1888,7 +1914,7 @@ namespace Handbrake dropDown.Items.Add("320"); dropDown.Items.Add("384"); } - private void setBitrateSelections320(ComboBox dropDown) + private static void setBitrateSelections320(ComboBox dropDown) { dropDown.Items.Clear(); dropDown.Items.Add("32"); @@ -1906,7 +1932,7 @@ namespace Handbrake dropDown.Items.Add("256"); dropDown.Items.Add("320"); } - private void setBitrateSelections160(ComboBox dropDown) + private static void setBitrateSelections160(ComboBox dropDown) { dropDown.Items.Clear(); dropDown.Items.Add("32"); @@ -1920,7 +1946,7 @@ namespace Handbrake dropDown.Items.Add("128"); dropDown.Items.Add("160"); } - private void setMixDownAllOptions(ComboBox dropdown) + private static void setMixDownAllOptions(ComboBox dropdown) { dropdown.Items.Clear(); dropdown.Items.Add("Automatic"); @@ -1930,7 +1956,7 @@ namespace Handbrake dropdown.Items.Add("Dolby Pro Logic II"); dropdown.Items.Add("6 Channel Discrete"); } - private void setMixDownNotAAC(ComboBox dropdown) + private static void setMixDownNotAAC(ComboBox dropdown) { dropdown.Items.Clear(); dropdown.Items.Add("Automatic"); @@ -2022,24 +2048,19 @@ namespace Handbrake public void loadPresetPanel() { presetHandler.loadPresetData(); - treeView_presets.Nodes.Clear(); - List presetNameList; - List presetNames; TreeNode preset_treeview; - TreeNode rootNode = new TreeNode(); TreeNode rootNodeTwo = new TreeNode(); TreeNode childNode; int workingLevel = 0; - string previousCategory = String.Empty; - string currentCategory = String.Empty; + string previousCategory = String.Empty, currentCategory = String.Empty; - presetNameList = presetHandler.getBuildInPresets(); + List presetNameList = presetHandler.getBuildInPresets(); if (presetNameList.Count != 0) { - foreach (Presets.Preset preset in presetNameList) + foreach (Preset preset in presetNameList) { // Handle Root Nodes @@ -2100,11 +2121,10 @@ namespace Handbrake } // User Presets - presetNames = presetHandler.getUserPresetNames(); + List presetNames = presetHandler.getUserPresetNames(); foreach (string preset in presetNames) { - preset_treeview = new TreeNode(preset); - preset_treeview.ForeColor = Color.Black; + preset_treeview = new TreeNode(preset) {ForeColor = Color.Black}; // Now Fill Out List View with Items treeView_presets.Nodes.Add(preset_treeview); -- 2.11.0