Ejemplo n.º 1
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Loads the specified XML source to initialize a new instance of the
		/// <see cref="ValidCharacters"/> class.
		/// </summary>
		/// <param name="xmlSrc">The XML source representation.</param>
		/// <param name="wsName">The name of the writing system that is being loaded</param>
		/// <param name="langDef">The language definition</param>
		/// <returns></returns>
		/// ------------------------------------------------------------------------------------
		public static ValidCharacters Load(string xmlSrc, string wsName, LanguageDefinition langDef)
		{
			Exception e;
			ValidCharacters validChars =
				XmlSerializationHelper.DeserializeFromString<ValidCharacters>(xmlSrc, out e);

			bool fTryOldStyleList = false;

			if (validChars == null)
			{
				validChars = new ValidCharacters();
				if (e != null)
					fTryOldStyleList = !DataAppearsToBeMalFormedXml(xmlSrc);
				if (!fTryOldStyleList && !String.IsNullOrEmpty(xmlSrc))
				{
					StringBuilder bldr = new StringBuilder();
					bldr.AppendFormat("Invalid ValidChars field while loading the {0} writing system:",
						wsName);
					bldr.Append(Environment.NewLine);
					bldr.Append("\t");
					bldr.Append(xmlSrc);
					ReportError(new ArgumentException(bldr.ToString(), "xmlSrc", e));
				}
			}

			List<string> invalidChars;
			validChars.Init(langDef, out invalidChars);

			if (fTryOldStyleList)
			{
				e = null;
				List<string> list = ParseCharString(xmlSrc, " ", validChars.m_cpe, langDef, out invalidChars);
				validChars.AddCharacters(list);
			}

			if (invalidChars.Count > 0)
			{
				StringBuilder bldr = new StringBuilder();
				bldr.AppendFormat("Invalid ValidChars field while loading the {0} writing system. The following characters are invalid:",
					wsName);
				foreach (string chr in invalidChars)
				{
					bldr.Append(Environment.NewLine);
					bldr.Append("\t");
					bldr.AppendFormat("{0} (U+{1:X4}", chr, (int)chr[0]);
					for (int ich = 1; ich < chr.Length; ich++)
						bldr.AppendFormat(", U+{1:X4}", chr, (int)chr[ich]);
					bldr.Append(")");
				}
				ReportError(new ArgumentException(bldr.ToString(), "xmlSrc"));
			}

			if ((e != null || invalidChars.Count > 0) && validChars.m_WordFormingCharacters.Count == 0)
				validChars.AddDefaultWordformingCharOverrides();

			return validChars;
		}
Ejemplo n.º 2
0
		/// ------------------------------------------------------------------------------------
		/// <summary>
		/// Initializes a new instance of the <see cref="FwCharacterCategorizer"/> class.
		/// </summary>
		/// <param name="validChars">The valid characters.</param>
		/// <param name="charPropEngine">The character property engine.</param>
		/// ------------------------------------------------------------------------------------
		public FwCharacterCategorizer(ValidCharacters validChars,
			ILgCharacterPropertyEngine charPropEngine)
		{
			m_validChars = validChars;
			m_charPropEngine = charPropEngine;
		}
Ejemplo n.º 3
0
			/// ------------------------------------------------------------------------------------
			/// <summary>
			/// Initializes the valid characters explorer bar with three valid character grids.
			/// </summary>
			/// ------------------------------------------------------------------------------------
			internal void Init(CharacterGrid gridWf, CharacterGrid gridOther, CharacterGrid gridNum,
				LanguageDefinition langDef)
			{
				m_langDef = langDef;

				gridWf.BackgroundColor = SystemColors.Window;
				gridNum.BackgroundColor = SystemColors.Window;
				gridOther.BackgroundColor = SystemColors.Window;

				gridWf.MultiSelect = true;
				gridNum.MultiSelect = true;
				gridOther.MultiSelect = true;

				gridWf.CellPainting += HandleGridCellPainting;
				gridNum.CellPainting += HandleGridCellPainting;
				gridOther.CellPainting += HandleGridCellPainting;

				gridWf.Enter += HandleGridEnter;
				gridNum.Enter += HandleGridEnter;
				gridOther.Enter += HandleGridEnter;

				gridWf.CellFormatting += HandleCellFormatting;
				gridNum.CellFormatting += HandleCellFormatting;
				gridOther.CellFormatting += HandleCellFormatting;

				gridWf.CellMouseClick += HandleCharGridCellMouseClick;
				gridNum.CellMouseClick += HandleCharGridCellMouseClick;
				gridOther.CellMouseClick += HandleCharGridCellMouseClick;

				gridWf.SelectionChanged += HandleCharGridSelectionChanged;
				gridOther.SelectionChanged += HandleCharGridSelectionChanged;

				m_gridWordForming = gridWf;
				m_gridNumbers = gridNum;
				m_gridOther = gridOther;
				m_validChars = ValidCharacters.Load(langDef);

				RefreshCharacterGrids(ValidCharacterType.All);
			}