ACAT.Applications.ACATTalk.Program.Main C# (CSharp) Метод

Main() приватный метод

private Main ( String args ) : void
args String
Результат void
        public static void Main(String[] args)
        {
            // Disallow multiple instances
            if (FileUtils.IsACATRunning())
            {
                return;
            }

            Windows.TurnOffDPIAwareness();

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

            parseCommandLine(args);

            var assembly = Assembly.GetExecutingAssembly();

            // get appname and copyright information
            object[] attributes = assembly.GetCustomAttributes(typeof (AssemblyTitleAttribute), false);
            var appName = (attributes.Length != 0)
                                ? ((AssemblyTitleAttribute) attributes[0]).Title
                                : String.Empty;

            var appVersion = string.Format(Resources.Version0, assembly.GetName().Version);
            //attributes = assembly.GetCustomAttributes(typeof (AssemblyCopyrightAttribute), false);
            //var appCopyright = (attributes.Length != 0)
            //                        ? ((AssemblyCopyrightAttribute) attributes[0]).Copyright
            //                        : String.Empty;
            var appCopyright = Resources.AssemblyCopyright.Replace("\\n", Environment.NewLine);

            Log.Info("***** " + appName + ". " + appVersion + ". " + appCopyright + " *****");
            
            CoreGlobals.AppGlobalPreferences = GlobalPreferences.Load(FileUtils.GetPreferencesFileFullPath(GlobalPreferences.FileName));

            //Set the active user/profile information
            setUserName();
            setProfileName();

            //Create user and profile if they don't already exist
            if (!createUserAndProfile())
            {
                return;
            }

            if (!loadUserPreferences())
            {
                return;
            }

            Log.SetupListeners();

            Splash splash = new Splash(FileUtils.GetImagePath("SplashScreenImage.png"), appName, appVersion, appCopyright, 1000);
            splash.Show();

            Context.PreInit();
            Common.PreInit();

            Context.AppAgentMgr.EnableAppAgentContextSwitch = false;

            if (!Context.Init(Context.StartupFlags.Minimal | 
                                Context.StartupFlags.TextToSpeech | 
                                Context.StartupFlags.WordPrediction | 
                                Context.StartupFlags.AgentManager |
                                Context.StartupFlags.WindowsActivityMonitor | 
                                Context.StartupFlags.Abbreviations))
            {
                splash.Close();
                splash = null;

                TimedMessageBox.Show(Context.GetInitCompletionStatus());
                if (Context.IsInitFatal())
                {
                    return;
                }
            }

            AuditLog.Audit(new AuditEvent("Application", "start"));

            Context.ShowTalkWindowOnStartup = false;
            Context.AppAgentMgr.EnableContextualMenusForDialogs = false;
            Context.AppAgentMgr.EnableContextualMenusForMenus = false;
            Context.AppAgentMgr.DefaultAgentForContextSwitchDisable = Context.AppAgentMgr.NullAgent;

            if (splash != null)
            {
                splash.Close();
            }

            if (!Context.PostInit())
            {
                MessageBox.Show(Context.GetInitCompletionStatus(), "Initialization Error");
                return;
            }

            Common.Init();

            Context.AppWindowPosition = Windows.WindowPosition.CenterScreen;

            var formName = String.IsNullOrEmpty(_formName) ? "TalkApplicationScanner" : _formName;
            var form = PanelManager.Instance.CreatePanel(formName);
            if (form != null)
            {
                // Add ad-hoc agent that will handle the form
                IApplicationAgent agent = new TalkAppAgent();
                Context.AppAgentMgr.AddAgent(form.Handle, agent);

                Context.AppPanelManager.Show(form as IPanel);
            }
            else
            {
                MessageBox.Show("Invalid form name " + form, "Error");
                return;
            }

            try
            {
                Application.Run();

                AuditLog.Audit(new AuditEvent("Application", "stop"));

                Context.Dispose();

                Common.Uninit();

                //Utils.Dispose();

                Log.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }