コード例 #1
0
ファイル: Program.cs プロジェクト: hamstah/geogen
        static void Main(string[] args)
        {
#if DEBUG
#else
            // we will be catching "uncaught exception" and show them in some nice fashion
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
            Application.ThreadException += UncaughtExceptionHandler;
            AppDomain.CurrentDomain.UnhandledException += delegate(object o, UnhandledExceptionEventArgs a){
                Program.UncaughtExceptionHandler(null, new System.Threading.ThreadExceptionEventArgs(a.ExceptionObject as Exception));
            };
#endif
            Main main = null;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            main = new Main();

            if(args.Length > 0){
                try{
                    if(System.IO.File.Exists(args[0])){
                        main.fileFromShell = args[0];
                    }
                }
                catch{}
            }

            

            // use local config if possible, use my documents config otherwise
            if (
                System.Reflection.Assembly.GetExecutingAssembly().Location.Contains(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFilesX86)) ||
                System.Reflection.Assembly.GetExecutingAssembly().Location.Contains(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)) || 
                (!File.Exists(Program.BasePath + "config/studio.xml") && Directory.Exists(Program.AlternateBasePath)))
            {
                Program.BasePath = Program.AlternateBasePath;
            }


                // emergency save will be done by the UncaughtExceptionHandler in release mode
#if DEBUG 
                System.IO.File.WriteAllText("../emergencyBackup.nut", main.editorBackup);    
#endif

                Application.Run(main);
        }