OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / Program.cs
1 /*  Program.cs\r
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
5 \r
6 namespace Handbrake\r
7 {\r
8     using System;\r
9     using System.IO;\r
10     using System.Windows.Forms;\r
11     using Presets;\r
12 \r
13     /// <summary>\r
14     /// HandBrake Starts Here\r
15     /// </summary>\r
16     public static class Program\r
17     {\r
18         /// <summary>\r
19         /// The main entry point for the application.\r
20         /// </summary>\r
21         [STAThread]\r
22         public static void Main()\r
23         {\r
24             const string failedInstall = "HandBrake is not installed properly. Please reinstall HandBrake. \n\n";\r
25             const string nightlyCLIMissing =\r
26                 "If you have downloaded the \"HandBrakeGUI\" nightly, " +\r
27                 "please make sure you have also downloaded the \"HandBrakeCLI\" nightly and extracted it's contents to the same folder. ";\r
28             string missingFiles = string.Empty;\r
29 \r
30             // Verify HandBrakeCLI.exe and ilibgcc_s_sjlj-1.dll exists\r
31             if (!File.Exists(Path.Combine(Application.StartupPath, "HandBrakeCLI.exe")))\r
32             {\r
33                 missingFiles += "\"HandBrakeCLI.exe\" was not found.";\r
34             }\r
35 \r
36             if (missingFiles != string.Empty)\r
37             {\r
38                 MessageBox.Show(failedInstall + missingFiles + "\n\n"+ nightlyCLIMissing, "Error", MessageBoxButtons.OK,\r
39                                 MessageBoxIcon.Error);\r
40                 return;\r
41             }\r
42 \r
43             // Check were not running on a screen that's going to cause some funnies to happen.\r
44             Screen scr = Screen.PrimaryScreen;\r
45             if ((scr.Bounds.Width < 1024) || (scr.Bounds.Height < 620))\r
46                 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
47             else\r
48             {\r
49                 string logDir = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\logs");\r
50                 if (!Directory.Exists(logDir))\r
51                     Directory.CreateDirectory(logDir);\r
52 \r
53                 if (!File.Exists(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\presets.xml")))\r
54                 {\r
55                     PresetsHandler x = new PresetsHandler();\r
56                     x.UpdateBuiltInPresets();\r
57                 }\r
58 \r
59                 Application.EnableVisualStyles();\r
60                 Application.SetCompatibleTextRenderingDefault(false);\r
61                 Application.Run(new frmMain());\r
62             }\r
63         }\r
64     }\r
65 }