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
10 using System.Drawing;
\r
12 using System.Windows.Forms;
\r
14 using HandBrake.ApplicationServices;
\r
16 using Handbrake.Presets;
\r
17 using Handbrake.Properties;
\r
20 /// HandBrake Starts Here
\r
22 public static class Program
\r
25 /// The main entry point for the application.
\r
27 /// <param name="args">
\r
31 public static void Main(string[] args)
\r
33 InstanceId = Process.GetProcessesByName("HandBrake").Length;
\r
35 // Handle any unhandled exceptions
\r
36 AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomainUnhandledException);
\r
38 // Attempt to upgrade / keep the users settings between versions
\r
39 if (Settings.Default.UpdateRequired)
\r
41 Settings.Default.Upgrade();
\r
42 Settings.Default.UpdateRequired = false;
\r
43 Functions.Main.SetCliVersionData();
\r
46 // Make sure we have any pre-requesits before trying to launch
\r
47 string failedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n";
\r
48 string missingFiles = string.Empty;
\r
50 // Verify HandBrakeCLI.exe exists
\r
51 if (!File.Exists(Path.Combine(Application.StartupPath, "HandBrakeCLI.exe")))
\r
53 missingFiles += "\"HandBrakeCLI.exe\" was not found.";
\r
56 if (missingFiles != string.Empty)
\r
59 failedInstall + missingFiles,
\r
61 MessageBoxButtons.OK,
\r
62 MessageBoxIcon.Error);
\r
66 // Check were not running on a screen that's going to cause some funnies to happen.
\r
67 Screen scr = Screen.PrimaryScreen;
\r
68 if ((scr.Bounds.Width < 1024) || (scr.Bounds.Height < 620))
\r
71 "Your system does not meet the minimum requirements for HandBrake. \n" +
\r
72 "Your screen is running at: " + scr.Bounds.Width + "x" + scr.Bounds.Height +
\r
73 " \nScreen resolution is too Low. Must be 1024x620 or greater.\n\n",
\r
75 MessageBoxButtons.OK,
\r
76 MessageBoxIcon.Error);
\r
80 string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\logs");
\r
81 if (!Directory.Exists(logDir))
\r
82 Directory.CreateDirectory(logDir);
\r
84 if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\presets.xml")))
\r
86 PresetsHandler x = new PresetsHandler();
\r
87 x.UpdateBuiltInPresets();
\r
90 InitializeApplicationServices();
\r
92 Application.EnableVisualStyles();
\r
93 Application.SetCompatibleTextRenderingDefault(false);
\r
94 Application.Run(new frmMain(args));
\r
99 /// Initialize App Services
\r
101 private static void InitializeApplicationServices()
\r
103 string versionId = String.Format("Windows GUI {1} {0}", Settings.Default.hb_build, Settings.Default.hb_version);
\r
104 Init.SetupSettings(versionId, InstanceId, Settings.Default.CompletionOption, Settings.Default.noDvdNav,
\r
105 Settings.Default.growlEncode, Settings.Default.growlQueue,
\r
106 Settings.Default.processPriority, Settings.Default.saveLogPath, Settings.Default.saveLogToSpecifiedPath,
\r
107 Settings.Default.saveLogWithVideo, Settings.Default.showCliForInGuiEncodeStatus, Settings.Default.preventSleep);
\r
111 /// Throw up an error message for any unhandled exceptions.
\r
113 /// <param name="sender">The sender</param>
\r
114 /// <param name="e">Unhandled Exception EventArgs </param>
\r
115 private static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e)
\r
118 "An Unknown Error has occured. \n\n Exception:" + e.ExceptionObject,
\r
119 "Unhandled Exception",
\r
120 MessageBoxButtons.OK,
\r
121 MessageBoxIcon.Error);
\r
124 public static int InstanceId;
\r