public AdaptItGuesserAutoConfigDialog
			(
			IEncConverters aECs,
			string strDisplayName,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strLhsEncodingId,
			string strRhsEncodingId,
			int lProcessTypeFlags,
			bool bIsInRepository
			)
		{
			base.Initialize
			(
			aECs,
			AdaptItGuesserEncConverter.strHtmlFilename,
			strDisplayName,
			strFriendlyName,
			strConverterIdentifier,
			eConversionType,
			strLhsEncodingId,
			strRhsEncodingId,
			lProcessTypeFlags,
			bIsInRepository
			);
		}
Пример #2
0
		public CpAutoConfigDialog
			(
			IEncConverters aECs,
			string strDisplayName,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strLhsEncodingId,
			string strRhsEncodingId,
			int lProcessTypeFlags,
			bool bIsInRepository
			)
		{
			InitializeComponent();

			base.Initialize
			(
			aECs,
			CpEncConverter.strHtmlFilename,
			strDisplayName,
			strFriendlyName,
			strConverterIdentifier,
			eConversionType,
			strLhsEncodingId,
			strRhsEncodingId,
			lProcessTypeFlags,
			bIsInRepository
			);

			m_bQueryForConvType = false; // the converter determines this itself.

			if (m_encInfos != null)
				foreach (EncodingInfo encInfo in m_encInfos)
				{
					// String str = String.Format("CodePage: {0}, DisplayName: {1}, Name: {2}", encInfo.CodePage, encInfo.DisplayName, encInfo.Name);
					String str = Convert.ToString(encInfo.CodePage, 10);
					comboBoxCodePageList.Items.Add(str);
				}

			// if we're editing ...
			if (m_bEditMode)
			{
				int nIndex = comboBoxCodePageList.Items.IndexOf(ConverterIdentifier);
				if (nIndex != -1)
				{
					comboBoxCodePageList.SelectedIndex = nIndex;
					IsModified = false;
				}
			}
			else
			{
				int nIndex = comboBoxCodePageList.Items.IndexOf(cstrDefaultCodePageToSelect);
				if (nIndex != -1)
					comboBoxCodePageList.SelectedIndex = nIndex;
			}
		}
Пример #3
0
		/// <summary>
		/// This is the base class for the two different AdaptIt EncConverters: the Lookup transducer and the
		/// Guesser API transducer. Since both of these types have the same configuration dialog, most of the
		/// implementation can be put into this class, while the subclasses are used for the specifics to
		/// each (if there is none, then you can just get rid of this class)
		/// </summary>
		public override void Initialize
			(
			IEncConverters aECs,
			string strHtmlFileName,
			string strDisplayName,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strLhsEncodingId,
			string strRhsEncodingId,
			int lProcessTypeFlags,
			bool bIsInRepository
			)
		{
			InitializeComponent();

			base.Initialize
			(
			aECs,
			strHtmlFileName,
			strDisplayName,
			strFriendlyName,
			strConverterIdentifier,
			eConversionType,
			strLhsEncodingId,
			strRhsEncodingId,
			lProcessTypeFlags,
			bIsInRepository
			);

			m_bQueryForConvType = false;    // don't need to do this for this converter type (or we do, but differently)

			if (m_bEditMode)
				m_bLegacy = (strConverterIdentifier.IndexOf(cstrAdaptItWorkingDirLegacy) != -1);

			if (m_bLegacy)
			{
				InitProjectNames(cstrAdaptItWorkingDirLegacy, true);
				radioButtonLegacy.Checked = true;
			}
			else
			{
				InitProjectNames(cstrAdaptItWorkingDirUnicode, false);
				radioButtonUnicode.Checked = true;
			}

			if (m_bEditMode)
			{
				int nIndex = listBoxProjects.Items.IndexOf(ProjectNameFromConverterSpec);
				if (nIndex != -1)
					listBoxProjects.SelectedIndex = nIndex;

				IsModified = false;
			}
		}
Пример #4
0
		public override bool Configure
		(
		IEncConverters aECs,
		string strFriendlyName,
		ConvType eConversionType,
		string strLhsEncodingID,
		string strRhsEncodingID
		)
		{
			CcAutoConfigDialog form = new CcAutoConfigDialog(aECs, m_strDisplayName, m_strFriendlyName,
				m_strConverterID, m_eConversionType, m_strLhsEncodingID, m_strRhsEncodingID,
				m_lProcessType, m_bIsInRepository);

			return base.Configure(form);
		}
Пример #5
0
        public override bool Configure
        (
            IEncConverters aECs,
            string strFriendlyName,
            ConvType eConversionType,
            string strLhsEncodingID,
            string strRhsEncodingID
        )
        {
            CpAutoConfigDialog form = new CpAutoConfigDialog(aECs, m_strDisplayName, m_strFriendlyName,
                                                             m_strConverterID, m_eConversionType, m_strLhsEncodingID, m_strRhsEncodingID,
                                                             m_lProcessType, m_bIsInRepository);

            return(base.Configure(form));
        }
 public PerlExpressionAutoConfigDialog(
     IEncConverters aECs,
     string strFriendlyName,
     string strConverterIdentifier,
     ConvType eConversionType,
     string strTestData)
 {
     InitializeComponent();
     base.Initialize(
         aECs,
         strFriendlyName,
         strConverterIdentifier,
         eConversionType,
         strTestData);
 }
Пример #7
0
		protected bool m_bInitialized = false;  // set at the end of Initialize (to block certain events until we're ready for them)

		public CcAutoConfigDialog
			(
			IEncConverters aECs,
			string strDisplayName,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strLhsEncodingId,
			string strRhsEncodingId,
			int lProcessTypeFlags,
			bool bIsInRepository
			)
		{
			InitializeComponent();

			base.Initialize
			(
			aECs,
			CcEncConverter.strHtmlFilename,
			strDisplayName,
			strFriendlyName,
			strConverterIdentifier,
			eConversionType,
			strLhsEncodingId,
			strRhsEncodingId,
			lProcessTypeFlags,
			bIsInRepository
			);

			// if we're editing a CC table/spellfixer project, then set the Converter Spec and say it's unmodified
			if (m_bEditMode)
			{
				System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));
				textBoxFileSpec.Text = ConverterIdentifier;
				IsModified = false;
			}

			// if we're editing a SpellFixer project, then the converter is managed by the SpellFixer
			//  project dialog, so we don't need to have an "Save in Repository" button.
			UpdateUI(!IsSpellFixerProject);

			m_bInitialized = true;

			helpProvider.SetHelpString(textBoxFileSpec, Properties.Resources.ConverterFileSpecHelpString);
			helpProvider.SetHelpString(buttonBrowse, Properties.Resources.BrowseFileSpecHelpString);
			helpProvider.SetHelpString(groupBoxExpects, Properties.Resources.ConvTypeExpectsHelpString);
			helpProvider.SetHelpString(groupBoxReturns, Properties.Resources.ConvTypeReturnsHelpString);
		}
Пример #8
0
        protected bool m_bInitialized = false;          // set at the end of Initialize (to block certain events until we're ready for them)

        public CcAutoConfigDialog
        (
            IEncConverters aECs,
            string strDisplayName,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strLhsEncodingId,
            string strRhsEncodingId,
            int lProcessTypeFlags,
            bool bIsInRepository
        )
        {
            InitializeComponent();

            base.Initialize
            (
                aECs,
                CcEncConverter.strHtmlFilename,
                strDisplayName,
                strFriendlyName,
                strConverterIdentifier,
                eConversionType,
                strLhsEncodingId,
                strRhsEncodingId,
                lProcessTypeFlags,
                bIsInRepository
            );

            // if we're editing a CC table/spellfixer project, then set the Converter Spec and say it's unmodified
            if (m_bEditMode)
            {
                System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));
                textBoxFileSpec.Text = ConverterIdentifier;
                IsModified           = false;
            }

            // if we're editing a SpellFixer project, then the converter is managed by the SpellFixer
            //  project dialog, so we don't need to have an "Save in Repository" button.
            UpdateUI(!IsSpellFixerProject);

            m_bInitialized = true;

            helpProvider.SetHelpString(textBoxFileSpec, Properties.Resources.ConverterFileSpecHelpString);
            helpProvider.SetHelpString(buttonBrowse, Properties.Resources.BrowseFileSpecHelpString);
            helpProvider.SetHelpString(groupBoxExpects, Properties.Resources.ConvTypeExpectsHelpString);
            helpProvider.SetHelpString(groupBoxReturns, Properties.Resources.ConvTypeReturnsHelpString);
        }
