Пример #1
0
        // Initialize everything on the UI thread, and report+die for any problems or SwitchContext from SplashForm to EDDiscoveryForm.
        private void MainEngineStart(object sender, EventArgs e)
        {
            var tim = (Timer)sender;

            tim?.Stop();

            var launchArg = ((EDDFormLaunchArgs)tim?.Tag)?.Clone() ?? new EDDFormLaunchArgs();

            tim?.Dispose();

            try
            {
                EDDMainForm = new EDDiscoveryForm();
                SetLoadingMsg("Checking Ship Systems");

                EDDiscoveryController.Initialize(SetLoadingMsg);   // this loads up the options

                EDDOptions.Instance.NoWindowReposition |= launchArg.PositionReset;
                EDDOptions.Instance.NoTheme            |= launchArg.ThemeReset;

                EDDMainForm.Init(SetLoadingMsg);    // call the init function, which will initialize the eddiscovery form

                SetLoadingMsg("Establishing Telepresence");
                SwitchContext(EDDMainForm);         // Ignition, and liftoff!
            }
            catch (Exception ex)
            {   // There's so many ways that things could go wrong during init; let's fail for everything!
                EDDMainForm?.Dispose();
                FatalExceptionForm.ShowAndDie(MainForm, "Initializing", Properties.Resources.URLProjectFeedback, ex);
            }
        }
Пример #2
0
        // Initialize everything on the UI thread, and report+die for any problems or SwitchContext from SplashForm to EDDiscoveryForm.
        private void MainEngineStart(object sender, EventArgs e)
        {
            var tim = (Timer)sender;

            tim?.Stop();

            var launchArg = ((EDDFormLaunchArgs)tim?.Tag)?.Clone() ?? new EDDFormLaunchArgs();

            tim?.Dispose();

            try
            {
                EDDMainForm = new EDDiscoveryForm();
                SetLoadingMsg("Starting EDD");

                EDDiscoveryController.Initialize(SetLoadingMsg);   // this loads up the options

                EDDOptions.Instance.NoWindowReposition |= launchArg.PositionReset;
                EDDOptions.Instance.NoTheme            |= launchArg.ThemeReset;
                EDDOptions.Instance.TabsReset          |= launchArg.TabsReset;
                EDDOptions.Instance.ResetLanguage      |= launchArg.ResetLang;

                EDDMainForm.Init(SetLoadingMsg);    // call the init function, which will initialize the eddiscovery form

                SetLoadingMsg("Starting Program");
                SwitchContext(EDDMainForm);         // Ignition, and liftoff!
            }
            catch (Exception ex)
            {   // There's so many ways that things could go wrong during init; let's fail for everything!
                EDDMainForm?.Dispose();
                BaseUtils.ExceptionForm.ShowException(ex, "A fatal exception was encountered while initializing EDDiscovery.", Properties.Resources.URLProjectFeedback, isFatal: true, parent: MainForm);
            }
        }
        // event handlers

        // Initialize everything on the UI thread soon after the `Application` has been `.Run()`, and transfer context (MainForm) from the SplashForm to the EDDiscoveryForm.
        private void initTimer_Tick(object sender, EventArgs e)
        {
            ((Timer)sender)?.Stop();
            ((Timer)sender)?.Dispose();

            try
            {
                EDDMainForm = new EDDiscoveryForm();
                SetLoadingMsg("Checking Ship Systems");
                EDDiscoveryController.Initialize(Control.ModifierKeys.HasFlag(Keys.Shift), Control.ModifierKeys.HasFlag(Keys.Control), SetLoadingMsg);
                EDDMainForm.Init(SetLoadingMsg);     // call the init function, which will initialize the eddiscovery form

                SetLoadingMsg("Establishing Telepresence");
                EDDMainForm.Show();
            }
            catch (Exception ex)
            {   // There's so many ways that things could go wrong during init; let's fail for everything!
                EDDMainForm?.Dispose();
                FatalExceptionForm.ShowAndDie(MainForm, "Initializing", Properties.Resources.URLProjectFeedback, ex);
            }

            var splashForm = MainForm;

            MainForm = EDDMainForm; // Switch context
            splashForm.Close();     // and cleanup
        }
Пример #4
0
        // Initialize everything on the UI thread, and report+die for any problems or SwitchContext from SplashForm to EDDiscoveryForm.
        private void MainEngineStart(object sender, EventArgs e)
        {
            var tim = (Timer)sender;

            tim?.Stop();

            var launchArg = ((EDDFormLaunchArgs)tim?.Tag)?.Clone() ?? new EDDFormLaunchArgs();

            tim?.Dispose();

            EDDiscoveryForm EDDMainForm = null;

            try
            {
                EDDMainForm = new EDDiscoveryForm();
                SetLoadingMsg("Starting EDD");

                EDDiscoveryController.Initialize(SetLoadingMsg);   // this loads up the options

                EDDOptions.Instance.NoWindowReposition |= launchArg.PositionReset;
                EDDOptions.Instance.NoTheme            |= launchArg.ThemeReset;
                EDDOptions.Instance.TabsReset          |= launchArg.TabsReset;
                EDDOptions.Instance.ResetLanguage      |= launchArg.ResetLang;

                EDDMainForm.Init(SetLoadingMsg);    // call the init function, which will initialize the eddiscovery form

                if (Environment.OSVersion.Platform == PlatformID.Win32NT)
                {
                    NativeMethods.STARTUPINFO_I si = new NativeMethods.STARTUPINFO_I();
                    UnsafeNativeMethods.GetStartupInfo(si);        // duplicate of form.cs WmCreate check of code.

                    if ((si.dwFlags & NativeMethods.STARTF_USESHOWWINDOW) != 0)
                    {
                        if (si.wShowWindow == NativeMethods.SW_MINIMIZE || si.wShowWindow == NativeMethods.SW_SHOWMINNOACTIVE)
                        {
                            EDDOptions.Instance.MinimiseOnOpen = true;
                        }
                        else if (si.wShowWindow == NativeMethods.SW_SHOWMAXIMIZED || si.wShowWindow == NativeMethods.SW_MAXIMIZE)
                        {
                            EDDOptions.Instance.MaximiseOnOpen = true;
                        }
                    }
                }

                SetLoadingMsg("Starting Program");
                SwitchContext(EDDMainForm);         // Ignition, and liftoff!
            }
            catch (Exception ex)
            {   // There's so many ways that things could go wrong during init; let's fail for everything!
                EDDMainForm?.Dispose();
                BaseUtils.ExceptionForm.ShowException(ex, "A fatal exception was encountered while initializing EDDiscovery.", Properties.Resources.URLProjectFeedback, isFatal: true, parent: MainForm);
            }
        }