Exemplo n.º 1
0
		private static List<string> GetWritingSystemIdsWithSpellCheckingInstalled()
		{
			List<string> writingSystemIdsWithSpellCheckingInstalled = new List<string>();
			try
			{
				using (Broker broker = new Broker())
				{
					foreach (WritingSystem ws in BasilProject.Project.WritingSystems.Values)
					{
						if (broker.DictionaryExists(ws.Id))
						{
							writingSystemIdsWithSpellCheckingInstalled.Add(ws.Id);
						}
					}
				}
			}
			catch (DllNotFoundException)
			{
				//If Enchant is not installed we expect an exception.
			}
			return writingSystemIdsWithSpellCheckingInstalled;
		}
Exemplo n.º 2
0
		public TextBoxSpellChecker()
		{
			_extendees = new Dictionary<Control, string>();
			bool brokerSuccessfullyCreated = false;

			try
			{
				_broker = new Broker();
				brokerSuccessfullyCreated = true;
			}
			catch
			{
				//it's okay if we can't create one.
				// probably because Enchant isn't installed on this machine
			}

			if (brokerSuccessfullyCreated)
			{
				_hotSpotProvider = new HotSpotProvider();
				_hotSpotProvider.RetrieveHotSpots += CheckSpelling;
				_dictionaries = new Dictionary<string, Dictionary>();
			}
		}
        public List<SpellCheckInfo> GetSpellCheckComboBoxItems()
        {
            _spellCheckerItems.Clear();

            // add None option
            _spellCheckerItems.Add(new SpellCheckInfo(""));

            try
            {
                using (Broker broker = new Broker())
                {
                    // add installed dictionaries
                    _spellCheckerItems.AddRange(broker.Dictionaries.Select(dictionaryInfo => new SpellCheckInfo(dictionaryInfo)));

                    // add current dictionary, if not installed
                    if (!string.IsNullOrEmpty(CurrentSpellCheckingId))
                    {
                        if (!broker.DictionaryExists(CurrentSpellCheckingId))
                        {
                            _spellCheckerItems.Add(new SpellCheckInfo(CurrentSpellCheckingId));
                        }
                    }
                }
            }
            catch (DllNotFoundException)
            {
                //If Enchant is not installed we expect an exception.
            }
            catch (Exception e)//there are other errors we can get from the enchant binding
            {
                ErrorReport.NotifyUserOfProblem(new ShowOncePerSessionBasedOnExactMessagePolicy(),
                                                "The Enchant Spelling engine encountered an error: " + e.Message);
            }

            return _spellCheckerItems;
        }