Пример #9
0
 public IcuTranslitAutoConfigDialog(
     IEncConverters aECs,
     string strFriendlyName,
     string strConverterIdentifier,
     ConvType eConversionType,
     string strTestData)
 {
     InitializeComponent();
     fillListBox();
     base.Initialize(
         aECs,
         strFriendlyName,
         strConverterIdentifier,
         eConversionType,
         strTestData);
     m_bInitialized = true;
 }
Пример #10
0
        public TecAutoConfigDialog
        (
            IEncConverters aECs,
            string strDisplayName,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strLhsEncodingId,
            string strRhsEncodingId,
            int lProcessTypeFlags,
            bool bIsInRepository
        )
        {
            Util.DebugWriteLine(this, "(1) BEGIN");
            InitializeComponent();
            Util.DebugWriteLine(this, "initialized component");

            base.Initialize
            (
                aECs,
                TecEncConverter.strHtmlFilename,
                strDisplayName,
                strFriendlyName,
                strConverterIdentifier,
                eConversionType,
                strLhsEncodingId,
                strRhsEncodingId,
                lProcessTypeFlags,
                bIsInRepository
            );
            Util.DebugWriteLine(this, "called base.Initalize");

            // if we're editing a TECkit map, then set the Converter Spec and say it's unmodified
            if (m_bEditMode)
            {
                System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));
                textBoxFileSpec.Text = ConverterIdentifier;
                IsModified           = false;
            }

            m_bInitialized = true;

            Util.DebugWriteLine(this, "setting help string");
            helpProvider.SetHelpString(textBoxFileSpec, Properties.Resources.ConverterFileSpecHelpString);
            Util.DebugWriteLine(this, "END");
        }
Пример #11
0
		public override void DisplayTestPage
			(
			IEncConverters aECs,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strTestData
			)
		{
			InitializeFromThis(ref strFriendlyName, ref strConverterIdentifier,
				ref eConversionType, ref strTestData);

			CcAutoConfigDialog form = new CcAutoConfigDialog(aECs, strFriendlyName,
				strConverterIdentifier, eConversionType, strTestData);

			base.DisplayTestPage(form);
		}
 public PyScriptAutoConfigDialog(
     IEncConverters aECs,
     string strFriendlyName,
     string strConverterIdentifier,
     ConvType eConversionType,
     string strTestData)
 {
     Util.DebugWriteLine(this, "ctor2 BEGIN");
     InitializeComponent();
     base.Initialize(
         aECs,
         strFriendlyName,
         strConverterIdentifier,
         eConversionType,
         strTestData);
     Util.DebugWriteLine(this, "END");
 }
        public PerlExpressionAutoConfigDialog(
            IEncConverters aECs,
            string strDisplayName,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strLhsEncodingId,
            string strRhsEncodingId,
            int lProcessTypeFlags,
            bool bIsInRepository)
        {
            Util.DebugWriteLine(this, "BEGIN");
            InitializeComponent();
            Util.DebugWriteLine(this, "Initialized component.");
            base.Initialize(
                aECs,
                PerlExpressionEncConverter.strHtmlFilename,
                strDisplayName,
                strFriendlyName,
                strConverterIdentifier,
                eConversionType,
                strLhsEncodingId,
                strRhsEncodingId,
                lProcessTypeFlags | (int)ProcessTypeFlags.PerlExpression,
                bIsInRepository);
            Util.DebugWriteLine(this, "Initialized base.");
            // if we're editing a CC table/spellfixer project, then set the Converter Spec and say it's unmodified
            if (m_bEditMode)
            {
                Util.DebugWriteLine(this, "Edit mode");
                System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));
                textBoxExpression.Text = ConverterIdentifier;
                IsModified             = false;
            }

            // initialize the combo box with some examples that users can try
            LoadComboBoxFromSettings(comboBoxPreviousPerlExpressions, Settings.Default.RecentlyUsedExpressions);

            if (comboBoxPreviousPerlExpressions.Items.Count > 0)
            {
                comboBoxPreviousPerlExpressions.SelectedIndex = 0;
            }

            m_bInitialized = true;
            Util.DebugWriteLine(this, "END");
        }
Пример #14
0
        public override void DisplayTestPage
        (
            IEncConverters aECs,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strTestData
        )
        {
            InitializeFromThis(ref strFriendlyName, ref strConverterIdentifier,
                               ref eConversionType, ref strTestData);

            TechHindiSiteAutoConfigDialog form = new TechHindiSiteAutoConfigDialog(aECs, strFriendlyName,
                                                                                   strConverterIdentifier, eConversionType, strTestData);

            base.DisplayTestPage(form);
        }
		public AdaptItGuesserAutoConfigDialog
			(
			IEncConverters aECs,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strTestData
			)
		{
			base.Initialize
			(
			aECs,
			strFriendlyName,
			strConverterIdentifier,
			eConversionType,
			strTestData
			);
		}
Пример #16
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a text segment enumerator for importing a project
		/// </summary>
		/// <param name="firstRef">start reference for importing</param>
		/// <param name="lastRef">end reference for importing</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public ISCTextEnum TextEnum(BCVRef firstRef, BCVRef lastRef)
		{
			try
			{
				if (m_encConverters == null)
					m_encConverters = new EncConverters();
			}
			catch (DirectoryNotFoundException ex)
			{
				string message = string.Format(ScriptureUtilsException.GetResourceString(
						"kstidEncConverterInitError"), ex.Message);
				throw new EncodingConverterException(message,
					"/Beginning_Tasks/Import_Standard_Format/Unable_to_Import/Encoding_converter_not_found.htm");
			}

			// get the enumerator that will return text segments
			return new SCTextEnum(m_settings, m_domain, firstRef, lastRef, m_encConverters);
		}
Пример #17
0
        public override void DisplayTestPage
        (
            IEncConverters aECs,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strTestData
        )
        {
            Console.Error.WriteLine("TecEncConverterConfig.DisplayTestPage() BEGIN");
            InitializeFromThis(ref strFriendlyName, ref strConverterIdentifier,
                               ref eConversionType, ref strTestData);

            TecAutoConfigDialog form = new TecAutoConfigDialog(aECs, strFriendlyName,
                                                               strConverterIdentifier, eConversionType, strTestData);

            base.DisplayTestPage(form);
        }
Пример #18
0
 public AdaptItLookupAutoConfigDialog
 (
     IEncConverters aECs,
     string strFriendlyName,
     string strConverterIdentifier,
     ConvType eConversionType,
     string strTestData
 )
 {
     base.Initialize
     (
         aECs,
         strFriendlyName,
         strConverterIdentifier,
         eConversionType,
         strTestData
     );
 }
        public override bool Configure
        (
            IEncConverters aECs,
            string strFriendlyName,
            ConvType eConversionType,
            string strLhsEncodingID,
            string strRhsEncodingID
        )
        {
            var form = new IcuTranslitAutoConfigDialog(
                aECs, m_strDisplayName, m_strFriendlyName,
                m_strConverterID, m_eConversionType,
                BestGuessEncoding(m_strLhsEncodingID, strLhsEncodingID, EncConverters.strDefUnicodeEncoding),
                BestGuessEncoding(m_strRhsEncodingID, strRhsEncodingID, EncConverters.strDefUnicodeEncoding),
                m_lProcessType, m_bIsInRepository);

            return(Configure(form));
        }
Пример #20
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Create a text segment enumerator for importing a project
		/// </summary>
		/// <param name="firstRef">start reference for importing</param>
		/// <param name="lastRef">end reference for importing</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public ISCTextEnum TextEnum(BCVRef firstRef, BCVRef lastRef)
		{
			try
			{
				if (m_encConverters == null)
					m_encConverters = new EncConverters();
			}
			catch (DirectoryNotFoundException ex)
			{
				string message = string.Format(ScriptureUtilsException.GetResourceString(
						"kstidEncConverterInitError"), ex.Message);
				throw new EncodingConverterException(message,
					"/Beginning_Tasks/Import_Standard_Format/Unable_to_Import/Encoding_converter_not_found.htm");
			}

			// get the enumerator that will return text segments
			return new SCTextEnum(m_settings, m_domain, firstRef, lastRef, m_encConverters);
		}
        public IcuConvAutoConfigDialog(
            IEncConverters aECs,
            string strDisplayName,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strLhsEncodingId,
            string strRhsEncodingId,
            int lProcessTypeFlags,
            bool bIsInRepository)
        {
            Util.DebugWriteLine(this, "BEGIN");

            InitializeComponent();
            fillListBox();
            Util.DebugWriteLine(this, "Initialized component.");
            base.Initialize(
                aECs,
                IcuConvEncConverter.strHtmlFilename,
                strDisplayName,
                strFriendlyName,
                strConverterIdentifier,
                eConversionType,
                strLhsEncodingId,
                strRhsEncodingId,
                lProcessTypeFlags | (int)ProcessTypeFlags.ICUConverter,
                bIsInRepository);
            Util.DebugWriteLine(this, "Initialized base.");

            // if we're editing, then set the Converter Spec and say it's unmodified
            if (m_bEditMode)
            {
                Util.DebugWriteLine(this, "Edit mode");
                System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));
                var index = listBoxConvName.FindString(ConverterIdentifier);
                listBoxConvName.SelectedIndex = index;
                IsModified = false;
            }

            m_bInitialized = true;
            Util.DebugWriteLine(this, "END");
        }
