From 88852f68bec4320200a1c96a70f4a74d2c27045a Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 25 Jun 2010 19:46:38 +0000 Subject: [PATCH] WinGui: - Allow files to be dropped on the GUI executable. (Including shortcuts). This will automatically try to scan the file. Users can add their own registry entries to add an "open with" if they choose. - Fixed an exception that occurs when a scanned file returns no titles. - Fixed an issue where pressing "No" to the on close warning (when encodes are running) would cancel the encode anyway. git-svn-id: svn://localhost/HandBrake/trunk@3405 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- win/C#/Program.cs | 4 ++-- win/C#/frmMain.cs | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 13 deletions(-) diff --git a/win/C#/Program.cs b/win/C#/Program.cs index d5da8f2d..19f5fb2c 100644 --- a/win/C#/Program.cs +++ b/win/C#/Program.cs @@ -24,7 +24,7 @@ namespace Handbrake /// The main entry point for the application. /// [STAThread] - public static void Main() + public static void Main(string[] args) { // Handle any unhandled exceptions AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); @@ -79,7 +79,7 @@ namespace Handbrake Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - Application.Run(new frmMain()); + Application.Run(new frmMain(args)); } } diff --git a/win/C#/frmMain.cs b/win/C#/frmMain.cs index 713ca101..1a7590b5 100644 --- a/win/C#/frmMain.cs +++ b/win/C#/frmMain.cs @@ -79,7 +79,13 @@ namespace Handbrake #region Application Startup - public frmMain() + /// + /// Initializes a new instance of the class. + /// + /// + /// The arguments passed in on application startup. + /// + public frmMain(string[] args) { // Load and setup the splash screen in this thread splash.Show(this); @@ -168,6 +174,12 @@ namespace Handbrake // Event Handlers and Queue Recovery events(); queueRecovery(); + + // If have a file passed in via command arguemtents, check it's a file and try scanning it. + if (args.Length >= 1 && File.Exists(args[0])) + { + this.StartScan(args[0], 0); + } } private void UpdateCheckDone(IAsyncResult result) @@ -2046,17 +2058,19 @@ namespace Handbrake drp_dvdtitle.SelectedIndex = 0; } - // Enable the creation of chapter markers if the file is an image of a dvd. - int start, end; - int.TryParse(drop_chapterStart.Items[0].ToString(), out start); - int.TryParse(drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString(), out end); - if (end > start) - Check_ChapterMarkers.Enabled = true; - else + // Enable the creation of chapter markers if the file is an image of a dvd + if (drop_chapterStart.Items.Count > 0) { - Check_ChapterMarkers.Enabled = false; - Check_ChapterMarkers.Checked = false; - data_chpt.Rows.Clear(); + int start, end; + int.TryParse(drop_chapterStart.Items[0].ToString(), out start); + int.TryParse(drop_chapterFinish.Items[drop_chapterFinish.Items.Count - 1].ToString(), out end); + if (end > start) Check_ChapterMarkers.Enabled = true; + else + { + Check_ChapterMarkers.Enabled = false; + Check_ChapterMarkers.Checked = false; + data_chpt.Rows.Clear(); + } } // If no titles were found, Display an error message @@ -2440,7 +2454,10 @@ namespace Handbrake "Close HandBrake?", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (result == DialogResult.No) + { e.Cancel = true; + return; + } // Try to safely close out if we can, or kill the cli if using in-gui status if (Settings.Default.enocdeStatusInGui) -- 2.11.0