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
9 using System.Diagnostics;
\r
11 using System.Windows.Forms;
\r
13 using HandBrake.ApplicationServices;
\r
15 using Handbrake.Presets;
\r
16 using Handbrake.Properties;
\r
19 /// HandBrake Starts Here
\r
21 public static class Program
\r
24 /// The main entry point for the application.
\r
26 /// <param name="args">
\r
30 public static void Main(string[] args)
\r
32 InstanceId = Process.GetProcessesByName("HandBrake").Length;
\r
34 // Handle any unhandled exceptions
\r
35 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
\r
37 // Attempt to upgrade / keep the users settings between versions
\r
38 if (Settings.Default.UpdateRequired)
\r
40 Settings.Default.Upgrade();
\r
41 Settings.Default.UpdateRequired = false;
\r
44 // Make sure we have any pre-requesits before trying to launch
\r
45 const string FailedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n";
\r
46 const string NightlyCLIMissing =
\r
47 "If you have downloaded the \"HandBrakeGUI\" nightly, " +
\r
48 "please make sure you have also downloaded the \"HandBrakeCLI\" nightly and extracted it's contents to the same folder. ";
\r
49 string missingFiles = string.Empty;
\r
51 // Verify HandBrakeCLI.exe exists
\r
52 if (!File.Exists(Path.Combine(Application.StartupPath, "HandBrakeCLI.exe")))
\r
54 missingFiles += "\"HandBrakeCLI.exe\" was not found.";
\r
57 if (missingFiles != string.Empty)
\r
60 FailedInstall + missingFiles + "\n\n" + NightlyCLIMissing,
\r
62 MessageBoxButtons.OK,
\r
63 MessageBoxIcon.Error);
\r
67 // Check were not running on a screen that's going to cause some funnies to happen.
\r
68 Screen scr = Screen.PrimaryScreen;
\r
69 if ((scr.Bounds.Width < 1024) || (scr.Bounds.Height < 620))
\r
70 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
73 string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\logs");
\r
74 if (!Directory.Exists(logDir))
\r
75 Directory.CreateDirectory(logDir);
\r
77 if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\presets.xml")))
\r
79 PresetsHandler x = new PresetsHandler();
\r
80 x.UpdateBuiltInPresets();
\r
83 InitializeApplicationServices();
\r
85 Application.EnableVisualStyles();
\r
86 Application.SetCompatibleTextRenderingDefault(false);
\r
87 Application.Run(new frmMain(args));
\r
92 /// Initialize App Services
\r
94 private static void InitializeApplicationServices()
\r
96 string versionId = String.Format("Windows GUI {1} {0}", Settings.Default.hb_build, Settings.Default.hb_version);
\r
97 Init.SetupSettings(versionId, InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,
\r
98 Settings.Default.growlEncode, Settings.Default.growlQueue,
\r
99 Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath,
\r
100 Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep);
\r
104 /// Throw up an error message for any unhandled exceptions.
\r
106 /// <param name="sender">The sender</param>
\r
107 /// <param name="e">Unhandled Exception EventArgs </param>
\r
108 private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
\r
112 frmExceptionWindow exceptionWindow = new frmExceptionWindow();
\r
113 exceptionWindow.Setup("An Unknown Error has occured.", e.ExceptionObject.ToString());
\r
114 exceptionWindow.ShowDialog();
\r
119 "An Unknown Error has occured. \n\n Exception:" + e.ExceptionObject,
\r
120 "Unhandled Exception",
\r
121 MessageBoxButtons.OK,
\r
122 MessageBoxIcon.Error);
\r
126 public static int InstanceId;
\r