StartWithWSPage() public method

Used to start the dlg with the WS page being used.
public StartWithWSPage ( ) : void
return void
Ejemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Launches the proj properties DLG.
		/// </summary>
		/// <param name="startOnWSPage">if set to <c>true</c> [start on WS page].</param>
		/// ------------------------------------------------------------------------------------
		private void LaunchProjPropertiesDlg(bool startOnWSPage)
		{
			if (!ClientServerServicesHelper.WarnOnOpeningSingleUserDialog(Cache))
				return;
			if (!SharedBackendServicesHelper.WarnOnOpeningSingleUserDialog(Cache))
				return;

			FdoCache cache = Cache;
			bool fDbRenamed = false;
			string sProject = cache.ProjectId.Name;
			string sProjectOrig = sProject;
			string sLinkedFilesRootDir = cache.LangProject.LinkedFilesRootDir;
			using (var dlg = new FwProjPropertiesDlg(cache, m_app, m_app, FontHeightAdjuster.StyleSheetFromMediator(Mediator)))
			{
				dlg.ProjectPropertiesChanged += OnProjectPropertiesChanged;
				if (startOnWSPage)
					dlg.StartWithWSPage();
				if (dlg.ShowDialog(this) != DialogResult.Abort)
				{
					fDbRenamed = dlg.ProjectNameChanged();
					if (fDbRenamed)
					{
						sProject = dlg.ProjectName;
					}
					bool fFilesMoved = false;
					if (dlg.LinkedFilesChanged())
					{
						fFilesMoved = m_app.UpdateExternalLinks(sLinkedFilesRootDir);
					}
					// no need for any of these refreshes if entire window has been/will be
					// destroyed and recreated.
					if (!fDbRenamed && !fFilesMoved)
					{
						Mediator.PropertyTable.SetProperty("DocumentName", cache.ProjectId.UiName);
						Mediator.PropertyTable.SetPropertyPersistence("DocumentName", false);
					}
				}
			}
			if (fDbRenamed)
				m_app.FwManager.RenameProject(sProject, m_app);
		}
Ejemplo n.º 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Launches the proj properties DLG.
		/// </summary>
		/// <param name="startOnWSPage">if set to <c>true</c> [start on WS page].</param>
		/// ------------------------------------------------------------------------------------
		private void LaunchProjPropertiesDlg(bool startOnWSPage)
		{
			FdoCache cache = Cache;
			bool fDbRenamed = false;
			string sServer = cache.ServerName;
			string sDatabase = cache.DatabaseName;
			string sProject = cache.LangProject.Name.UserDefaultWritingSystem;
			if (sProject != sDatabase)
			{
				cache.LangProject.Name.UserDefaultWritingSystem = sDatabase;
				sProject = sDatabase;
			}
			string sExtLinkRootDir = cache.LangProject.ExternalLinkRootDir;
			using (FwProjPropertiesDlg dlg = new FwProjPropertiesDlg(cache, FwApp.App, FwApp.App,
				FwApp.App, Logger.Stream, cache.LangProject.Hvo, HvoAppRootObject,
				cache.DefaultUserWs, FontHeightAdjuster.StyleSheetFromMediator(Mediator)))
			{
				if (startOnWSPage)
					dlg.StartWithWSPage();
				if (dlg.ShowDialog(this) != DialogResult.Abort)
				{
					fDbRenamed = dlg.ProjectNameChanged();
					if (fDbRenamed)
					{
						sProject = cache.LangProject.Name.UserDefaultWritingSystem;
					}
					bool fFilesMoved = false;
					if (dlg.ExternalLinkChanged())
					{
						fFilesMoved = FwApp.UpdateExternalLinks(sExtLinkRootDir, cache.LangProject);
					}
					// no need for any of these refreshes if entire window has been/will be
					// destroyed and recreated.
					if (!fDbRenamed && !fFilesMoved)
					{
						bool fDidRefresh = false;
						if (dlg.NewRenderingNeeded() && FwApp.App is FwXApp)
						{
							Mediator.BroadcastMessage("MasterRefresh", null); // Part of fixing LT-2339: redisplay with changes.
							fDidRefresh = true;
						}
						if (dlg.WritingSystemsChanged())
						{
							// Since we are going to do a full refresh, we don't want to sync the writing systems here as that
							// adds several more seconds updating everything prior to doing the full refresh. If we really need
							// to notify other apps of this change, we need some better approach, or sync a full refresh (but I
							// (KZ) tried this and it runs into the same huge delay as calling OnMasterRefresh directly. Also, it
							// doesn't appear that a call to Synchronize gets a sync message to the database anyway. It just
							// does the work immediately on the local copy).
							//FwApp.App.Synchronize(new SyncInfo(SyncMsg.ksyncWs, 0, 0), cache);
							// JohnT: So many things depend on the current list of writing systems...for example,
							// everywhere we display all writing systems, or best writing system, or default writing system...
							if (!fDidRefresh && FwApp.App is FwXApp)
							{
								Mediator.BroadcastMessage("MasterRefresh", null);
								// Note: calling OnMasterRefresh directly takes many minutes reloading and painting
								// everything in the process of removing the browse control in WarmBootPart1.
								//(FwApp.App as FwXApp).OnMasterRefresh(null);
								fDidRefresh = true;
							}
						}
						if (!fDidRefresh && dlg.SortChanged() && FwApp.App is FwXApp)
							Mediator.BroadcastMessage("MasterRefresh", null);
						Mediator.PropertyTable.SetProperty("DocumentName", cache.ProjectName());
						Mediator.PropertyTable.SetPropertyPersistence("DocumentName", false);
						SetWindowLabel();
					}
				}
			}
			if (fDbRenamed)
			{

				string oldFilenamePrefix = String.Format("db${0}$", sDatabase);
				string newFilenamePrefix = String.Format("db${0}$", sProject);

				//Make a copy all the settings files to match the new project name.
				DirectoryInfo di = new DirectoryInfo(Mediator.PropertyTable.UserSettingDirectory);
				string findOldFilenames = String.Format("db${0}$*", sDatabase);
				System.IO.FileInfo[] fi = di.GetFiles(findOldFilenames);
				foreach (System.IO.FileInfo f in fi)
				{
					string newname = CreateNewFileName(f.FullName, oldFilenamePrefix, newFilenamePrefix);
					File.Copy(f.FullName, newname, true);
				}

				// The file db$ProjectName$Settings.xml cannot just be copied because the PropertyTable
				// settings have to be renamed to reflect the new project name.
				// Therefore before renaming the database we need to save the project specific PropertyTable settings
				// to a new file using the new project name in the filename and property names.
				Mediator.PropertyTable.SaveLocalSettingsForNewProjectName(sDatabase, sProject);

				bool fRenameSucceeded = false;
				fRenameSucceeded = FwApp.App.RenameProject(sServer, sDatabase, sProject);
				if (fRenameSucceeded)
				{
					//Now delete all old settings files.
					foreach (System.IO.FileInfo f in fi)
					{
						if (File.Exists(f.FullName))
							File.Delete(f.FullName);
					}
				}
				else
				{
					//delete the new settings files since the database rename failed
					foreach (System.IO.FileInfo f in fi)
					{
						string newname = CreateNewFileName(f.FullName, oldFilenamePrefix, newFilenamePrefix);
						if (File.Exists(newname))
							File.Delete(newname);
					}
				}
			}
		}