Esempio n. 1
0
        public static bool InitializeModules()
        {
            // logger
            m_Splash.ThreadSetText("Initializing logger...");

            try
            {
                Globals.InitializeLogger();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Critical error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            // settings
            m_Splash.ThreadSetText(String.Format("Loading {0}...", Settings.FileName));

            try
            {
                Globals.InitializeSettings();
            }
            catch (Exception ex)
            {
                m_Splash.HandleException(String.Format("Error loading {0}", Settings.FileName));
                Globals.Logger.LogException(ex);
                return(false);
            }

            // language
            m_Splash.ThreadSetText(String.Format("Loading {0}...", Globals.Settings.Language));

            try
            {
                Globals.InitializeLanguage();
            }
            catch (Exception ex)
            {
                m_Splash.HandleException(String.Format("Error loading {0}", Globals.Settings.Language));
                Globals.Logger.LogException(ex);
                return(false);
            }

            // hash spy
            m_Splash.ThreadSetText("Initializing hash spy");

            try
            {
                Globals.InitializeHashSpy();
            }
            catch (Exception ex)
            {
                m_Splash.HandleException("Error initializing hash spy.");
                Globals.Logger.LogException(ex);
                return(false);
            }

            // main form
            m_Splash.ThreadSetText("Initializing main form...");

            try
            {
                Globals.InitializeMainForm();
            }
            catch (Exception ex)
            {
                m_Splash.HandleException("Error initializing main form.");
                Globals.Logger.LogException(ex);
                return(false);
            }

            // hash dictionary
            m_Splash.ThreadSetText("Loading dictionary...");

            try
            {
                HashDictionary.LoadDictionary(HashDictionary.FileName);
            }
            catch (Exception ex)
            {
                Globals.Logger.LogException(ex);
            }

            // delay
            m_Splash.ThreadSetText("Done");
            return(true);
        }
        /// <summary>
        /// Initialize all the app modules
        /// </summary>
        /// <returns>true on success, false if something goes wrong</returns>
        private static bool InitializeModules()
        {
            // set the splash screen text
            m_Splash.ThreadSetText("Initializing logger...");

            // initialize the logger
            try { Globals.InitializeLogger(); }

            catch (Exception ex)
            {
                // if something goes wrong show a message box with the error
                MessageBox.Show(ex.Message, "Critical error", MessageBoxButtons.OK, MessageBoxIcon.Error);

                return(false);
            }

            // set the splash screen text
            m_Splash.ThreadSetText(string.Format("Loading {0}...", Settings.FileName));

            // initialize the settings
            try { Globals.InitializeSettings(); }

            catch (Exception ex)
            {
                // if something goes wrong, log the exception
                m_Splash.HandleException(string.Format("Error loading {0}", Settings.FileName));
                Globals.Logger.Log(ex);

                return(false);
            }

            // set the splash screen text
            m_Splash.ThreadSetText(string.Format("Loading {0}...", Globals.Settings.Language));

            // initialize the language
            try { Globals.InitializeLanguage(); }

            catch (Exception ex)
            {
                // if something goes wrong, log the exception
                m_Splash.HandleException(string.Format("Error loading {0}", Globals.Settings.Language));
                Globals.Logger.Log(ex);

                return(false);
            }

            // set the splash screen text
            m_Splash.ThreadSetText("Initializing hash spy");

            // initialize the spy
            try { Globals.InitializeHashSpy(); }

            catch (Exception ex)
            {
                // if something goes wrong, log the exception
                m_Splash.HandleException("Error initializing hash spy.");
                Globals.Logger.Log(ex);

                return(false);
            }

            // set the splash screen text
            m_Splash.ThreadSetText("Initializing main form...");

            // initialize the main form
            try { Globals.InitializeMainForm(); }

            catch (Exception ex)
            {
                // if something goes wrong, log the exception
                m_Splash.HandleException("Error initializing main form.");
                Globals.Logger.Log(ex);

                return(false);
            }

            // set the splash screen text
            m_Splash.ThreadSetText("Loading dictionary...");

            // initialize the dictionary
            try { HashDictionary.LoadDictionary(HashDictionary.FileName); }

            catch (Exception ex)
            {
                // if something goes wrong, log the exception
                Globals.Logger.Log(ex);
            }

            // set the splash screen text for the process completed
            m_Splash.ThreadSetText("Done");

            return(true);
        }