Exemple #1
0
        public void Initialize(LauncherApp launcher, string defaultLogText = null)
        {
            this.launcher     = launcher;
            logLabel.Text     = defaultLogText ?? string.Empty;
            versionLabel.Text = string.Empty;

            launcher.Loading           += launcher_Loading;
            launcher.ProgressAvailable += launcher_ProgressAvailable;
            launcher.LogAvailable      += launcher_LogAvailable;
            timer.Tick += timer_Tick;
            timer.Start();

            isInitialized = true;
        }
Exemple #2
0
        private void closeButton_Click(object sender, EventArgs e)
        {
            var procCount = LauncherApp.GetProcessCount();

            if (launcher.IsProcessing)
            {
                var confirmResult = MessageBox.Show("Some background operations are still in progress. Force close? ",
                                                    "Close", MessageBoxButtons.YesNo);

                if (confirmResult == DialogResult.No)
                {
                    return;
                }
            }
            Close();
        }
Exemple #3
0
        public void Initialize(LauncherApp launcher, string defaultLogText = null)
        {
            this.launcher = launcher;
            logLabel.Text = defaultLogText ?? string.Empty;
            versionLabel.Text = string.Empty;
            
            launcher.Loading += launcher_Loading;
            launcher.ProgressAvailable += launcher_ProgressAvailable;
            launcher.LogAvailable += launcher_LogAvailable;
            launcher.SDKVersionListUpdated += launcher_SDKVersionListUpdated;
            launcher.Processing += launcher_processing;
            launcher.Idle += launcher_idle;
            timer.Tick += timer_Tick;
            timer.Start();

            isInitialized = true;
        }
Exemple #4
0
        private void Run(string[] args)
        {
            if (args.Length > 0 && args[0] == LaunchAppRestartOption)
            {
                Console.WriteLine("Restart, wait for 200ms");
                Thread.Sleep(200);
                args = args.Skip(1).ToArray();
            }

            using (launcherApp = new LauncherApp())
            {
                launcherApp.DialogAvailable    += launcherApp_DialogAvailable;
                launcherApp.UnhandledException += (sender, exception) => ShowUnhandledException(exception);

                var evt = new ManualResetEvent(false);

                var splashThread = new Thread(
                    () =>
                {
                    splashscreen = new SplashForm();
                    splashscreen.Initialize(launcherApp);
                    splashscreen.Show();

                    launcherApp.MainWindowHandle = splashscreen.Handle;
                    evt.Set();

                    Application.Run(splashscreen);
                    splashscreen = null;
                });
                splashThread.Start();

                evt.WaitOne();

                launcherApp.ProgressAvailable += launcherApp_ProgressAvailable;
                launcherApp.LogAvailable      += launcherApp_LogAvailable;
                var runningForm = splashscreen;
                launcherApp.Running += (sender, eventArgs) => SafeWindowClose(runningForm);

                var result = launcherApp.Run(args);

                // Make sure the splashscreen is closed in case of an error
                if (result != 0)
                {
                    runningForm.ExitOnUserClose = false;
                    SafeWindowClose(runningForm);
                }

                // Reopen the SplashForm if we are still downloading files
                if (launcherApp.IsDownloading)
                {
                    isPostDownloading             = true;
                    launcherApp.DownloadFinished += launcherApp_DownloadFinished;

                    splashscreen = new SplashForm();
                    splashscreen.Initialize(launcherApp, "Downloading new version");
                    splashscreen.Show();
                    Application.Run(splashscreen);
                    splashscreen = null;
                }
            }
            launcherApp = null;

            // Relaunch this application if necessary
            if (relaunchThisProcess)
            {
                var newArgs = new List <string>()
                {
                    LaunchAppRestartOption
                };
                newArgs.AddRange(args);
                var startInfo = new ProcessStartInfo(typeof(Program).Assembly.Location)
                {
                    Arguments        = string.Join(" ", newArgs),
                    WorkingDirectory = Environment.CurrentDirectory,
                    UseShellExecute  = true
                };
                Process.Start(startInfo);
            }
        }
Exemple #5
0
        private void Run(string[] args)
        {
            if (args.Length > 0 && args[0] == LaunchAppRestartOption)
            {
                Console.WriteLine("Restart, wait for 200ms");
                Thread.Sleep(200);
                args = args.Skip(1).ToArray();
            }

            using (launcherApp = new LauncherApp())
            {
                launcherApp.DialogAvailable += launcherApp_DialogAvailable;
                launcherApp.UnhandledException += (sender, exception) => ShowUnhandledException(exception);

                var evt = new ManualResetEvent(false);

                var splashThread = new Thread(
                    () =>
                    {
                        splashscreen = new SplashForm();
                        splashscreen.Initialize(launcherApp);
                        splashscreen.Show();

                        launcherApp.MainWindowHandle = splashscreen.Handle;
                        evt.Set();

                        Application.Run(splashscreen);
                        splashscreen = null;
                    });
                splashThread.Start();

                evt.WaitOne();

                launcherApp.ProgressAvailable += launcherApp_ProgressAvailable;
                launcherApp.LogAvailable += launcherApp_LogAvailable;
                var runningForm = splashscreen;
                launcherApp.Running += (sender, eventArgs) => SafeWindowClose(runningForm);

                var result = launcherApp.Run(args);

                // Make sure the splashscreen is closed in case of an error
                if (result != 0)
                {
                    runningForm.ExitOnUserClose = false;
                    SafeWindowClose(runningForm);
                }

                // Reopen the SplashForm if we are still downloading files
                if (launcherApp.IsDownloading)
                {
                    isPostDownloading = true;
                    launcherApp.DownloadFinished += launcherApp_DownloadFinished;

                    splashscreen = new SplashForm();
                    splashscreen.Initialize(launcherApp, "Downloading new version");
                    splashscreen.Show();
                    Application.Run(splashscreen);
                    splashscreen = null;
                }
            }
            launcherApp = null;

            // Relaunch this application if necessary
            if (relaunchThisProcess)
            {
                var newArgs = new List<string>() { LaunchAppRestartOption };
                newArgs.AddRange(args);
                var startInfo = new ProcessStartInfo(typeof(Program).Assembly.Location)
                {
                    Arguments = string.Join(" ", newArgs),
                    WorkingDirectory = Environment.CurrentDirectory,
                    UseShellExecute = true
                };
                Process.Start(startInfo);
            }
        }