示例#1
0
        public Main(bool checkForUpdates)
        {
            Diagnostics.StartTimer("TotalStartupTimer");
            Diagnostics.StartTimer("DisplaySplash");
            splash = new SplashScreen(this);
            Thread t0 = new Thread(ShowSplash);
            t0.Start();
            Diagnostics.StopTimer("DisplaySplash");

            Diagnostics.StartTimer("InitGUI");
            InitializeComponent();
            this.FormClosing += new FormClosingEventHandler(Main_FormClosing);
            // Set main window start state/position/size
            this.StartPosition = FormStartPosition.Manual;
            this.WindowState = EveMarketMonitorApp.Properties.Settings.Default.WindowState;
            if (EveMarketMonitorApp.Properties.Settings.Default.WindowPos.X > 0 &&
                EveMarketMonitorApp.Properties.Settings.Default.WindowPos.X < Screen.PrimaryScreen.WorkingArea.Width &&
                EveMarketMonitorApp.Properties.Settings.Default.WindowPos.Y > 0 &&
                EveMarketMonitorApp.Properties.Settings.Default.WindowPos.Y < Screen.PrimaryScreen.WorkingArea.Height)
            {
                this.Location = EveMarketMonitorApp.Properties.Settings.Default.WindowPos;
            }
            else
            {
                this.Location = new Point(0, 0);
            }
            this.Size = EveMarketMonitorApp.Properties.Settings.Default.WindowSize;
            Diagnostics.StopTimer("InitGUI");

            try
            {
                //splash.ShowMessage("Test Message", "Test", MessageBoxButtons.OK, MessageBoxIcon.Information);
                DateTime start = DateTime.UtcNow;
                // DO ANY SETUP HERE.
                // The splash screen will be showing while these methods are executed.
                Diagnostics.StartTimer("Environment");
                UpdateStatus(0, 0, "Setting up environment", "", false);
                SetupEnvironment();
                Diagnostics.StopTimer("Environment");
                UpdateStatus(0, 0, "Checking Prerequesits", "", false);
                if (Prerequs())
                {
                    Diagnostics.StartTimer("PingChecks");
                    UpdateStatus(0, 0, "Checking remote servers", "", false);
                    PingServers();
                    Diagnostics.StopTimer("PingChecks");
                    Diagnostics.StartTimer("Updates");
                    // Update settings and user database if needed.
                    UpdateStatus(0, 0, "Initalising database", "", false);
                    //try
                    //{
                    checkForUpdates = checkForUpdates && EveMarketMonitorApp.Properties.Settings.Default.AutoUpdate;
                    if (checkForUpdates)
                    {
                        //DateTime lastCheck = Properties.Settings.Default.LastEMMAUpdateCheck;
                        //if (lastCheck.AddHours(5).CompareTo(DateTime.UtcNow) < 0)
                        //{
                        UpdateStatus(0, 0, "Checking for updates", "", false);
                        // Check for updates to EMMA components
                        AutoUpdate();
                        Properties.Settings.Default.LastEMMAUpdateCheck = DateTime.UtcNow;
                        Properties.Settings.Default.Save();
                        //}
                    }
                    Updater.Update();
                    //}
                    //catch (EMMAException)
                    //{
                    //UpdateStatus(0, 0, "Done", "", true);
                    //MessageBox.Show(splash, "Critical error updating EMMA database. For details, see " +
                    //    "\"Logging/ExceptionLog.txt\"", "Ciritcal error",
                    //    MessageBoxButtons.OK, MessageBoxIcon.Error);
                    //}
                    Updater.InitDBs();
                    CheckForDocumentation();
                    Diagnostics.StopTimer("Updates");
                    UpdateStatus(0, 0, "Checking License", "", false);
                    ValidateInstall(false, splash);

                    if (Globals.License != LicenseType.Full &&
                        Globals.License != LicenseType.Lite &&
                        Globals.License != LicenseType.Trial &&
                        Globals.License != LicenseType.Monthly)
                    {
                        this.Close();
                    }
                    else
                    {

                        Diagnostics.StartTimer("MapInit");
                        // Pre-load map data.
                        Map.InitaliseData();
                        UpdateStatus(0, 0, "Getting latest outpost data", "", false);
                        EveAPI.UpdateOutpostData();
                        Diagnostics.StopTimer("MapInit");
                        Diagnostics.StartTimer("AutoLogin");
                        // Log user in if they have auto login turned on
                        AutoLogin();
                        Diagnostics.StopTimer("AutoLogin");
                        //UpdateStatus(0, 0, "Starting program", "", false);

                        // make sure we show the splash screen for a minimum of one second.
                        // ... it looks wierd otherwise.
                        while (start.AddSeconds(1).CompareTo(DateTime.UtcNow) > 0) { }
                    }
                }
            }
            catch (Exception ex)
            {
                EMMAException emmaEx = ex as EMMAException;
                if (emmaEx == null)
                {
                    emmaEx = new EMMAException(ExceptionSeverity.Critical, "Error during startup", ex);
                }
                splash.ShowMessage("Problem during EMMA startup.\r\nCheck " + EMMAException.logFile +
                    " for details.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UpdateStatus(0, 0, "Done", "", true);
                this.Close();
            }
            finally
            {
                Diagnostics.StartTimer("LoadMainForm");
                UpdateStatus(0, 0, "Done", "", true);
                splash = null;
            }
        }
示例#2
0
        private void ValidateInstall(bool showDialogIfValid, SplashScreen splash)
        {
            try
            {
                Enforcer.LicenseManagement licenseMgt = new LicenseManagement();
                Globals.License = licenseMgt.GetLicenseType();
                //if (splash != null && !showDialogIfValid &&
                //    Globals.License != LicenseType.Full &&
                //    Globals.License != LicenseType.Lite &&
                //    Globals.License != LicenseType.Trial)
                //{
                //    splash.ShowMessage("Dear user, EMMA has been free for some time now. However, due to the additional work that has been done lately, and will be done in future, I am reintroducing the licensing model.\r\n\r\nYou are currently using an unlicensed version of EMMA. On 1st Sept 2010 it will stop working.\r\nIf you previously bought a license then eve-mail me (Ambo) and, if you're on my records, I will send you a new key\r\nIf you have not previously bought a license then please click the license button within EMMA for details of how to get one.\r\n\r\nThanks, Ambo.",
                //        "License Expired", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //}

                // Set license to full for now.
                //if (Globals.License != LicenseType.Lite) { Globals.License = LicenseType.Full; }

                if (showDialogIfValid ||
                    (Globals.License != LicenseType.Full && Globals.License != LicenseType.Lite))
                {
                    licenseMgt.ShowDialog();
                }
                Globals.License = licenseMgt.GetLicenseType();
            }
            catch (Exception ex)
            {
                if (!(ex is EMMAException))
                {
                    new EMMAException(ExceptionSeverity.Critical, "Problem validating installation", ex);
                }

                if (splash != null)
                {
                    splash.ShowMessage("There was a problem validating your installation.\r\n" +
                        ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    MessageBox.Show("There was a problem validating your installation.\r\n" +
                        ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                this.Close();
            }
        }