/// ------------------------------------------------------------------------------------
		/// <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;
		}
Ejemplo n.º 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Adds the specified character to the grid's list of displayed characters. This is
		/// called by the two public methods AddCharacter and AddCharacters.
		/// </summary>
		/// ------------------------------------------------------------------------------------
		private void InternalAddCharacter(string chr, LanguageDefinition langDef)
		{
			if (langDef.GetOverrideCharType(chr) == ValidCharacterType.None &&
				!StringUtils.IsCharacterDefined(chr))
			{
				return;
			}

			// Keep track of those characters that are not control characters and for
			// which there are no representative glyphs in the font.
			if (Win32.AreCharGlyphsInFont(chr, Font))
			{
				if (m_charsWithMissingGlyphs.Contains(chr))
					m_charsWithMissingGlyphs.Remove(chr);
			}
			else if (!Icu.IsControl(chr[0]))
			{
				if (!m_charsWithMissingGlyphs.Contains(chr))
					m_charsWithMissingGlyphs.Add(chr);
			}

			// If we're dealing with a type of space or control character, then figure out
			// display text that is slightly more readable than whatever glyph the font
			// contains for the character, which may not be a glyph at all.
			if ((Icu.IsSpace(chr[0]) || Icu.IsControl(chr[0])) &&
				!m_specialCharStrings.ContainsKey(chr))
			{
				m_specialCharStrings[chr] = GetSpecialCharDisplayText(chr);
			}

			Chars.Add(chr);
		}