示例#1
0
        public void Start()
        {
            string str2;
            string str3;
            int    num;

            try
            {
                string path = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "paint.net"), "Optimization");
                Directory.CreateDirectory(path);
                string profile = ((this.args != null) && (this.args.Length >= 1)) ? "Startup.1.profile" : "Startup.0.profile";
                ProfileOptimization.SetProfileRoot(path);
                ProfileOptimization.StartProfile(profile);
            }
            catch (Exception)
            {
            }
            try
            {
                new Uri(Environment.GetEnvironmentVariable("windir"), UriKind.Absolute);
            }
            catch (Exception exception)
            {
                if (!(exception is UriFormatException) && !(exception is ArgumentNullException))
                {
                    throw;
                }
                string environmentVariable = Environment.GetEnvironmentVariable("systemroot");
                Environment.SetEnvironmentVariable("windir", environmentVariable);
            }
            string sxsRootDirPath = Path.Combine(Application.StartupPath, "SxS");

            ShellUtil.LoadUniversalCrt(sxsRootDirPath);
            ShellUtil.LoadVisualCppRuntime(sxsRootDirPath);
            ShellUtil.LoadOpenMP(sxsRootDirPath);
            Control.CheckForIllegalCrossThreadCalls = true;
            Application.SetCompatibleTextRenderingDefault(false);
            Application.EnableVisualStyles();
            Processor.LockLogicalCpuCount();
            string[] args = TryRemoveArg(this.args, "/sleep=", out str2);
            if (!string.IsNullOrWhiteSpace(str2) && int.TryParse(str2, out num))
            {
                Thread.Sleep(num);
            }
            args = TryRemoveArg(args, "/skipRepairAttempt", out str3);
            if ((str3 == null) && this.CheckForImportantFiles())
            {
                StartNewInstance(null, false, args);
            }
            else
            {
                string str4;
                args = TryRemoveArg(args, "/mutexName=", out str4);
                string mutexName = string.IsNullOrWhiteSpace(str4) ? "PaintDotNet" : str4;
                this.StartPart2(mutexName, args);
            }
        }