private bool ShowUpgradeForm(Version availableVersion, bool automatic, bool updateFound) { string versionText = availableVersion != null ? GetVersionDiff(AppDeployment.CurrentVersion, availableVersion) : null; using (var dlgUpgrade = new UpgradeDlg(versionText, automatic, updateFound) { Text = Program.Name }) { try { return(dlgUpgrade.ShowDialog(ParentWindow) == DialogResult.OK); } catch (ObjectDisposedException) { try { return(dlgUpgrade.ShowDialog(ParentWindow) == DialogResult.OK); } catch (Exception) { return(false); } } } }
protected override void DoTest() { // Show About dialog. using (var about = new AboutDlg()) { RunDlg <AboutDlg>( () => about.ShowDialog(Program.MainWindow), a => a.Close()); } // Show Alert link dialog. RunDlg <AlertLinkDlg>( () => WebHelpers.ShowLinkFailure(Program.MainWindow, "http://skyline.maccosslab.org"), d => d.Close()); // Show shutdown report dialog Assert.IsFalse(ReportShutdownDlg.HadUnexpectedShutdown(true)); try { throw new IOException("Something to report"); } catch (Exception x) { ReportShutdownDlg.SaveExceptionFile(x, true); } Assert.IsTrue(ReportShutdownDlg.HadUnexpectedShutdown(true)); using (var reportShutdownDlg = new ReportShutdownDlg()) { RunDlg <ReportShutdownDlg>( () => reportShutdownDlg.ShowDialog(), d => d.Close()); } Assert.IsFalse(ReportShutdownDlg.HadUnexpectedShutdown(true)); // Show upgrade dialog using (var dlg = new UpgradeDlg(Program.LICENSE_VERSION_CURRENT - 1)) { RunDlg <UpgradeDlg>( () => dlg.ShowDialog(), d => d.Close()); } }
public static void Main(string[] args = null) { if (String.IsNullOrEmpty(Settings.Default.InstallationId)) // Each instance to have GUID { Settings.Default.InstallationId = Guid.NewGuid().ToString(); } // don't allow 64-bit Skyline to run in a 32-bit process if (Install.Is64Bit && !Environment.Is64BitProcess) { string installUrl = Install.Url; string installLabel = (installUrl == string.Empty) ? string.Empty : string.Format(Resources.Program_Main_Install_32_bit__0__, Name); AlertLinkDlg.Show(null, string.Format(Resources.Program_Main_You_are_attempting_to_run_a_64_bit_version_of__0__on_a_32_bit_OS_Please_install_the_32_bit_version, Name), installLabel, installUrl); return; } CommonFormEx.TestMode = FunctionalTest; CommonFormEx.Offscreen = SkylineOffscreen; CommonFormEx.ShowFormNames = FormEx.ShowFormNames = ShowFormNames; // For testing and debugging Skyline command-line interface if (args != null && args.Length > 0) { if (!CommandLineRunner.HasCommandPrefix(args[0])) { TextWriter textWriter; if (Debugger.IsAttached) { textWriter = new DebugWriter(); } else { AttachConsole(-1); textWriter = Console.Out; Console.WriteLine(); Console.WriteLine(); } var writer = new CommandStatusWriter(textWriter); if (args[0].Equals("--ui", StringComparison.InvariantCultureIgnoreCase)) // Not L10N { // ReSharper disable once ObjectCreationAsStatement new CommandLineUI(args, writer); } else { CommandLineRunner.RunCommand(args, writer); } } else { // For testing SkylineRunner without installation CommandLineRunner clr = new CommandLineRunner(); clr.Start(args[0]); } return; } // The way Skyline command-line interface is run for an installation else if (AppDomain.CurrentDomain.SetupInformation.ActivationArguments != null && AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData != null && AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData.Length > 0 && CommandLineRunner.HasCommandPrefix(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0])) // Not L10N { CommandLineRunner clr = new CommandLineRunner(); clr.Start(AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData[0]); // HACK: until the "invalid string binding" error is resolved, this will prevent an error dialog at exit Process.GetCurrentProcess().Kill(); return; } try { Init(); if (!string.IsNullOrEmpty(Settings.Default.DisplayLanguage)) { try { LocalizationHelper.CurrentUICulture = CultureInfo.GetCultureInfo(Settings.Default.DisplayLanguage); } catch (CultureNotFoundException) { } } LocalizationHelper.InitThread(Thread.CurrentThread); // Make sure the user has agreed to the current license version // or one more recent. int licenseVersion = Settings.Default.LicenseVersionAccepted; if (licenseVersion < LICENSE_VERSION_CURRENT && !NoSaveSettings) { // If the user has never used the application before, then // they must have agreed to the current license agreement during // installation. Otherwise, make sure they agree to the new // license agreement. if (Install.Type == Install.InstallType.release && (licenseVersion != 0 || !Settings.Default.MainWindowSize.IsEmpty)) { using (var dlg = new UpgradeDlg(licenseVersion)) { if (dlg.ShowDialog() == DialogResult.Cancel) { return; } } } try { // Make sure the user never sees this again for this license version Settings.Default.LicenseVersionAccepted = LICENSE_VERSION_CURRENT; Settings.Default.Save(); } // ReSharper disable EmptyGeneralCatchClause catch (Exception) // ReSharper restore EmptyGeneralCatchClause { // Just try to update the license version next time. } } try { // If this is a new installation copy over installed external tools from previous installation location. var toolsDirectory = ToolDescriptionHelpers.GetToolsDirectory(); if (!Directory.Exists(toolsDirectory)) { using (var longWaitDlg = new LongWaitDlg { Text = Name, Message = Resources.Program_Main_Copying_external_tools_from_a_previous_installation, ProgressValue = 0 }) { longWaitDlg.PerformWork(null, 1000 * 3, broker => CopyOldTools(toolsDirectory, broker)); } } } // ReSharper disable once EmptyGeneralCatchClause catch { } // Force live reports (though tests may reset this) //Settings.Default.EnableLiveReports = true; if (ReportShutdownDlg.HadUnexpectedShutdown()) { using (var reportShutdownDlg = new ReportShutdownDlg()) { reportShutdownDlg.ShowDialog(); } } SystemEvents.DisplaySettingsChanged += SystemEventsOnDisplaySettingsChanged; // Careful, a throw out of the SkylineWindow constructor without this // catch causes Skyline just to appear to silently never start. Makes for // some difficult debugging. try { var activationArgs = AppDomain.CurrentDomain.SetupInformation.ActivationArguments; if ((activationArgs != null && activationArgs.ActivationData != null && activationArgs.ActivationData.Length != 0) || !Settings.Default.ShowStartupForm) { MainWindow = new SkylineWindow(args); } else { StartWindow = new StartPage(); try { if (StartWindow.ShowDialog() != DialogResult.OK) { Application.Exit(); return; } MainWindow = StartWindow.MainWindow; } finally { StartWindow.Dispose(); StartWindow = null; } } } catch (Exception x) { ReportExceptionUI(x, new StackTrace(1, true)); } ConcurrencyVisualizer.StartEvents(MainWindow); // Position window offscreen for stress testing. if (SkylineOffscreen) { FormEx.SetOffscreen(MainWindow); } ActionUtil.RunAsync(() => { try { SendAnalyticsHit(); } catch (Exception ex) { Trace.TraceWarning("Exception sending analytics hit {0}", ex); // Not L10N } }); MainToolServiceName = Guid.NewGuid().ToString(); Application.Run(MainWindow); StopToolService(); } catch (Exception x) { // Send unhandled exceptions to the console. Console.WriteLine(x.Message); Console.Write(x.StackTrace); } MainWindow = null; }