Пример #22
0
		public TecAutoConfigDialog
			(
			IEncConverters aECs,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strTestData
			)
		{
			InitializeComponent();

			base.Initialize
			(
			aECs,
			strFriendlyName,
			strConverterIdentifier,
			eConversionType,
			strTestData
			);
		}
Пример #23
0
		public TecAutoConfigDialog
			(
			IEncConverters aECs,
			string strDisplayName,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strLhsEncodingId,
			string strRhsEncodingId,
			int lProcessTypeFlags,
			bool bIsInRepository
			)
		{
			InitializeComponent();

			base.Initialize
			(
			aECs,
			TecEncConverter.strHtmlFilename,
			strDisplayName,
			strFriendlyName,
			strConverterIdentifier,
			eConversionType,
			strLhsEncodingId,
			strRhsEncodingId,
			lProcessTypeFlags,
			bIsInRepository
			);

			// if we're editing a TECkit map, then set the Converter Spec and say it's unmodified
			if (m_bEditMode)
			{
				System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));
				textBoxFileSpec.Text = ConverterIdentifier;
				IsModified = false;
			}

			m_bInitialized = true;

			helpProvider.SetHelpString(textBoxFileSpec, Properties.Resources.ConverterFileSpecHelpString);
		}
Пример #24
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Initializes a new instance of the <see cref="SCTextEnum"/> class.
        /// </summary>
        /// <param name="settings">The import settings</param>
        /// <param name="domain">The source domain</param>
        /// <param name="startRef">first reference to retrieve</param>
        /// <param name="endRef">last reference to retrieve</param>
        /// ------------------------------------------------------------------------------------
        public SCTextEnum(IScrImportSet settings, ImportDomain domain,
                          BCVRef startRef, BCVRef endRef)
        {
            m_settings   = settings;
            m_domain     = domain;
            m_startRef   = new BCVRef(startRef);
            m_endRef     = new BCVRef(endRef);
            m_mappingSet = ((ScrImportSet)m_settings).GetMappingSetForDomain(domain);

            // Gets the set of encoding converters
            m_encConverters = new EncConverters();

            // make a list of all of the begin and end markers for inline markers
            // Also build the map of encoding converters
            m_InlineBeginAndEndMarkers = new List <string>();
            foreach (ImportMappingInfo mapping in ((ScrImportSet)m_settings).GetMappingListForDomain(domain))
            {
                if (mapping.IsInline || m_settings.ImportTypeEnum == TypeOfImport.Paratext5)
                {
                    m_InlineBeginAndEndMarkers.Add(mapping.BeginMarker);
                    if (mapping.IsInline)
                    {
                        m_InlineBeginAndEndMarkers.Add(mapping.EndMarker);
                    }
                }
            }

            m_InlineBeginAndEndMarkers.Sort(new LengthComparer());

            // Build a list of all of the characters that inline markers start with
            Set <char> tempCharList = new Set <char>();

            foreach (string marker in m_InlineBeginAndEndMarkers)
            {
                tempCharList.Add(marker[0]);                 // Set ignores duplicates.
            }
            m_InlineMarkerStartChars = tempCharList.ToArray();
            // Get the import file source that will provide the files to import.
            m_importSource     = ((ScrImportSet)settings).GetImportFiles(domain);
            m_importSourceEnum = m_importSource.GetEnumerator();
        }
Пример #25
0
        public override bool Configure
        (
            IEncConverters aECs,
            string strFriendlyName,
            ConvType eConversionType,
            string strLhsEncodingID,
            string strRhsEncodingID
        )
        {
#if VERBOSE_DEBUGGING
            Console.WriteLine("TecEncConverterConfig(3).Configure BEGIN");
#endif
            TecAutoConfigDialog form = new TecAutoConfigDialog(aECs, m_strDisplayName, m_strFriendlyName,
                                                               m_strConverterID, m_eConversionType, m_strLhsEncodingID, m_strRhsEncodingID,
                                                               m_lProcessType, m_bIsInRepository);

#if VERBOSE_DEBUGGING
            Console.WriteLine("TecEncConverterConfig.Configure END");
#endif
            return(base.Configure(form));
        }
 public PyScriptAutoConfigDialog(
     IEncConverters aECs,
     string strDisplayName,
     string strFriendlyName,
     string strConverterIdentifier,
     ConvType eConversionType,
     string strLhsEncodingId,
     string strRhsEncodingId,
     int lProcessTypeFlags,
     bool bIsInRepository)
 {
     Util.DebugWriteLine(this, "ctor1 BEGIN");
     InitializeComponent();
     Util.DebugWriteLine(this, "Initialized component.");
     base.Initialize(
         aECs,
         PyScriptEncConverter.strHtmlFilename,
         strDisplayName,
         strFriendlyName,
         strConverterIdentifier,
         eConversionType,
         strLhsEncodingId,
         strRhsEncodingId,
         lProcessTypeFlags | (int)ProcessTypeFlags.PythonScript,
         bIsInRepository);
     Util.DebugWriteLine(this, "Initialized base.");
     // if we're editing a CC table/spellfixer project, then set the
     // Converter Spec and say it's unmodified
     if (m_bEditMode)
     {
         Util.DebugWriteLine(this, "Edit mode");
         System.Diagnostics.Debug.Assert(
             !String.IsNullOrEmpty(ConverterIdentifier));
         textBoxFileSpec.Text = ConverterIdentifier;
         IsModified           = false;
     }
     m_bInitialized = true;
     Util.DebugWriteLine(this, "END");
 }
Пример #27
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="SCTextEnum"/> class.
		/// </summary>
		/// <param name="settings">The import settings</param>
		/// <param name="domain">The source domain</param>
		/// <param name="startRef">first reference to retrieve</param>
		/// <param name="endRef">last reference to retrieve</param>
		/// <param name="encConverters">The encoding converters repository</param>
		/// ------------------------------------------------------------------------------------
		public SCTextEnum(IScrImportSet settings, ImportDomain domain,
			BCVRef startRef, BCVRef endRef, IEncConverters encConverters)
		{
			m_settings = settings;
			m_domain = domain;
			m_startRef = new BCVRef(startRef);
			m_endRef = new BCVRef(endRef);
			m_mappingSet = m_settings.GetMappingSetForDomain(domain);

			// Gets the set of encoding converters
			m_encConverters = encConverters;

			// make a list of all of the begin and end markers for inline markers
			// Also build the map of encoding converters
			m_InlineBeginAndEndMarkers = new List<string>();
			foreach (ImportMappingInfo mapping in m_settings.GetMappingListForDomain(domain))
			{
				if (mapping.IsInline || m_settings.ImportTypeEnum == TypeOfImport.Paratext5)
				{
					m_InlineBeginAndEndMarkers.Add(mapping.BeginMarker);
					if (mapping.IsInline)
						m_InlineBeginAndEndMarkers.Add(mapping.EndMarker);
				}
			}

			m_InlineBeginAndEndMarkers.Sort(new StrLengthComparer(false));

			// Build a list of all of the characters that inline markers start with
			Set<char> tempCharList = new Set<char>();
			foreach (string marker in m_InlineBeginAndEndMarkers)
				tempCharList.Add(marker[0]); // Set ignores duplicates.

			m_InlineMarkerStartChars = tempCharList.ToArray();
			// Get the import file source that will provide the files to import.
			m_importSource = settings.GetImportFiles(domain);
			m_importSourceEnum = m_importSource.GetEnumerator();
		}
        public virtual void Initialize
        (
            IEncConverters aECs,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strTestData
        )
        {
            Util.DebugWriteLine(this, "BEGIN");
            FriendlyName        = strFriendlyName;
            ConverterIdentifier = strConverterIdentifier;
            ConversionType      = eConversionType;

            m_aECs = aECs;
            m_aEC  = InitializeEncConverter;

            tabControl.Controls.Remove(tabPageAbout);
            tabControl.Controls.Remove(tabPageSetup);
            tabControl.Controls.Remove(tabPageAdvanced);

            // for 'test', it's possible that there may be some font mapping in the repository
            string strLhsName, strRhsName;

            if (m_aECs.GetFontMappingFromMapping(strFriendlyName, out strLhsName, out strRhsName))
            {
                ecTextBoxInput.Font  = CreateFontSafe(strLhsName, ecTextBoxInput.Font);
                ecTextBoxOutput.Font = CreateFontSafe(strRhsName, ecTextBoxOutput.Font);
            }

            ecTextBoxInput.Text = strTestData;
            buttonOK.Visible    = buttonApply.Visible = false;
            buttonCancel.Text   = "Close";

            helpProvider.SetHelpString(buttonCancel, Properties.Resources.CloseButtonHelpString);
        }
