コード例 #1
0
ファイル: BulkEditBar.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Make a TransduceMethod (used in preview and apply click methods for Transduce tab).
		/// </summary>
		/// <param name="newCol">obtains the index of the active column.</param>
		/// <returns></returns>
		TransduceMethod MakeTransduceMethod(out int newCol)
		{
			newCol = 0;  // in case we fail.
			FieldComboItem fci = m_transduceTargetCombo.SelectedItem as FieldComboItem;
			if (fci == null)
			{
				MessageBox.Show(XMLViewsStrings.ksChooseDestination);
				return null;
			}
			FieldComboItem fciSrc = m_transduceSourceCombo.SelectedItem as FieldComboItem;
			if (fciSrc == null)
			{
				MessageBox.Show(XMLViewsStrings.ksChooseSource);
				return null;
			}
			newCol = fci.ColumnIndex + 1;
			int srcCol = fciSrc.ColumnIndex + 1;
			string convName = m_transduceProcessorCombo.SelectedItem as string;
			if (convName == null)
			{
				MessageBox.Show(XMLViewsStrings.ksChooseTransducer, XMLViewsStrings.ksSelectProcess);
				return null;
			}

			ECInterfaces.IEncConverters encConverters = null;
			try
			{
				encConverters = new SilEncConverters31.EncConverters();
			}
			catch (Exception e)
			{
				MessageBox.Show(String.Format(XMLViewsStrings.ksCannotAccessEC, e.Message));
				return null;
			}
			ECInterfaces.IEncConverter converter = encConverters[convName];
			return new TransduceMethod(m_cache, fci.Accessor,
				m_bv.ColumnSpecs[fci.ColumnIndex] as XmlNode,
				fciSrc.Accessor, converter,
				m_trdNonEmptyTargetControl.TssSeparator, m_trdNonEmptyTargetControl.NonEmptyMode);
		}
コード例 #2
0
ファイル: BulkEditBar.cs プロジェクト: sillsdev/WorldPad
		/// <summary>
		/// Load the available (relevant) converters. Adapted from
		/// WritingSystemPropertiesDialog.LoadAvailableConverters.
		/// </summary>
		private void InitConverterCombo()
		{
			try
			{
				string selectedItem = m_transduceProcessorCombo.SelectedItem as string;
				ECInterfaces.IEncConverters encConverters = new SilEncConverters31.EncConverters();
				m_transduceProcessorCombo.Items.Clear();
				foreach (string convName in encConverters.Keys)
				{
					ECInterfaces.IEncConverter conv = encConverters[convName];
					// Only Unicode-to-Unicode converters are relevant.
					if (conv.ConversionType == ECInterfaces.ConvType.Unicode_to_Unicode
						|| conv.ConversionType == ECInterfaces.ConvType.Unicode_to_from_Unicode)
						m_transduceProcessorCombo.Items.Add(convName);
				}
				if (!String.IsNullOrEmpty(selectedItem))
					m_transduceProcessorCombo.SelectedItem = selectedItem; // preserve selection if possible
				else if (m_transduceProcessorCombo.Items.Count > 0)
					m_transduceProcessorCombo.SelectedIndex = 0;
			}
			catch (Exception e)
			{
				MessageBox.Show(String.Format(XMLViewsStrings.ksCannotAccessEC, e.Message));
				return;
			}
		}
コード例 #3
0
ファイル: LexImportWizard.cs プロジェクト: sillsdev/WorldPad
		/// <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();
		}