Inheritance: SIL.FieldWorks.Common.Controls.WizardDialog, IFwExtension
Exemplo n.º 1
0
		/// <summary>
		/// From IFwExtension
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="mediator"></param>
		void IFwExtension.Init(FdoCache cache, XCore.Mediator mediator)
		{
			CheckDisposed();

			m_wizard = this;
			m_cache = cache;
			m_mediator = mediator;
			if (mediator != null)
			{
				m_app = (IApp) mediator.PropertyTable.GetValue("App");
				m_stylesheet = FontHeightAdjuster.StyleSheetFromMediator(mediator);
			}
			m_dirtyInputFile = true;
			m_dirtyMapFile = true;
//			m_hasShownIFMs = false;
			m_processedInputFile = m_processedMapFile = string.Empty;	// no files processed yet
//			m_autoImportFields = new Hashtable();
			m_isPhaseInputFile = false;

			InitOutputFiles();
			SetDatabaseNameIntoLabel();

			// read in the Lex Import Fields
			m_LexFields = new Sfm2Xml.LexImportFields();
			m_LexFields.ReadLexImportFields(m_sImportFields);

			// now read in any custom fields
			// m_CustomFields = new Sfm2Xml.LexImportFields();
			bool customFieldsChanged = false;
			m_CustomFields = ReadCustomFieldsFromDB(out customFieldsChanged);	// compare with map file before showing the UI and before the Import

			// set up default button states
			NextButtonEnabled = true;
			AcceptButton = null;
			btnModifyMappingLanguage.Enabled = false;
			btnModifyContentMapping.Enabled = false;
			string dictFileToImport = string.Empty;
			m_SettingsFileName.Items.Clear();
			m_SettingsFileName.Items.Add(m_sMDFImportMap);

			if (GetLastImportFile(out dictFileToImport))
			{
				FindFilesForDatabaseFile(dictFileToImport);
				m_DatabaseFileName.Text = dictFileToImport;

				HandleDBFileNameChanges();
			}
			else
			{
				m_SaveAsFileName.Text = string.Empty;	// empty if not found already
			}
			AllowQuickFinishButton();	// show it if it's valid

			// Copied from the previous LexImport dlg constructor (ImportLexicon.cs)
			// Ensure that we have the default encoding converter (to/from MS Windows Code Page
			// for Western European languages)
			EnsureWindows1252ConverterExists();

			ShowSaveButtonOrNot();
		}
Exemplo n.º 2
0
		/// <summary>
		/// From IFwExtension
		/// </summary>
		/// <param name="cache"></param>
		/// <param name="mediator"></param>
		void IFwExtension.Init(FdoCache cache, XCore.Mediator mediator)
		{
			CheckDisposed();

			m_wizard = this;
			m_cache = cache;
			m_mediator = mediator;
			m_dirtyInputFile = true;
			m_dirtyMapFile = true;
			m_hasShownIFMs = false;
			m_processedInputFile = m_processedMapFile = string.Empty;	// no files processed yet
			m_autoImportFields = new Hashtable();
			m_isPhaseInputFile = false;

			InitOutputFiles();
			SetDatabaseNameIntoLabel();

			// read in the Lex Import Fields
			m_LexFields = new Sfm2Xml.LexImportFields();
			m_LexFields.ReadLexImportFields(m_sImportFields);

			// now read in any custom fields
			// m_CustomFields = new Sfm2Xml.LexImportFields();
			bool customFieldsChanged = false;
			m_CustomFields = ReadCustomFieldsFromDB(out customFieldsChanged);	// compare with map file before showing the UI and before the Import

			// set up default button states
			NextButtonEnabled = true;
			AcceptButton = null;
			btnModifyMappingLanguage.Enabled = false;
			btnModifyContentMapping.Enabled = false;
			string dictFileToImport = string.Empty;
			m_SettingsFileName.Items.Clear();
			m_SettingsFileName.Items.Add(m_sMDFImportMap);

			if (GetLastImportFile(out dictFileToImport))
			{
				FindFilesForDatabaseFile(dictFileToImport);
				m_DatabaseFileName.Text = dictFileToImport;

				HandleDBFileNameChanges();
			}
			else
			{
				m_SaveAsFileName.Text = string.Empty;	// empty if not found already
			}
			AllowQuickFinishButton();	// show it if it's valid

			// Copied from the previous LexImport dlg constructor (ImportLexicon.cs)
			// Ensure that we have the default encoding converter (to/from MS Windows Code Page
			// for Western European languages)
			SilEncConverters31.EncConverters encConv = new SilEncConverters31.EncConverters();
			System.Collections.IDictionaryEnumerator de = encConv.GetEnumerator();
			// REVIEW: SHOULD THIS NAME BE LOCALIZED?
			string sEncConvName = "Windows1252<>Unicode";
			bool fMustCreateEncCnv = true;
			while (de.MoveNext())
			{
				if ((string)de.Key != null && (string)de.Key == sEncConvName)
				{
					fMustCreateEncCnv = false;
					break;
				}
			}
			if (fMustCreateEncCnv)
			{
				try
				{
					encConv.AddConversionMap(sEncConvName, "1252",
						ECInterfaces.ConvType.Legacy_to_from_Unicode, "cp", "", "",
						ECInterfaces.ProcessTypeFlags.CodePageConversion);
				}
				catch (SilEncConverters31.ECException exception)
				{
					MessageBox.Show(exception.Message, LexTextControls.ksConvMapError,
						MessageBoxButtons.OK);
				}
			}

			ShowSaveButtonOrNot();
		}