Пример #1
0
        public static void Main(string[] args)
        {
            if (Environment.OSVersion.Platform != PlatformID.Win32NT)
            {
                MessageBox.Show(Properties.Resources.MessageApplicationCannotRun, GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            Settings settings = new Settings();

            if (!settings.DisableThemes)
            {
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                settings.RenderWithVisualStyles = Application.RenderWithVisualStyles;
            }
            ArgumentParser argumentParser = new ArgumentParser();

            try {
                argumentParser.Arguments = args;
            } catch (Exception exception) {
                Debug.WriteLine(exception);
                ErrorLog.WriteLine(exception);
                MessageBox.Show(exception.Message, GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            if (argumentParser.HasArguments)
            {
                if (argumentParser.IsHelp)
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine1.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine2.Replace("\\t", "\t"));
                    stringBuilder.AppendLine(Properties.Resources.HelpLine3.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine4.Replace("\\t", "\t"));
                    stringBuilder.AppendLine(Properties.Resources.HelpLine5.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine6.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine7.Replace("\\t", "\t"));
                    stringBuilder.AppendLine(Properties.Resources.HelpLine8.Replace("\\t", "\t"));
                    stringBuilder.AppendLine(Properties.Resources.HelpLine9.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine10.Replace("\\t", "\t")).AppendLine();
                    stringBuilder.AppendLine(Properties.Resources.HelpLine11.Replace("\\t", "\t"));
                    MessageBox.Show(stringBuilder.ToString(), GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionHelp, MessageBoxButtons.OK, MessageBoxIcon.Question);
                }
                else if (argumentParser.IsThisTest)
                {
                    try {
                        Application.Run(new ArgumentParserForm());
                    } catch (Exception exception) {
                        Debug.WriteLine(exception);
                        ErrorLog.WriteLine(exception);
                        MessageBox.Show(exception.Message, GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        MessageBox.Show(Properties.Resources.MessageApplicationError, GetTitle(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    try {
                        LauncherAsRegistry launcherAsRegistry = new LauncherAsRegistry()
                        {
                            ApplicationFilePath = argumentParser.ApplicationFilePath,
                            Arguments           = argumentParser.ApplicationArguments,
                            WorkingFolderPath   = argumentParser.WorkingFolderPath,
                            OneInstance         = argumentParser.OneInstance,
                            RegFilePath         = argumentParser.RegFilePath
                        };
                        launcherAsRegistry.Launch();
                    } catch (Exception exception) {
                        Debug.WriteLine(exception);
                        ErrorLog.WriteLine(exception);
                        MessageBox.Show(exception.Message, GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                }
            }
            else
            {
                try {
                    SingleMainForm.Run(new MainForm(settings));
                } catch (Exception exception) {
                    Debug.WriteLine(exception);
                    ErrorLog.WriteLine(exception);
                    MessageBox.Show(exception.Message, GetTitle() + Constants.Space + Constants.EnDash + Constants.Space + Properties.Resources.CaptionError, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    MessageBox.Show(Properties.Resources.MessageApplicationError, GetTitle(), MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
        }