/// ------------------------------------------------------------------------------------
		/// <summary>
		///
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void SavePUACheckedChars(LanguageDefinition langDef)
		{
			if (m_lstPUACharacters.Items.Count == 0)
				return;

			ValidCharacters validChars = ValidCharacters.Load(langDef);
			if (validChars == null)
				return;

			// First clear out any characters in the PUA list for the writing system
			// unless they are still in the list of checked items.
			// Also remove them from the valid characters list.
			foreach (PuaListItem puaItem in m_lstPUACharacters.Items)
			{
				if (!m_lstPUACharacters.CheckedItems.Contains(puaItem))
				{
					langDef.RemovePuaDefinition(puaItem.PUAChar.CharDef);

					char c = (char)puaItem.PUAChar.Character;
					validChars.RemoveCharacter(c.ToString());
				}
			}

			// Add the characters which are checked to the PUA list for the writing system and
			// the valid characters list.
			foreach (PuaListItem puaItem in m_lstPUACharacters.CheckedItems)
			{
				langDef.AddPuaDefinition(puaItem.PUAChar.CharDef);

				// Now add the character to the valid characters list if it is not a diacritic
				// or some other category that is disallowed in the valid characters list.
				string chr = ((char)puaItem.PUAChar.Character).ToString();
				ValidCharacterType chrType = langDef.GetOverrideCharType(chr);
				if (chrType != ValidCharacterType.None)
					validChars.AddCharacter(chr, chrType);
			}

			// Put the updated valid characters back into the final lang. definition.
			langDef.ValidChars = validChars.XmlString;
		}
Exemple #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Makes sure that if the specified codepoint is a custom PUA character, that that
		/// character is added to the language definition's PUA collection.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private static void UpdateLangDefPUACollection(int codepoint,
			LanguageDefinition langDef, List<PUACharacter> customPuaCharacters)
		{
			// Go through all the custom defined PUA characters in ICU and make sure that if
			// our codepoint is one of them, the language definition contains our codepoint
			// in its collection of PUA characters.
			foreach (PUACharacter customChar in customPuaCharacters)
			{
				string sCodePoint = codepoint.ToString("x4").ToUpperInvariant();

				// Is our codepoint one of the custom PUA characters? If so,
				// add it to the language definition's PUA collection.
				if (sCodePoint == customChar.CodePoint)
				{
					PUACharacter puaChar = new PUACharacter(sCodePoint);
					puaChar.RefreshFromIcu(false);
					langDef.AddPuaDefinition(codepoint, puaChar.ToString());
				}
			}
		}