예제 #1
0
파일: FwXApp.cs 프로젝트: sillsdev/WorldPad
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Creates a new instance of the main X window
		/// </summary>
		///
		/// <param name="cache">Instance of the FW Data Objects cache that the new main window
		/// will use for accessing the database.</param>
		/// <param name="isNewCache">Flag indicating whether one-time, application-specific
		/// initialization should be done for this cache.</param>
		/// <param name="wndCopyFrom"> Must be null for creating the original app window.
		/// Otherwise, a reference to the main window whose settings we are copying.</param>
		/// <param name="fOpeningNewProject"><c>true</c> if opening a brand spankin' new
		/// project</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		protected override Form NewMainAppWnd(FdoCache cache, bool isNewCache, Form wndCopyFrom,
			bool fOpeningNewProject)
		{
			// Review: I put in this exception catching block because
			// the exception handler is not been invoked...until we figure out why
			// not, this is better than just having the raw exception in the users face.
			try
			{
				if (isNewCache)
				{
					// TODO: Do any needed initialization here.
				}
				Stream iconStream = ApplicationIconStream;
				Debug.Assert(iconStream != null, "Couldn't find the specified application icon as a resource.");
				string configFile;
				if (m_commandLineArgs.ContainsKey("x"))
				{
					configFile = m_commandLineArgs["x"][0];
				}
				else
				{
					configFile = DirectoryFinder.GetFWCodeFile(DefaultConfigurationPathname);
					//					configFile = (string)SettingsKey.GetValue("LatestConfigurationFile",
					//						Path.Combine(DirectoryFinder.FWCodeDirectory,
					//						DefaultConfigurationPathname));
					if (!File.Exists(configFile))
						configFile = null;
				}
				FwXWindow result;
				if (configFile != null)
					result = new FwXWindow(cache, wndCopyFrom, iconStream, configFile, false);
				else
				{
					// try to load from stream
					return new FwXWindow(cache, wndCopyFrom, iconStream, ConfigurationStream);
				}
				if (isNewCache)
				{
					// Must be done after reading properties from init table.
					if (result.PropertyTable.GetBoolProperty("SendSync", false) && SyncGuid != Guid.Empty)
						cache.MakeDbSyncRecords(SyncGuid);
				}

				if (m_commandLineArgs.ContainsKey("link"))
					result.StartupAtURL(m_commandLineArgs["link"][0]);

				return result;
			}
			catch (Exception error)
			{
				HandleTopLevelError(this, new System.Threading.ThreadExceptionEventArgs(error));
				return null;
			}
		}