Пример #29
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected override void CreateTestData()
		{
			m_settings = Cache.ServiceLocator.GetInstance<IScrImportSetFactory>().Create();
			Cache.LangProject.TranslatedScriptureOA.ImportSettingsOC.Add(m_settings);
			m_settings.ImportTypeEnum = TypeOfImport.Other;
			m_converters = null;
			m_fileOs = new MockFileOS();
			FileUtils.Manager.SetFileAdapter(m_fileOs);
		}
Пример #30
0
		public FallbackAutoConfigDialog
			(
			IEncConverters aECs,
			string strDisplayName,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strLhsEncodingId,
			string strRhsEncodingId,
			int lProcessTypeFlags,
			bool bIsInRepository
			)
		{
			if (aECs.Count == 0)
			{
				MessageBox.Show("Unable to find any existing converters! You must add some before attempting to chain them together.");
				return;
			}

			InitializeComponent();

			base.Initialize
			(
			aECs,
			FallbackEncConverter.strHtmlFilename,
			strDisplayName,
			strFriendlyName,
			strConverterIdentifier,
			eConversionType,
			strLhsEncodingId,
			strRhsEncodingId,
			lProcessTypeFlags,
			bIsInRepository
			);

			// if we're editing ...
			if (m_bEditMode)
			{
				System.Diagnostics.Debug.Assert(m_aEC != null);
				System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));

				labelCompoundConverterName.Text = FriendlyName;

				if (m_aEC != null)
				{
					QueryStepData();    // get the data about the steps

					if (    ((m_astrStepFriendlyNames != null) && (m_astrStepFriendlyNames.Length == 2))
						&&  ((m_abDirectionForwards != null) && (m_abDirectionForwards.Length == 2)))
					{
						m_strPrimaryConverter = m_astrStepFriendlyNames[(int)PrimaryFallbackEnum.ePrimary];
						m_strFallbackConverter = m_astrStepFriendlyNames[(int)PrimaryFallbackEnum.eFallback];
						checkBoxReversePrimary.Checked = !m_abDirectionForwards[(int)PrimaryFallbackEnum.ePrimary];
						checkBoxReverseFallback.Checked = !m_abDirectionForwards[(int)PrimaryFallbackEnum.eFallback];
					}
				}

				IsModified = false;
			}

			// in any case, populate the combo boxes with the full list of available converters
			foreach (IEncConverter aEC in aECs.Values)
			{
				// don't let the primary-fallback converter be put into the lists
				if (strFriendlyName != aEC.Name)
				{
					comboBoxPrimary.Items.Add(aEC.Name);
					comboBoxFallback.Items.Add(aEC.Name);

					// if this is either the primary or the fallback, then also get the bidi status
					if (m_strPrimaryConverter == aEC.Name)
					{
						comboBoxPrimary.SelectedItem = m_strPrimaryConverter;   // select it in the combo box

						if (EncConverters.IsUnidirectional(aEC.ConversionType))
							checkBoxReversePrimary.Enabled = false;
					}
					else if (m_strFallbackConverter == aEC.Name)
					{
						comboBoxFallback.SelectedItem = m_strFallbackConverter; // select it in the combo box

						if (EncConverters.IsUnidirectional(aEC.ConversionType))
							checkBoxReverseFallback.Enabled = false;
					}
				}
			}

			// in case we set teh selected item in that last code, we don't want to treat that as the steady state situation
			//  (i.e. ignore the resultant SelectedItemChange event until after we're finished.
			m_bIgnoreSelItemChgWhileLoading = false;
		}
Пример #31
0
		public abstract void DisplayTestPage
			(
			IEncConverters aECs,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strTestData
			);
Пример #32
0
		public abstract bool Configure
			(
			IEncConverters aECs,
			string strFriendlyName,
			ConvType eConversionType,
			string strLhsEncodingID,
			string strRhsEncodingID
			);
Пример #33
0
		public ECAttributes(IEncConverters aECs, string sItem, AttributeType repositoryItem)
		{
			m_aECs = aECs;
			m_strItem = sItem;
			m_eAttributeType = repositoryItem;
		}
Пример #34
0
		public void ConvertAsciiToUnicode()
		{
			string encFileName = Path.Combine(Path.GetTempPath(), "test.map");
			try
			{
				using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(
					"SIL.FieldWorks.TE.EncTest.map"))
				{
					Assert.IsNotNull(stream);

					// Define an encoding converter
					using (StreamReader reader = new StreamReader(stream))
					{
						using (StreamWriter writer = new StreamWriter(encFileName))
						{
							writer.Write(reader.ReadToEnd());
						}
					}
				}

				m_converters = new EncConverters();
				m_converters.Add("MyConverter", encFileName, ConvType.Legacy_to_from_Unicode, string.Empty,
					string.Empty, ProcessTypeFlags.UnicodeEncodingConversion);
				Assert.NotNull(m_converters["MyConverter"], "MyConverter didn't get added");

				string filename = m_fileOs.MakeSfFile(Encoding.GetEncoding(EncodingConstants.kMagicCodePage),
					false, "ROM",
					@"\mt 0123456789",
					"\\s \u0081\u009a\u0096\u00b5",
					@"\c 1",
					@"\v 1");
				m_settings.AddFile(filename, ImportDomain.Main, null, null);

				// Set the vernacular WS to use the MyConverter encoder
				VernacularWs.LegacyMapping = "MyConverter";

				ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
					new ScrReference(45, 0, 0, ScrVers.English),
					new ScrReference(45, 1, 1, ScrVers.English));

				ISCTextSegment textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment");
				Assert.AreEqual(@"\id", textSeg.Marker);
				Assert.AreEqual("ROM ", textSeg.Text);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment");
				Assert.AreEqual(@"\mt", textSeg.Marker);
				Assert.AreEqual("\u0966\u0967\u0968\u0969\u096a\u096b\u096c\u096d\u096e\u096f ", textSeg.Text);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment");
				Assert.AreEqual(@"\s", textSeg.Marker);
				Assert.AreEqual("\u0492\u043a\u2013\u04e9 ", textSeg.Text);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment");
				Assert.AreEqual(@"\c", textSeg.Marker);
				Assert.AreEqual(@" ", textSeg.Text);

				textSeg = textEnum.Next();
				Assert.IsNotNull(textSeg, "Unable to read segment");
				Assert.AreEqual(@"\v", textSeg.Marker);
				Assert.AreEqual(@" ", textSeg.Text);
			}
			finally
			{
				m_converters.Remove("MyConverter");
				try
				{
					FileUtils.Delete(encFileName);
				}
				catch { }
			}
		}
