The ImportWizard class guides the user through the process of establishing import settings for TE and/or for defining the project settings for shadowing or converting a Standard Format project for access by ScriptureObjects.
Inheritance: System.Windows.Forms.Form, IFWDisposable
コード例 #1
0
ファイル: ImportDialog.cs プロジェクト: bbriggs/FieldWorks
		///-------------------------------------------------------------------------------
		/// <summary>
		/// When the Source button is clicked, display the import wizard.
		/// </summary>
		///-------------------------------------------------------------------------------
		private void btnSource_Click(object sender, System.EventArgs e)
		{
			using (ImportWizard importWizard = new ImportWizard(m_scr.Cache.ProjectId.Name,
				m_scr, m_StyleSheet, m_helpTopicProvider, m_app))
			{
				using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper(ActionHandler))
				{
					if (importWizard.ShowDialog() == DialogResult.Cancel)
					{
						// Ditch any in-memory changes made to the settings. Reload from the DB.
						m_importSettings.RevertToSaved();
					}
					else
						undoHelper.RollBack = false;
				}

				// If there are no files after showing the wizard, close the import dialog
				if (InitBookNameList() == 0)
				{
					MessageBox.Show(this, DlgResources.ResourceString("kstidImportFilesUnavailable"),
						m_app.ApplicationName, MessageBoxButtons.OK, MessageBoxIcon.Information);
					Close();
					return;
				}

				// The default set of settings may have changed.
				m_importSettings = m_scr.DefaultImportSettings;

				// Update the file ranges for import because they may have changed.
				InitializeStartAndEndRefControls();

				// Update the passage controls to reflect the new range of files available
				// Only make changes that do not expand the available range of books since a
				// range may have been specified before the wizard was run that we do not
				// want to overwrite
				if (!scrPsgFrom.IsReferenceValid(scrPsgFrom.ScReference))
					SetStartRefToFirstImportableBook();

				if (!scrPsgTo.IsReferenceValid(scrPsgTo.ScReference))
					SetEndRefToLastImportableBook();
			}
			btnOK.Focus();
		}
コード例 #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Get the settings for Import, either from database or from wizard
		/// </summary>
		/// <returns>Import settings, or <c>null</c> if user canceled dialog.</returns>
		/// ------------------------------------------------------------------------------------
		protected IScrImportSet GetImportSettings()
		{
			ILangProject proj = m_cache.LangProject;
			IScripture scr = proj.TranslatedScriptureOA;
			IScrImportSet importSettings = null;
			NonUndoableUnitOfWorkHelper.Do(m_cache.ActionHandlerAccessor, () =>
			{
				importSettings =
					scr.FindOrCreateDefaultImportSettings(TypeOfImport.Unknown);
			});
			importSettings.StyleSheet = m_styleSheet;

			importSettings.OverlappingFileResolver = new ConfirmOverlappingFileReplaceDialog(m_helpTopicProvider);
			if (!importSettings.BasicSettingsExist)
			{
				using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper(
					m_cache.ServiceLocator.GetInstance<IActionHandler>()))
				{
					using (ImportWizard importWizard = new ImportWizard(m_cache.ProjectId.Name,
						scr, m_styleSheet, m_helpTopicProvider, m_app))
					{
						if (importWizard.ShowDialog() == DialogResult.Cancel)
							return null;
						// Scripture reference range may have changed
						ImportDialog.ClearDialogReferences();
						importSettings = scr.DefaultImportSettings;
					}
					undoHelper.RollBack = false;
				}
			}
			else
			{
				StringCollection sInvalidFiles;
				bool fCompletedWizard = false;
				while (!importSettings.ImportProjectIsAccessible(out sInvalidFiles))
				{
					// Display the "Project Not Found" message box
					using (ScrImportSetMessage dlg = new ScrImportSetMessage())
					{
						string[] files = new string[sInvalidFiles.Count];
						sInvalidFiles.CopyTo(files, 0);
						dlg.InvalidFiles = files;
						dlg.HelpURL = m_helpTopicProvider.HelpFile;
						dlg.HelpTopic = "/Beginning_Tasks/Import_Standard_Format/Project_Files_Unavailable.htm";
						dlg.DisplaySetupOption = true;
						switch(dlg.ShowDialog())
						{
							case DialogResult.OK: // Setup...
							{
								using (NonUndoableUnitOfWorkHelper undoHelper = new NonUndoableUnitOfWorkHelper(
									m_cache.ServiceLocator.GetInstance<IActionHandler>()))
								{
									using (ImportWizard importWizard = new ImportWizard(
										m_cache.ProjectId.Name, scr, m_styleSheet, m_helpTopicProvider, m_app))
									{
										if (importWizard.ShowDialog() == DialogResult.Cancel)
											return null;
										// Scripture reference range may have changed
										ImportDialog.ClearDialogReferences();
										importSettings = scr.DefaultImportSettings;
										fCompletedWizard = true;
									}
									undoHelper.RollBack = false;
								}
								break;
							}
							case DialogResult.Cancel:
								return null;
							case DialogResult.Retry:
								// Loop around until user gets tired.
								break;
						}
					}
				}
				if (!fCompletedWizard)
				{
					if (ParatextProjHasUnmappedMarkers(importSettings))
					{
						// TODO: Show message box and then bring up import wizard
					}
				}
			}

			return importSettings;
		}