2 This file is part of the HandBrake source code.
\r
3 Homepage: <http://handbrake.fr>.
\r
4 It may be used under the terms of the GNU General Public License. */
\r
10 using System.Windows.Forms;
\r
12 using HandBrake.ApplicationServices;
\r
14 using Handbrake.Properties;
\r
19 /// HandBrake Starts Here
\r
21 public static class Program
\r
24 /// The main entry point for the application.
\r
27 public static void Main(string[] args)
\r
29 // Handle any unhandled exceptions
\r
30 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
\r
32 // Attempt to upgrade / keep the users settings between versions
\r
33 if (Settings.Default.UpdateRequired)
\r
35 Settings.Default.Upgrade();
\r
36 Settings.Default.UpdateRequired = false;
\r
39 // Make sure we have any pre-requesits before trying to launch
\r
40 const string FailedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n";
\r
41 const string NightlyCLIMissing =
\r
42 "If you have downloaded the \"HandBrakeGUI\" nightly, " +
\r
43 "please make sure you have also downloaded the \"HandBrakeCLI\" nightly and extracted it's contents to the same folder. ";
\r
44 string missingFiles = string.Empty;
\r
46 // Verify HandBrakeCLI.exe exists
\r
47 if (!File.Exists(Path.Combine(Application.StartupPath, "HandBrakeCLI.exe")))
\r
49 missingFiles += "\"HandBrakeCLI.exe\" was not found.";
\r
52 if (missingFiles != string.Empty)
\r
55 FailedInstall + missingFiles + "\n\n" + NightlyCLIMissing,
\r
57 MessageBoxButtons.OK,
\r
58 MessageBoxIcon.Error);
\r
62 // Check were not running on a screen that's going to cause some funnies to happen.
\r
63 Screen scr = Screen.PrimaryScreen;
\r
64 if ((scr.Bounds.Width < 1024) || (scr.Bounds.Height < 620))
\r
65 MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n" + "Your screen is running at: " + scr.Bounds.Width + "x" + scr.Bounds.Height + " \nScreen resolution is too Low. Must be 1024x620 or greater", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
68 string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\logs");
\r
69 if (!Directory.Exists(logDir))
\r
70 Directory.CreateDirectory(logDir);
\r
72 if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\presets.xml")))
\r
74 PresetsHandler x = new PresetsHandler();
\r
75 x.UpdateBuiltInPresets();
\r
78 InitializeApplicationServices();
\r
80 Application.EnableVisualStyles();
\r
81 Application.SetCompatibleTextRenderingDefault(false);
\r
82 Application.Run(new frmMain(args));
\r
87 /// Initialize App Services
\r
89 private static void InitializeApplicationServices()
\r
91 Init.SetupSettings(Settings.Default.cli_minimized, Settings.Default.CompletionOption, Settings.Default.noDvdNav,
\r
92 Settings.Default.enocdeStatusInGui, Settings.Default.growlEncode, Settings.Default.growlQueue,
\r
93 Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath,
\r
94 Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep);
\r
98 /// Throw up an error message for any unhandled exceptions.
\r
100 /// <param name="sender">The sender</param>
\r
101 /// <param name="e">Unhandled Exception EventArgs </param>
\r
102 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
\r
106 frmExceptionWindow exceptionWindow = new frmExceptionWindow();
\r
107 exceptionWindow.Setup("An Unknown Error has occured.", e.ExceptionObject.ToString());
\r
108 exceptionWindow.ShowDialog();
\r
113 "An Unknown Error has occured. \n\n Exception:" + e.ExceptionObject,
\r
114 "Unhandled Exception",
\r
115 MessageBoxButtons.OK,
\r
116 MessageBoxIcon.Error);
\r