/// ------------------------------------------------------------------------------------
		/// <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;
		}
Example #2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Update the characters in the Private Use Area.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		public static void UpdatePUACollection(LanguageDefinition langDef, List<string> chars)
		{
			List<PUACharacter> customPuaCharacters = GetDefinedCustomPUACharsFromICU();

			// Remove any PUA characters that are no longer in the character list. If there
			// are any new PUA characters in the valid characters list, they
			// will be added to this collection in IsCodePointDefined().
			int codePoint;
			string data;
			for (int i = langDef.PuaDefinitionCount - 1; i >= 0; i--)
			{
				langDef.GetPuaDefinition(i, out codePoint, out data);
				char character = (char)new PUACharacter(codePoint).Character;

				string category = langDef.GetOverrideCharCategory(character);
				if (!chars.Contains(character.ToString()) && (category == null || category[0] != 'M'))
				{
					langDef.RemovePuaDefinition(new CharDef(codePoint, data));
				}
			}

			// Now make sure all the custom PUA characters specified in the valid characters
			// list are also added to the language definition's PUA collection.
			foreach (string chr in chars)
			{
				// Go through the codepoints in the character.
				foreach (char c in chr)
					UpdateLangDefPUACollection((int)c, langDef, customPuaCharacters);
			}
		}