SIL.FieldWorks.FieldWorks.InitializeFirstApp C# (CSharp) Метод

InitializeFirstApp() приватный Метод

private InitializeFirstApp ( FwApp app, SIL.FieldWorks.ProjectId projectId ) : bool
app SIL.FieldWorks.Common.Framework.FwApp
projectId SIL.FieldWorks.ProjectId
Результат bool
		private static bool InitializeFirstApp(FwApp app, ProjectId projectId)
		{
			Debug.Assert(s_cache == null && s_projectId == null, "This should only get called once");
			Debug.Assert(projectId != null, "Should have exited the program");

			using (var process = Process.GetCurrentProcess())
			{
				app.RegistrySettings.LoadingProcessId = process.Id;
			}
			if (String.IsNullOrEmpty(app.RegistrySettings.LatestProject))
			{
				// Until something gets saved, we will keep track of the first project opened.
				app.RegistrySettings.LatestProject = projectId.Handle;
				app.RegistrySettings.LatestServer = projectId.ServerName ?? string.Empty;
			}

			UsageEmailDialog.IncrementLaunchCount(app.SettingsKey); // count launches for bug reporting

			ShowSplashScreen(app);

			try
			{
				// Create the cache and let the application init the cache for what it needs
				s_cache = CreateCache(projectId);
				Debug.Assert(s_cache != null, "At this point we should know which project to load and have loaded it!");

				if (s_noUserInterface || InitializeApp(app, s_splashScreen))
				{
					app.RegistrySettings.LoadingProcessId = 0;
#if !__MonoCS__
					if (!WindowsInstallerQuery.IsThisInstalled() || app.ActiveMainWindow == null)
						return true;

					// Initialize NetSparkle to check for updates:
					Settings.Default.IsBTE = WindowsInstallerQuery.IsThisBTE();

					var appCastUrl = Settings.Default.IsBTE
						? (Settings.Default.CheckForBetaUpdates
							? CoreImpl.Properties.Resources.ResourceManager.GetString("kstidAppcastBteBetasUrl")
							: CoreImpl.Properties.Resources.ResourceManager.GetString("kstidAppcastBteUrl"))
						: (Settings.Default.CheckForBetaUpdates
							? CoreImpl.Properties.Resources.ResourceManager.GetString("kstidAppcastSeBetasUrl")
							: CoreImpl.Properties.Resources.ResourceManager.GetString("kstidAppcastSeUrl"));

					var sparkle = SingletonsContainer.Get("Sparkle", () => new Sparkle(appCastUrl, app.ActiveMainWindow.Icon));
					sparkle.AboutToExitForInstallerRun += delegate(object sender, CancelEventArgs args)
						{
							CloseAllMainWindows();
							if(app.ActiveMainWindow != null)
							{
								args.Cancel = true;
							}
						};
					if (Settings.Default.AutoCheckForUpdates)
						sparkle.CheckOnFirstApplicationIdle();
#endif
					return true;
				}
			}
			catch (UnauthorizedAccessException uae)
			{
				if (MiscUtils.IsUnix)
				{
					// Tell Mono user he/she needs to logout and log back in
					MessageBox.Show(ResourceHelper.GetResourceString("ksNeedToJoinFwGroup"));
				}
				throw;
			}
			catch (FdoDataMigrationForbiddenException)
			{
				// tell the user to close all other applications using this project
				MessageBox.Show(ResourceHelper.GetResourceString("kstidDataMigrationProhibitedText"),
					ResourceHelper.GetResourceString("kstidDataMigrationProhibitedCaption"), MessageBoxButtons.OK, MessageBoxIcon.Error);
			}
			finally
			{
				CloseSplashScreen();
			}

			return false;
		}
FieldWorks