예제 #1
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // command line arguments that we can call when we temporarily elevate the process
            if(args.Contains("--registerRDCext"))
            {
                Helpers.InstallRDCAssociation();
                return;
            }

            if(args.Contains("--registerCAPext"))
            {
                Helpers.InstallCAPAssociation();
                return;
            }

            Win32PInvoke.LoadLibrary("renderdoc.dll");

            string filename = "";

            bool temp = false;

            // not real command line argument processing, but allow an argument to indicate we're being passed
            // a temporary filename that we should take ownership of to delete when we're done (if the user doesn't
            // save it)
            foreach(var a in args)
            {
                if(a.ToLowerInvariant() == "--tempfile")
                    temp = true;
            }

            string remoteHost = "";
            uint remoteIdent = 0;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].ToLowerInvariant() == "--remoteaccess" && i + 1 < args.Length)
                {
                    var regexp = @"^([a-zA-Z0-9_-]+:)?([0-9]+)$";

                    var match = Regex.Match(args[i+1], regexp);

                    if (match.Success)
                    {
                        var host = match.Groups[1].Value;
                        if (host != "" && host[host.Length - 1] == ':')
                            host = host.Substring(0, host.Length - 1);
                        uint ident = 0;
                        if (uint.TryParse(match.Groups[2].Value, out ident))
                        {
                            remoteHost = host;
                            remoteIdent = ident;
                        }
                    }
                }
            }

            if (args.Length > 0 && File.Exists(args[args.Length - 1]))
            {
                filename = args[args.Length - 1];
            }

            var cfg = new PersistantConfig();

            // load up the config from user folder, handling errors if it's malformed and falling back to defaults
            if (File.Exists(Core.ConfigFilename))
            {
                try
                {
                    cfg = PersistantConfig.Deserialize(Core.ConfigFilename);
                }
                catch (System.Xml.XmlException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.InvalidOperationException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.IO.IOException ex)
                {
                    MessageBox.Show(String.Format("Error loading config file: {1}\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename, ex.Message));
                }
            }

            // propogate float formatting settings to the Formatter class used globally to format float values
            cfg.SetupFormatter();

            Application.CurrentCulture = new System.Globalization.CultureInfo("en-GB");

            var core = new Core(filename, remoteHost, remoteIdent, temp, cfg);

            try
            {
                Application.Run(core.AppWindow);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            cfg.Serialize(Core.ConfigFilename);
        }
예제 #2
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // command line arguments that we can call when we temporarily elevate the process
            if (args.Contains("--registerRDCext"))
            {
                Helpers.InstallRDCAssociation();
                return;
            }

            if (args.Contains("--registerCAPext"))
            {
                Helpers.InstallCAPAssociation();
                return;
            }

            Win32PInvoke.LoadLibrary("renderdoc.dll");

            string filename = "";

            bool temp = false;

            // not real command line argument processing, but allow an argument to indicate we're being passed
            // a temporary filename that we should take ownership of to delete when we're done (if the user doesn't
            // save it)
            foreach (var a in args)
            {
                if (a.ToLowerInvariant() == "--tempfile")
                {
                    temp = true;
                }
            }

            if (args.Length > 0 && File.Exists(args[args.Length - 1]))
            {
                filename = args[args.Length - 1];
            }

            var cfg = new PersistantConfig();

            // load up the config from user folder, handling errors if it's malformed and falling back to defaults
            if (File.Exists(Core.ConfigFilename))
            {
                try
                {
                    cfg = PersistantConfig.Deserialize(Core.ConfigFilename);
                }
                catch (System.Xml.XmlException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.InvalidOperationException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
            }

            // propogate float formatting settings to the Formatter class used globally to format float values
            cfg.SetupFormatter();

            var core = new Core(filename, temp, cfg);

            try
            {
                Application.Run(core.AppWindow);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            cfg.Serialize(Core.ConfigFilename);
        }
예제 #3
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // command line arguments that we can call when we temporarily elevate the process
            if (args.Contains("--registerRDCext"))
            {
                Helpers.InstallRDCAssociation();
                return;
            }

            if (args.Contains("--registerCAPext"))
            {
                Helpers.InstallCAPAssociation();
                return;
            }

            Win32PInvoke.LoadLibrary("renderdoc.dll");

            string filename = "";

            bool temp = false;

            // not real command line argument processing, but allow an argument to indicate we're being passed
            // a temporary filename that we should take ownership of to delete when we're done (if the user doesn't
            // save it)
            foreach (var a in args)
            {
                if (a.ToUpperInvariant() == "--TEMPFILE")
                {
                    temp = true;
                }
            }

            string remoteHost  = "";
            uint   remoteIdent = 0;

            for (int i = 0; i < args.Length; i++)
            {
                if (args[i].ToUpperInvariant() == "--REMOTEACCESS" && i + 1 < args.Length)
                {
                    var regexp = @"^([a-zA-Z0-9_-]+:)?([0-9]+)$";

                    var match = Regex.Match(args[i + 1], regexp);

                    if (match.Success)
                    {
                        var host = match.Groups[1].Value;
                        if (host.Length > 0 && host[host.Length - 1] == ':')
                        {
                            host = host.Substring(0, host.Length - 1);
                        }
                        uint ident = 0;
                        if (uint.TryParse(match.Groups[2].Value, out ident))
                        {
                            remoteHost  = host;
                            remoteIdent = ident;
                        }
                    }
                }
            }

            if (args.Length > 0 && File.Exists(args[args.Length - 1]))
            {
                filename = args[args.Length - 1];
            }

            var cfg = new PersistantConfig();

            // load up the config from user folder, handling errors if it's malformed and falling back to defaults
            if (File.Exists(Core.ConfigFilename))
            {
                try
                {
                    cfg = PersistantConfig.Deserialize(Core.ConfigFilename);
                }
                catch (System.Xml.XmlException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.InvalidOperationException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.IO.IOException ex)
                {
                    MessageBox.Show(String.Format("Error loading config file: {1}\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename, ex.Message));
                }
            }

            // propogate float formatting settings to the Formatter class used globally to format float values
            cfg.SetupFormatter();

            Application.CurrentCulture = new System.Globalization.CultureInfo("en-GB");

            var core = new Core(filename, remoteHost, remoteIdent, temp, cfg);

            try
            {
                Application.Run(core.AppWindow);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            cfg.Serialize(Core.ConfigFilename);
        }
예제 #4
0
파일: AppMain.cs 프로젝트: n1nj4n/renderdoc
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
            Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);

            // command line arguments that we can call when we temporarily elevate the process
            if(args.Contains("--registerRDCext"))
            {
                Helpers.InstallRDCAssociation();
                return;
            }

            if(args.Contains("--registerCAPext"))
            {
                Helpers.InstallCAPAssociation();
                return;
            }

            Win32PInvoke.LoadLibrary("renderdoc.dll");

            string filename = "";

            bool temp = false;

            // not real command line argument processing, but allow an argument to indicate we're being passed
            // a temporary filename that we should take ownership of to delete when we're done (if the user doesn't
            // save it)
            foreach(var a in args)
            {
                if(a.ToLowerInvariant() == "--tempfile")
                    temp = true;
            }

            if (args.Length > 0 && File.Exists(args[args.Length - 1]))
            {
                filename = args[args.Length - 1];
            }

            var cfg = new PersistantConfig();

            // load up the config from user folder, handling errors if it's malformed and falling back to defaults
            if (File.Exists(Core.ConfigFilename))
            {
                try
                {
                    cfg = PersistantConfig.Deserialize(Core.ConfigFilename);
                }
                catch (System.Xml.XmlException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
                catch (System.InvalidOperationException)
                {
                    MessageBox.Show(String.Format("Error loading config file\n{0}\nA default config is loaded and will be saved out.", Core.ConfigFilename));
                }
            }

            // propogate float formatting settings to the Formatter class used globally to format float values
            cfg.SetupFormatter();

            var core = new Core(filename, temp, cfg);

            try
            {
                Application.Run(core.AppWindow);
            }
            catch (Exception e)
            {
                HandleException(e);
            }

            cfg.Serialize(Core.ConfigFilename);
        }