Пример #1
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds the given character, placing it in the correct group according to its Unicode
        /// category.
        /// </summary>
        /// <param name="chr">The character, which can consist of a base character as well as
        /// possibly some combining characters (diacritics, etc.).</param>
        /// <param name="type">Type of character being added, if known (really only needed for
        /// not-yet-defined PUA characters)</param>
        /// <param name="sortAfterAdd">Inidicates whether or not to sort the list after
        /// the characters is added.</param>
        /// <returns>A enumeration value indicating which type of character was added</returns>
        /// ------------------------------------------------------------------------------------
        public ValidCharacterType AddCharacter(string chr, ValidCharacterType type,
                                               bool sortAfterAdd)
        {
            if (string.IsNullOrEmpty(chr) || IsValid(chr))
            {
                return(ValidCharacterType.None);
            }

            int codepoint = chr[0];

            if (type == ValidCharacterType.DefinedUnknown)
            {
                type = GetNaturalCharType(codepoint);
            }
            List <string> list;

            switch (type)
            {
            case ValidCharacterType.WordForming: list = m_WordFormingCharacters; break;

            case ValidCharacterType.Numeric: list = m_NumericCharacters; break;

            default: list = m_OtherCharacters; break;
            }

            list.Add(chr);
            if (sortAfterAdd)
            {
                Sort(list);
            }
            return(type);
        }
Пример #2
0
        public void GetNaturalCharType(int codepoint, ValidCharacterType type)
        {
            CoreWritingSystemDefinition ws         = m_wsManager.Create("en-US");
            ValidCharacters             validChars = ValidCharacters.Load(ws);

            Assert.AreEqual(type, ReflectionHelper.GetResult(validChars, "GetNaturalCharType", codepoint));
        }
Пример #3
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Removes the characters in the specified list from the list of valid characters.
        /// The return value is a bitmask value indicating from what lists characters were
        /// removed.
        /// </summary>
        /// ------------------------------------------------------------------------------------
        public ValidCharacterType RemoveCharacters(List <string> characters)
        {
            ValidCharacterType removedTypes = ValidCharacterType.None;

            if (characters != null)
            {
                foreach (string chr in characters)
                {
                    removedTypes |= RemoveCharacter(chr);
                }
            }

            return(removedTypes);
        }
Пример #4
0
        /// ------------------------------------------------------------------------------------
        /// <summary>
        /// Adds the characters from the given list, placing each character in the correct
        /// group according to its Unicode category.
        /// </summary>
        /// <param name="characters">The list of characters.</param>
        /// <returns>A bit-mask value indicating which types of characters were added</returns>
        /// ------------------------------------------------------------------------------------
        public ValidCharacterType AddCharacters(List <string> characters)
        {
            ValidCharacterType addedTypes = ValidCharacterType.None;

            if (characters != null)
            {
                foreach (string chr in characters)
                {
                    addedTypes |= AddCharacter(chr, ValidCharacterType.DefinedUnknown, false);
                }
            }

            SortLists();
            return(addedTypes);
        }
Пример #5
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Adds the given character, placing it in the correct group according to its Unicode
 /// category. The list to which the character is added is sorted after the character
 /// is added.
 /// </summary>
 /// <param name="chr">The character, which can consist of a base character as well as
 /// possibly some combining characters (diacritics, etc.).</param>
 /// <param name="type">Type of character being added, if known (really only needed for
 /// not-yet-defined PUA characters)</param>
 /// <returns>A enumeration value indicating which type of character was added</returns>
 /// ------------------------------------------------------------------------------------
 public ValidCharacterType AddCharacter(string chr, ValidCharacterType type)
 {
     return(AddCharacter(chr, type, true));
 }
Пример #6
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the given character, placing it in the correct group according to its Unicode
		/// category.
		/// </summary>
		/// <param name="chr">The character, which can consist of a base character as well as
		/// possibly some combining characters (diacritics, etc.).</param>
		/// <param name="type">Type of character being added, if known (really only needed for
		/// not-yet-defined PUA characters)</param>
		/// <param name="sortAfterAdd">Inidicates whether or not to sort the list after
		/// the characters is added.</param>
		/// <returns>A enumeration value indicating which type of character was added</returns>
		/// ------------------------------------------------------------------------------------
		public ValidCharacterType AddCharacter(string chr, ValidCharacterType type,
			bool sortAfterAdd)
		{
			if (string.IsNullOrEmpty(chr) || IsValid(chr))
				return ValidCharacterType.None;

			int codepoint = chr[0];
			if (type == ValidCharacterType.DefinedUnknown)
				type = GetNaturalCharType(codepoint);
			List<string> list;
			switch(type)
			{
				case ValidCharacterType.WordForming: list = m_WordFormingCharacters; break;
				case ValidCharacterType.Numeric: list = m_NumericCharacters; break;
				default: list = m_OtherCharacters; break;
			}

			list.Add(chr);
			if (sortAfterAdd)
				Sort(list);
			return type;
		}