Пример #35
0
		public CmpdAutoConfigDialog
			(
			IEncConverters aECs,
			string strDisplayName,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strLhsEncodingId,
			string strRhsEncodingId,
			int lProcessTypeFlags,
			bool bIsInRepository
			)
		{
			System.Diagnostics.Debug.Assert(aECs != null);
			if (aECs.Count == 0)
			{
				MessageBox.Show("No existing converters in the repository! You must add some before attempting to chain them together.");
				return;
			}

			InitializeComponent();

			base.Initialize
			(
			aECs,
			CmpdEncConverter.strHtmlFilename,
			strDisplayName,
			strFriendlyName,
			strConverterIdentifier,
			eConversionType,
			strLhsEncodingId,
			strRhsEncodingId,
			lProcessTypeFlags,
			bIsInRepository
			);

			// the NewRow should have (only) the "Click me" label
			dataGridViewSteps.Rows[0].Cells[cnStepNameColumn].Value = cstrClickMeMessage;

			// if we're editing ...
			if (m_bEditMode)
			{
				System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));

				labelCompoundConverterName.Text = FriendlyName; // FriendlyName was initialized during base.Initialize since we're editing

				System.Diagnostics.Debug.Assert(m_aEC != null); // m_aEC was initialized during base.Initialize since we have the friendly name ...
				if (m_aEC != null)  // ... but make sure anyway
				{
					QueryStepData();    // get the data about the steps

					for (int i = 0; i < m_astrStepFriendlyNames.Length; i++)
					{
						IEncConverter aEC = m_aECs[m_astrStepFriendlyNames[i]];
						if (aEC == null)
						{
							// this really can't happen, because if the converter isn't there when we subsequently open it,
							//  the call to QueryStepData (which calls m_aEC.ConverterNameEnum) will fail to return the
							//  now deleted step. But just in case...
							MessageBox.Show(String.Format("The converter '{0}' no longer exists. Removing from the compound converter", m_astrStepFriendlyNames[i]), EncConverters.cstrCaption);
							dataGridViewSteps.Rows.Insert(i, new object[] { cstrClickMeMessage, false, "None" });
						}
						else
						{
							// insert a row in the grid for this step
							dataGridViewSteps.Rows.Insert(i, 1);
							DataGridViewRow theRow = dataGridViewSteps.Rows[i];
							UpdateConverterCellValue(theRow, aEC);
							UpdateDirectionReverseCellValue(theRow, !m_abDirectionForwards[i], aEC);
							UpdateNormalizationCellValue(theRow, m_aeNormalizeFlags[i]);
							theRow.Tag = aEC;
						}
					}
				}

				IsModified = false;
				m_bAllStepsAreBidirectional = !EncConverters.IsUnidirectional(m_aEC.ConversionType);
			}
		}
Пример #36
0
 public ECAttributes(IEncConverters aECs, string sItem, AttributeType repositoryItem)
 {
     m_aECs           = aECs;
     m_strItem        = sItem;
     m_eAttributeType = repositoryItem;
 }
Пример #37
0
		public virtual void Initialize
			(
			IEncConverters aECs,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strTestData
			)
		{
			FriendlyName = strFriendlyName;
			ConverterIdentifier = strConverterIdentifier;
			ConversionType = eConversionType;

			m_aECs = aECs;
			m_aEC = InitializeEncConverter;

			tabControl.Controls.Remove(tabPageAbout);
			tabControl.Controls.Remove(tabPageSetup);
			tabControl.Controls.Remove(tabPageAdvanced);

			// for 'test', it's possible that there may be some font mapping in the repository
			string strLhsName, strRhsName;
			if (m_aECs.GetFontMappingFromMapping(strFriendlyName, out strLhsName, out strRhsName))
			{
				ecTextBoxInput.Font = CreateFontSafe(strLhsName, ecTextBoxInput.Font);
				ecTextBoxOutput.Font = CreateFontSafe(strRhsName, ecTextBoxOutput.Font);
			}

			ecTextBoxInput.Text = strTestData;
			buttonOK.Visible = buttonApply.Visible = false;
			buttonCancel.Text = "Close";

			helpProvider.SetHelpString(buttonCancel, Properties.Resources.CloseButtonHelpString);

		}
        public virtual void Initialize
        (
            IEncConverters aECs,
            string strHtmlFileName,
            string strDisplayName,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strLhsEncodingId,
            string strRhsEncodingId,
            int lProcessTypeFlags,
            bool bIsInRepository
        )
        {
            Util.DebugWriteLine(this, "AutoConfigDialog (2) BEGIN");
            htmlfilename = strHtmlFileName;
            m_strOriginalFriendlyName = FriendlyName = strFriendlyName;
            ConverterIdentifier       = strConverterIdentifier;
            LhsEncodingId             = strLhsEncodingId;
            RhsEncodingId             = strRhsEncodingId;
            m_eOrigConvType           = ConversionType = eConversionType;
            ProcessType    = lProcessTypeFlags;
            IsInRepository = bIsInRepository;

            m_aECs = aECs;

            // if the identifier is given, then it means we're editing.
            // (which means our button says *Update* rather than "Save in system repository"
            //  and we should ask during OnOK whether they want to update or not)
            m_bEditMode = !String.IsNullOrEmpty(ConverterIdentifier);

            // if we're editing, then it starts out clean
            IsModified = !m_bEditMode;

            // if we're editing, then we already have this converter in the collection (even if it's
            //  temporary)
            if (m_bEditMode)
            {
                m_aEC = m_aECs[FriendlyName];
                if (FriendlyName.IndexOf(EncConverters.cstrTempConverterPrefix) == 0)
                {
                    FriendlyName = m_strOriginalFriendlyName = null;
                }
            }

            // this parameter seems the most confusing and yet is a crucial part of EncConverters
            //  so if this is *given* to us, then just use those values rather than prompting the user
            //  for them (e.g. FW knows that the BulkEdits are Unicode_to_(from_)Unicode, so we don't
            //  have to bother the user with it.
            // If we're in 'edit' mode, it is often because the user has mis-configured these parameters
            //  so if edit mode, then query for the ConvType value.
            if ((ConversionType == ConvType.Unknown) || m_bEditMode)
            {
                m_bQueryForConvType = true;
                SetConvTypeControls();
            }

            this.Text = strDisplayName;

            // get the help for the about tab
            RegistryKey keyRoot = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\SIL\SilEncConverters40", false);

            if (keyRoot != null)
            {
                var strXmlFilePath = (string)keyRoot.GetValue("RootDir");
                if (String.IsNullOrEmpty(strXmlFilePath))
                {
                    throw new ApplicationException("The 'RootDir' registry key is not defined!? Perhaps the application needs to be re-installed. Ask the developer.");
                }
                strXmlFilePath = Path.Combine(strXmlFilePath, Path.Combine(@"Help", strHtmlFileName));
                System.Diagnostics.Debug.WriteLine(strXmlFilePath);
                System.Diagnostics.Debug.Assert(System.IO.File.Exists(strXmlFilePath), String.Format("Cannot find '{0}'. If this is a development machine, you need to add the following reg key to see the About help files: HLKM\\SOFTWARE\\SIL\\SilEncConverters40\\[RootDir] = '<parent folder where the 'help' sub-folder exists>' along with a trailing slash (e.g. \"C:\\fw\\lib\\release\\\")", strHtmlFileName));
                this.webBrowser.Navigate(strXmlFilePath);
            }
#if DEBUG
            else
            {
                throw new ApplicationException(@"Can't read the HLKM\SOFTWARE\SIL\SilEncConverters40\[RootDir] registry key, which should get created during installation.");
            }
#endif

            ecTextBoxInput.Text = "Test Data";
            //char[] chinese = {'\u6B22','\u8FCE','\u4F7F','\u7528','\u0020'};
            //ecTextBoxInput.Text = new string(chinese);
            Util.DebugWriteLine(this, "END");
        }