Пример #7
0
			/// ---------------------------------------------------------------------------------
			/// <summary>
			/// Adds the specified valid character to one of the valid character grids.
			/// </summary>
			/// ---------------------------------------------------------------------------------
			private void RefreshCharacterGrids(ValidCharacterType type)
			{
				if ((type & ValidCharacterType.WordForming) != 0)
				{
					m_gridWordForming.RemoveAllCharacters();
					m_gridWordForming.AddCharacters(m_validChars.WordFormingCharacters, m_ws);
				}

				if ((type & ValidCharacterType.Numeric) != 0)
				{
					m_gridNumbers.RemoveAllCharacters();
					m_gridNumbers.AddCharacters(m_validChars.NumericCharacters, m_ws);
				}

				if ((type & ValidCharacterType.Other) != 0)
				{
					m_gridOther.RemoveAllCharacters();
					m_gridOther.AddCharacters(m_validChars.OtherCharacters, m_ws);
				}
			}
Пример #8
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the given character, placing it in the correct group according to its Unicode
		/// category. The list to which the character is added is sorted after the character
		/// is added.
		/// </summary>
		/// <param name="chr">The character, which can consist of a base character as well as
		/// possibly some combining characters (diacritics, etc.).</param>
		/// <param name="type">Type of character being added, if known (really only needed for
		/// not-yet-defined PUA characters)</param>
		/// <returns>A enumeration value indicating which type of character was added</returns>
		/// ------------------------------------------------------------------------------------
		public ValidCharacterType AddCharacter(string chr, ValidCharacterType type)
		{
			return AddCharacter(chr, type, true);
		}
Пример #9
0
			/// ---------------------------------------------------------------------------------
			/// <summary>
			/// Adds the specified character to the list of valid characters.
			/// </summary>
			/// ---------------------------------------------------------------------------------
			protected internal virtual void AddCharacter(string chr, ValidCharacterType type,
				bool makeReceivingGridCurrent)
			{
				ValidCharacterType retType = m_validChars.AddCharacter(chr, type);
				RefreshCharacterGrids(retType);

				if (makeReceivingGridCurrent || CurrentGrid == null)
				{
					switch (retType)
					{
						case ValidCharacterType.WordForming: CurrentGrid = m_gridWordForming; break;
						case ValidCharacterType.Numeric: CurrentGrid = m_gridNumbers; break;
						case ValidCharacterType.Other: CurrentGrid = m_gridOther; break;
						default: return;
					}

					CurrentGrid.CurrentCharacter = chr;
				}
			}
Пример #10
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the character to a list (rather than to a grid).
		/// </summary>
		/// ------------------------------------------------------------------------------------
		protected internal override void AddCharacter(string chr, ValidCharacterType type,  bool notUsed)
		{
			m_charsInGrid.Add(chr);
		}
Пример #11
0
 /// ------------------------------------------------------------------------------------
 /// <summary>
 /// Adds the character to a list (rather than to a grid).
 /// </summary>
 /// ------------------------------------------------------------------------------------
 protected internal override void AddCharacter(string chr, ValidCharacterType type, bool notUsed)
 {
     m_charsInGrid.Add(chr);
 }
Пример #12
0
        private void AddCharactersFromWritingSystem(CoreWritingSystemDefinition ws, string charSetType, ValidCharacterType validCharType)
        {
            CharacterSetDefinition charSet;

            if (!ws.CharacterSets.TryGet(charSetType, out charSet))
            {
                return;
            }

            foreach (string chr in charSet.Characters)
            {
                AddCharacter(chr, validCharType);
            }
        }
Пример #13
0
        private void AddCharactersFromWritingSystem(CoreWritingSystemDefinition ws, string charSetType, ValidCharacterType validCharType, List <string> invalidChars)
        {
            CharacterSetDefinition charSet;

            if (!ws.CharacterSets.TryGet(charSetType, out charSet))
            {
                return;
            }

            foreach (string chr in charSet.Characters)
            {
                if (TsStringUtils.IsValidChar(chr))
                {
                    AddCharacter(chr, validCharType);
                }
                else
                {
                    invalidChars.Add(chr);
                }
            }
        }