Пример #39
0
		public virtual void Initialize
			(
			IEncConverters aECs,
			string strHtmlFileName,
			string strDisplayName,
			string strFriendlyName,
			string strConverterIdentifier,
			ConvType eConversionType,
			string strLhsEncodingId,
			string strRhsEncodingId,
			int lProcessTypeFlags,
			bool bIsInRepository
			)
		{
			m_strOriginalFriendlyName = FriendlyName = strFriendlyName;
			ConverterIdentifier = strConverterIdentifier;
			LhsEncodingId = strLhsEncodingId;
			RhsEncodingId = strRhsEncodingId;
			m_eOrigConvType = ConversionType = eConversionType;
			ProcessType = lProcessTypeFlags;
			IsInRepository = bIsInRepository;

			m_aECs = aECs;

			// if the identifier is given, then it means we're editing.
			// (which means our button says *Update* rather than "Save in system repository"
			//  and we should ask during OnOK whether they want to update or not)
			m_bEditMode = !String.IsNullOrEmpty(ConverterIdentifier);

			// if we're editing, then it starts out clean
			IsModified = !m_bEditMode;

			// if we're editing, then we already have this converter in the collection (even if it's
			//  temporary)
			if (m_bEditMode)
			{
				m_aEC = m_aECs[FriendlyName];
				if (FriendlyName.IndexOf(EncConverters.cstrTempConverterPrefix) == 0)
					FriendlyName = m_strOriginalFriendlyName = null;
			}

			// this parameter seems the most confusing and yet is a crucial part of EncConverters
			//  so if this is *given* to us, then just use those values rather than prompting the user
			//  for them (e.g. FW knows that the BulkEdits are Unicode_to_(from_)Unicode, so we don't
			//  have to bother the user with it.
			// If we're in 'edit' mode, it is often because the user has mis-configured these parameters
			//  so if edit mode, then query for the ConvType value.
			if ((ConversionType == ConvType.Unknown) || m_bEditMode)
			{
				m_bQueryForConvType = true;
				SetConvTypeControls();
			}

			this.Text = strDisplayName;

			// get the help for the about tab
			RegistryKey keyRoot = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\SIL\SilEncConverters31", false);
			if (keyRoot != null)
			{
				string strXmlFilePath = (string)keyRoot.GetValue("RootDir");
				if (strXmlFilePath[strXmlFilePath.Length - 1] != '\\')
					strXmlFilePath += '\\';
				strXmlFilePath += @"help\" + strHtmlFileName;
				System.Diagnostics.Debug.Assert(System.IO.File.Exists(strXmlFilePath), String.Format("Can find '{0}'. If this is a development machine, you need to add the following reg key to see the About help files: HLKM\\SOFTWARE\\SIL\\SilEncConverters31\\[RootDir] = '<parent folder where the 'help' sub-folder exists>' along with a trailing slash (e.g. \"C:\\fw\\lib\\release\\\")", strHtmlFileName));
				this.webBrowserHelp.Url = new Uri(strXmlFilePath);
			}
#if DEBUG
			else
				throw new ApplicationException(@"Can't read the HLKM\SOFTWARE\SIL\SilEncConverters31\[RootDir] registry key!");
#endif

			ecTextBoxInput.Text = "Test Data";
		}
        public CmpdAutoConfigDialog
        (
            IEncConverters aECs,
            string strDisplayName,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strLhsEncodingId,
            string strRhsEncodingId,
            int lProcessTypeFlags,
            bool bIsInRepository
        )
        {
            System.Diagnostics.Debug.Assert(aECs != null);
            if (aECs.Count == 0)
            {
                MessageBox.Show("No existing converters in the repository! You must add some before attempting to chain them together.");
                return;
            }

            InitializeComponent();

            base.Initialize
            (
                aECs,
                CmpdEncConverter.strHtmlFilename,
                strDisplayName,
                strFriendlyName,
                strConverterIdentifier,
                eConversionType,
                strLhsEncodingId,
                strRhsEncodingId,
                lProcessTypeFlags,
                bIsInRepository
            );

            // the NewRow should have (only) the "Click me" label
            dataGridViewSteps.Rows[0].Cells[cnStepNameColumn].Value = cstrClickMeMessage;

            // if we're editing ...
            if (m_bEditMode)
            {
                System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));

                labelCompoundConverterName.Text = FriendlyName; // FriendlyName was initialized during base.Initialize since we're editing

                System.Diagnostics.Debug.Assert(m_aEC != null); // m_aEC was initialized during base.Initialize since we have the friendly name ...
                if (m_aEC != null)                              // ... but make sure anyway
                {
                    QueryStepData();                            // get the data about the steps

                    for (int i = 0; i < m_astrStepFriendlyNames.Length; i++)
                    {
                        IEncConverter aEC = m_aECs[m_astrStepFriendlyNames[i]];
                        if (aEC == null)
                        {
                            // this really can't happen, because if the converter isn't there when we subsequently open it,
                            //  the call to QueryStepData (which calls m_aEC.ConverterNameEnum) will fail to return the
                            //  now deleted step. But just in case...
                            MessageBox.Show(String.Format("The converter '{0}' no longer exists. Removing from the compound converter", m_astrStepFriendlyNames[i]), EncConverters.cstrCaption);
                            dataGridViewSteps.Rows.Insert(i, new object[] { cstrClickMeMessage, false, "None" });
                        }
                        else
                        {
                            // insert a row in the grid for this step
                            dataGridViewSteps.Rows.Insert(i, 1);
                            DataGridViewRow theRow = dataGridViewSteps.Rows[i];
                            UpdateConverterCellValue(theRow, aEC);
                            UpdateDirectionReverseCellValue(theRow, !m_abDirectionForwards[i], aEC);
                            UpdateNormalizationCellValue(theRow, m_aeNormalizeFlags[i]);
                            theRow.Tag = aEC;
                        }
                    }
                }

                IsModified = false;
                m_bAllStepsAreBidirectional = !EncConverters.IsUnidirectional(m_aEC.ConversionType);
            }
        }
        public CcAutoConfigDialog
        (
            IEncConverters aECs,
            string strDisplayName,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strLhsEncodingId,
            string strRhsEncodingId,
            int lProcessTypeFlags,
            bool bIsInRepository
        )
        {
#if VERBOSE_DEBUGGING
            Console.WriteLine("CcAutoConfigDialog ctor BEGIN");
#endif
            InitializeComponent();
#if VERBOSE_DEBUGGING
            Console.WriteLine("Initialized CcAutoConfigDialog component.");
#endif
            base.Initialize
            (
                aECs,
                CcEncConverter.strHtmlFilename,
                strDisplayName,
                strFriendlyName,
                strConverterIdentifier,
                eConversionType,
                strLhsEncodingId,
                strRhsEncodingId,
                lProcessTypeFlags,
                bIsInRepository
            );
#if VERBOSE_DEBUGGING
            Console.WriteLine("Initialized base.");
#endif
            // if we're editing a CC table/spellfixer project, then set the Converter Spec and say it's unmodified
            if (m_bEditMode)
            {
#if VERBOSE_DEBUGGING
                Console.WriteLine("Edit mode");
#endif
                System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));
                textBoxFileSpec.Text = ConverterIdentifier;
                IsModified           = false;
            }

            // if we're editing a SpellFixer project, then the converter is managed by the SpellFixer
            //  project dialog, so we don't need to have an "Save in Repository" button.
            UpdateUI(!IsSpellFixerProject);

            m_bInitialized = true;

#if VERBOSE_DEBUGGING
            Console.WriteLine("1");
#endif
            helpProvider.SetHelpString(textBoxFileSpec, "Enter the file path to the converter table/map.");
#if VERBOSE_DEBUGGING
            Console.WriteLine("2");
#endif
            helpProvider.SetHelpString(buttonBrowse, "Click to browse for the converter table/map");
#if VERBOSE_DEBUGGING
            Console.WriteLine("3");
#endif
            helpProvider.SetHelpString(groupBoxExpects, "Choose the encoding type for the input to the table/map: either Unicode or Legacy bytes.  For example, if this is an Unicode encoding converter, then the input will be Legacy bytes.");
#if VERBOSE_DEBUGGING
            Console.WriteLine("4");
#endif
            helpProvider.SetHelpString(groupBoxReturns, "Choose the encoding type for the output of the table/map: either Unicode or Legacy bytes For example, if this is an Unicode encoding converter, then the output will be Unicode encoding.");
#if VERBOSE_DEBUGGING
            Console.WriteLine("CcAutoConfigDialog ctor END");
#endif
        }
Пример #42
0
		public void ConvertingTextSegments_MainImportDomain()
		{
			string filename = m_fileOs.MakeSfFile(Encoding.GetEncoding(EncodingConstants.kMagicCodePage), false, "MAT",
				@"\mt Matthew",
				@"\c 1",
				@"\v 1",
				@"\vt This is \em my\em* verse text with a",
				@"\sp espanol",
				@"\k keyword",
				@"\f footnote text", // This tests the switch statement in GetEncodingConverterForMarkerDomain
				@"\spkwf raro", // This tests the need for & ~MarkerDomain.Footnote in ConvertSource
				@"\ft end of footnote",
				@"\btvt my \em Back\em* translation",
				@"\k keywordbt");
			m_settings.AddFile(filename, ImportDomain.Main, null, null);

			m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\em ", @"\em*", "Emphasis"));
			m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\k", null, "Key Word"));

			ImportMappingInfo mapping = m_settings.MappingForMarker(@"\sp", MappingSet.Main);
			mapping.StyleName = "Default Paragraph Characters";
			mapping.WsId = "es";
			mapping = m_settings.MappingForMarker(@"\f", MappingSet.Main);
			mapping.StyleName = ScrStyleNames.NormalFootnoteParagraph;

			mapping = m_settings.MappingForMarker(@"\spkwf", MappingSet.Main);
			mapping.StyleName = "Key Word";
			mapping.WsId = "es";
			mapping.Domain = MarkerDomain.Default | MarkerDomain.Footnote;

			mapping = m_settings.MappingForMarker(@"\ft", MappingSet.Main);
			mapping.StyleName = "Default Paragraph Characters";
			mapping.Domain = MarkerDomain.Default | MarkerDomain.Footnote;

			mapping = m_settings.MappingForMarker(@"\btvt", MappingSet.Main);
			mapping.Domain = MarkerDomain.BackTrans;

			// Set the vernacular WS to use the UPPERCASE encoding converter
			VernacularWs.LegacyMapping = "UPPERCASE";

			// Save settings before enumerating, which will get the styles hooked up in the mapping list
			m_settings.SaveSettings();

			m_converters = MockRepository.GenerateStub<IEncConverters>();
			m_converters.Stub(x => x["UPPERCASE"]).Return(new DummyEncConverter());
			ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
				new ScrReference(40, 0, 0, ScrVers.English),
				new ScrReference(40, 1, 2, ScrVers.English));

			ISCTextSegment textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read id segment ");
			Assert.AreEqual(@"\id", textSeg.Marker);
			Assert.AreEqual("MAT ", textSeg.Text);
			Assert.AreEqual(40, textSeg.FirstReference.Book);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read mt segment");
			Assert.AreEqual(@"\mt", textSeg.Marker);
			Assert.AreEqual(@"MATTHEW ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read c segment");
			Assert.AreEqual(@"\c", textSeg.Marker);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read v 1");
			Assert.AreEqual(@"\v", textSeg.Marker);
			Assert.AreEqual("1", textSeg.LiteralVerseNum);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read first vt segment");
			Assert.AreEqual(@"\vt", textSeg.Marker);
			Assert.AreEqual(@"THIS IS ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read emphasis segment");
			Assert.AreEqual(@"\em ", textSeg.Marker);
			Assert.AreEqual(@"MY", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read emphasis segment");
			Assert.AreEqual(@"\em*", textSeg.Marker);
			Assert.AreEqual(@" VERSE TEXT WITH A ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read Spanish segment");
			Assert.AreEqual(@"\sp", textSeg.Marker);
			Assert.AreEqual(@"espanol ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read keyword segment");
			Assert.AreEqual(@"\k", textSeg.Marker);
			Assert.AreEqual(@"KEYWORD ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read footnote text segment");
			Assert.AreEqual(@"\f", textSeg.Marker);
			Assert.AreEqual(@"FOOTNOTE TEXT ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read Spanish keyword in footnote segment");
			Assert.AreEqual(@"\spkwf", textSeg.Marker);
			Assert.AreEqual(@"raro ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read end of footnote segment");
			Assert.AreEqual(@"\ft", textSeg.Marker);
			Assert.AreEqual(@"END OF FOOTNOTE ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read btvt segment");
			Assert.AreEqual(@"\btvt", textSeg.Marker);
			Assert.AreEqual(@"my ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, @"Unable to read BT \em segment");
			Assert.AreEqual(@"\em ", textSeg.Marker);
			Assert.AreEqual(@"Back", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, @"Unable to read BT \em segment");
			Assert.AreEqual(@"\em*", textSeg.Marker);
			Assert.AreEqual(@" translation ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read BT keyword segment");
			Assert.AreEqual(@"\k", textSeg.Marker);
			Assert.AreEqual(@"keywordbt ", textSeg.Text);

			Assert.IsNull(textEnum.Next());
		}
        public TechHindiSiteAutoConfigDialog
        (
            IEncConverters aECs,
            string strDisplayName,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strLhsEncodingId,
            string strRhsEncodingId,
            int lProcessTypeFlags,
            bool bIsInRepository
        )

        {
            InitializeComponent();

            base.Initialize
            (
                aECs,
                TechHindiSiteEncConverter.CstrHtmlFilename,
                strDisplayName,
                strFriendlyName,
                strConverterIdentifier,
                eConversionType,
                strLhsEncodingId,
                strRhsEncodingId,
                lProcessTypeFlags,
                bIsInRepository
            );

            // if we're editing a CC table/spellfixer project, then set the Converter Spec and say it's unmodified
            if (m_bEditMode)
            {
                System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));

                string strConverterPageUri, strInputHtmlElementId, strOutputHtmlElementId,
                       strConvertFunctionName, strConvertReverseFunctionName;
                TechHindiSiteEncConverter.ParseConverterIdentifier(ConverterIdentifier, out strConverterPageUri,
                                                                   out strInputHtmlElementId, out strOutputHtmlElementId, out strConvertFunctionName, out
                                                                   strConvertReverseFunctionName);
                textBoxFileSpec.Text = strConverterPageUri;
                textBoxInputId.Text  = strInputHtmlElementId;
                textBoxOutputId.Text = strOutputHtmlElementId;
                textBoxConvertFunctionForward.Text = strConvertFunctionName;
                textBoxConvertFunctionReverse.Text = strConvertReverseFunctionName;

                switch (ConversionType)
                {
                case ConvType.Legacy_to_from_Unicode:
                case ConvType.Unicode_to_from_Legacy:
                {
                    radioButtonLegacyToUnicode.Checked = true;
                    checkBoxBidirectional.Checked      = true;
                    break;
                };

                case ConvType.Legacy_to_Legacy:
                {
                    radioButtonLegacyToLegacy.Checked = true;
                    break;
                };

                case ConvType.Legacy_to_from_Legacy:
                {
                    radioButtonLegacyToLegacy.Checked = true;
                    checkBoxBidirectional.Checked     = true;
                    break;
                };

                case ConvType.Unicode_to_Unicode:
                {
                    radioButtonUnicodeToUnicode.Checked = true;
                    break;
                };

                case ConvType.Unicode_to_from_Unicode:
                {
                    radioButtonUnicodeToUnicode.Checked = true;
                    checkBoxBidirectional.Checked       = true;
                    break;
                };

                default:
                {
                    radioButtonLegacyToUnicode.Checked = true;
                    break;
                };
                }
                ;
                IsModified = false;
            }

            UpdateUI();

            m_bInitialized = true;
        }
Пример #44
0
        public FallbackAutoConfigDialog
        (
            IEncConverters aECs,
            string strDisplayName,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strLhsEncodingId,
            string strRhsEncodingId,
            int lProcessTypeFlags,
            bool bIsInRepository
        )
        {
            if (aECs.Count == 0)
            {
                MessageBox.Show("Unable to find any existing converters! You must add some before attempting to chain them together.");
                return;
            }

            InitializeComponent();

            base.Initialize
            (
                aECs,
                FallbackEncConverter.strHtmlFilename,
                strDisplayName,
                strFriendlyName,
                strConverterIdentifier,
                eConversionType,
                strLhsEncodingId,
                strRhsEncodingId,
                lProcessTypeFlags,
                bIsInRepository
            );

            // if we're editing ...
            if (m_bEditMode)
            {
                System.Diagnostics.Debug.Assert(m_aEC != null);
                System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(ConverterIdentifier));

                labelCompoundConverterName.Text = FriendlyName;

                if (m_aEC != null)
                {
                    QueryStepData();                        // get the data about the steps

                    if (((m_astrStepFriendlyNames != null) && (m_astrStepFriendlyNames.Length == 2)) &&
                        ((m_abDirectionForwards != null) && (m_abDirectionForwards.Length == 2)))
                    {
                        m_strPrimaryConverter           = m_astrStepFriendlyNames[(int)PrimaryFallbackEnum.ePrimary];
                        m_strFallbackConverter          = m_astrStepFriendlyNames[(int)PrimaryFallbackEnum.eFallback];
                        checkBoxReversePrimary.Checked  = !m_abDirectionForwards[(int)PrimaryFallbackEnum.ePrimary];
                        checkBoxReverseFallback.Checked = !m_abDirectionForwards[(int)PrimaryFallbackEnum.eFallback];
                    }
                }

                IsModified = false;
            }

            // in any case, populate the combo boxes with the full list of available converters
            foreach (IEncConverter aEC in aECs.Values)
            {
                // don't let the primary-fallback converter be put into the lists
                if (strFriendlyName != aEC.Name)
                {
                    comboBoxPrimary.Items.Add(aEC.Name);
                    comboBoxFallback.Items.Add(aEC.Name);

                    // if this is either the primary or the fallback, then also get the bidi status
                    if (m_strPrimaryConverter == aEC.Name)
                    {
                        comboBoxPrimary.SelectedItem = m_strPrimaryConverter;                           // select it in the combo box

                        if (EncConverters.IsUnidirectional(aEC.ConversionType))
                        {
                            checkBoxReversePrimary.Enabled = false;
                        }
                    }
                    else if (m_strFallbackConverter == aEC.Name)
                    {
                        comboBoxFallback.SelectedItem = m_strFallbackConverter;                         // select it in the combo box

                        if (EncConverters.IsUnidirectional(aEC.ConversionType))
                        {
                            checkBoxReverseFallback.Enabled = false;
                        }
                    }
                }
            }

            // in case we set teh selected item in that last code, we don't want to treat that as the steady state situation
            //  (i.e. ignore the resultant SelectedItemChange event until after we're finished.
            m_bIgnoreSelItemChgWhileLoading = false;
        }
Пример #45
0
		public void ConvertingTextSegments_InterleavedBt()
		{
			string filename = m_fileOs.MakeSfFile(Encoding.GetEncoding(EncodingConstants.kMagicCodePage), false, "MAT",
				@"\mt Matthew",
				@"\c 1",
				@"\v 1 This is my verse text",
				@"\rt my Back translation",
				@"\v 2 Second verse");
			m_settings.AddFile(filename, ImportDomain.Main, null, null);

			ImportMappingInfo mapping = m_settings.MappingForMarker(@"\rt", MappingSet.Main);
			mapping.StyleName = "Default Paragraph Characters";
			mapping.Domain = MarkerDomain.BackTrans;

			// Set the vernacular WS to use the UPPERCASE encoding converter
			VernacularWs.LegacyMapping = "UPPERCASE";

			// Save settings before enumerating, which will get the styles hooked up in the mapping list
			m_settings.SaveSettings();

			m_converters = MockRepository.GenerateStub<IEncConverters>();
			m_converters.Stub(x => x["UPPERCASE"]).Return(new DummyEncConverter());
			ISCTextEnum textEnum = GetTextEnum(ImportDomain.Main,
				new ScrReference(40, 0, 0, ScrVers.English),
				new ScrReference(40, 1, 2, ScrVers.English));

			ISCTextSegment textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read id segment ");
			Assert.AreEqual(@"\id", textSeg.Marker);
			Assert.AreEqual("MAT ", textSeg.Text);
			Assert.AreEqual(40, textSeg.FirstReference.Book);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read mt segment");
			Assert.AreEqual(@"\mt", textSeg.Marker);
			Assert.AreEqual(@"MATTHEW ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read c segment");
			Assert.AreEqual(@"\c", textSeg.Marker);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read v 1");
			Assert.AreEqual(@"\v", textSeg.Marker);
			Assert.AreEqual("1", textSeg.LiteralVerseNum);
			Assert.AreEqual(@" THIS IS MY VERSE TEXT ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read btvt segment");
			Assert.AreEqual(@"\rt", textSeg.Marker);
			Assert.AreEqual(@"my Back translation ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read v 2");
			Assert.AreEqual(@"\v", textSeg.Marker);
			Assert.AreEqual("2", textSeg.LiteralVerseNum);
			Assert.AreEqual(@" SECOND VERSE ", textSeg.Text);

			Assert.IsNull(textEnum.Next());
		}
Пример #46
0
		public void ConvertingTextSegments_BTImportDomain()
		{
			string filename = m_fileOs.MakeSfFile(Encoding.GetEncoding(EncodingConstants.kMagicCodePage), false, "MAT",
				@"\mt Matthew",
				@"\c 1",
				@"\v 1",
				@"\vt my \uw retronica\uw* translation",
				@"\k keywordbt");
			m_settings.AddFile(filename, ImportDomain.BackTrans, "en", null);

			m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\uw ", @"\uw*", false,
				MappingTargetType.TEStyle, MarkerDomain.BackTrans, "Untranslated Word", "es"));
			m_settings.SetMapping(MappingSet.Main, new ImportMappingInfo(@"\k", null, "Key Word"));

			// Set the English WS to use the UPPERCASE encoding converter
			Cache.ServiceLocator.WritingSystemManager.Get("en").LegacyMapping = "UPPERCASE";

			// Save settings before enumerating, which will get the styles hooked up in the mapping list
			m_settings.SaveSettings();

			m_converters = MockRepository.GenerateStub<IEncConverters>();
			m_converters.Stub(x => x["UPPERCASE"]).Return(new DummyEncConverter());
			ISCTextEnum textEnum = GetTextEnum(ImportDomain.BackTrans,
				new ScrReference(40, 0, 0, ScrVers.English),
				new ScrReference(40, 1, 2, ScrVers.English));

			ISCTextSegment textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read id segment ");
			Assert.AreEqual(@"\id", textSeg.Marker);
			Assert.AreEqual("MAT ", textSeg.Text);
			Assert.AreEqual(40, textSeg.FirstReference.Book);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read mt segment");
			Assert.AreEqual(@"\mt", textSeg.Marker);
			Assert.AreEqual(@"MATTHEW ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read c segment");
			Assert.AreEqual(@"\c", textSeg.Marker);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read v 1");
			Assert.AreEqual(@"\v", textSeg.Marker);
			Assert.AreEqual("1", textSeg.LiteralVerseNum);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read first vt segment");
			Assert.AreEqual(@"\vt", textSeg.Marker);
			Assert.AreEqual(@"MY ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read untranslated word segment (Spanish)");
			Assert.AreEqual(@"\uw ", textSeg.Marker);
			Assert.AreEqual(@"retronica", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to segment following untranslated word");
			Assert.AreEqual(@"\uw*", textSeg.Marker);
			Assert.AreEqual(@" TRANSLATION ", textSeg.Text);

			textSeg = textEnum.Next();
			Assert.IsNotNull(textSeg, "Unable to read keyword segment");
			Assert.AreEqual(@"\k", textSeg.Marker);
			Assert.AreEqual(@"KEYWORDBT ", textSeg.Text);

			Assert.IsNull(textEnum.Next());
		}
        /// <summary>
        /// This is the base class for the two different AdaptIt EncConverters: the Lookup transducer and the
        /// Guesser API transducer. Since both of these types have the same configuration dialog, most of the
        /// implementation can be put into this class, while the subclasses are used for the specifics to
        /// each (if there is none, then you can just get rid of this class)
        /// </summary>
        public override void Initialize
        (
            IEncConverters aECs,
            string strHtmlFileName,
            string strDisplayName,
            string strFriendlyName,
            string strConverterIdentifier,
            ConvType eConversionType,
            string strLhsEncodingId,
            string strRhsEncodingId,
            int lProcessTypeFlags,
            bool bIsInRepository
        )
        {
            InitializeComponent();

            base.Initialize
            (
                aECs,
                strHtmlFileName,
                strDisplayName,
                strFriendlyName,
                strConverterIdentifier,
                eConversionType,
                strLhsEncodingId,
                strRhsEncodingId,
                lProcessTypeFlags,
                bIsInRepository
            );

            m_bQueryForConvType = false;    // don't need to do this for this converter type (or we do, but differently)

#if !NotUsingNormalizer
            // in the new situation, the converter spec has two pieces of information:
            //  a) the same as the original one -- the path to the KB file
            //  b) the path to a normalizing entity (e.g. cct, tec, map, or a custom
            //      XML file that has the normalizing correspondences (ala. ???)
            // these two are separated by a ';'
            if (m_bEditMode)
            {
                System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(strConverterIdentifier));
                string[] astrPaths = strConverterIdentifier.Split(new[] { ';' });
                string   strKnowledgeBaseFileSpec = astrPaths[0];

                if (astrPaths.Length >= 2)
                {
                    textBoxNormalizationPath.Text = astrPaths[1];
                }

                m_bLegacy = (strKnowledgeBaseFileSpec.IndexOf(cstrAdaptItWorkingDirLegacy) != -1);
            }
#else
            if (m_bEditMode)
            {
                m_bLegacy = (strConverterIdentifier.IndexOf(cstrAdaptItWorkingDirLegacy) != -1);
            }
#endif

            if (m_bLegacy)
            {
                InitProjectNames(cstrAdaptItWorkingDirLegacy, true);
                radioButtonLegacy.Checked = true;
            }
            else
            {
                InitProjectNames(CstrAdaptItWorkingDirUnicode, false);
                radioButtonUnicode.Checked = true;
            }

            if (m_bEditMode)
            {
                int nIndex = listBoxProjects.Items.IndexOf(ProjectNameFromConverterSpec);
                if (nIndex != -1)
                {
                    listBoxProjects.SelectedIndex = nIndex;
                }

                IsModified = false;
            }
        }