private void LoadOpenOfficeDictionaries()
        {
            #region #LoadOpenOfficeDictionaries
            checker.Dictionaries.Clear();

            Stream dict_en_US = Assembly.GetExecutingAssembly().
                                GetManifestResourceStream("SpellingDictionaryExample.Dictionaries.OpenOffice.en_US.en_US.dic");
            Stream grammar_en_US = Assembly.GetExecutingAssembly().
                                   GetManifestResourceStream("SpellingDictionaryExample.Dictionaries.OpenOffice.en_US.en_US.aff");
            Stream alphabet_en_US = Assembly.GetExecutingAssembly().
                                    GetManifestResourceStream("SpellingDictionaryExample.Dictionaries.EnglishAlphabet.txt");

            SpellCheckerOpenOfficeDictionary openOfficeDictionaryEnglish = new SpellCheckerOpenOfficeDictionary();
            openOfficeDictionaryEnglish.LoadFromStream(dict_en_US, grammar_en_US, alphabet_en_US);
            openOfficeDictionaryEnglish.Culture = new CultureInfo("en-US");
            checker.Dictionaries.Add(openOfficeDictionaryEnglish);
            #endregion #LoadOpenOfficeDictionaries

            Stream dict_es_ES = Assembly.GetExecutingAssembly().
                                GetManifestResourceStream("SpellingDictionaryExample.Dictionaries.OpenOffice.es_ES.es_ES.dic");
            Stream grammar_es_ES = Assembly.GetExecutingAssembly().
                                   GetManifestResourceStream("SpellingDictionaryExample.Dictionaries.OpenOffice.es_ES.es_ES.aff");
            Stream alphabet_es_ES = Assembly.GetExecutingAssembly().
                                    GetManifestResourceStream("SpellingDictionaryExample.Dictionaries.SpanishAlphabet.txt");

            SpellCheckerOpenOfficeDictionary openOfficeDictionarySpanish = new SpellCheckerOpenOfficeDictionary();
            openOfficeDictionarySpanish.LoadFromStream(dict_es_ES, grammar_es_ES, alphabet_es_ES);
            openOfficeDictionarySpanish.Culture = new CultureInfo("es-ES");
            checker.Dictionaries.Add(openOfficeDictionarySpanish);

            LoadCustomDictionary();
        }
Beispiel #2
0
        /// <summary>
        /// Loads and returns the <see cref="SpellCheckerOpenOfficeDictionary"/> for the specified <see cref="CultureInfo"/>
        /// </summary>
        /// <param name="cultureInfo">
        /// The <see cref="CultureInfo"/> for which the <see cref="SpellCheckerOpenOfficeDictionary"/> has to be loaded
        /// </param>
        /// <returns>
        /// An instance of <see cref="SpellCheckerOpenOfficeDictionary"/> if it can be found, null otherwise.
        /// </returns>
        private SpellCheckerOpenOfficeDictionary LoadDictionary(CultureInfo cultureInfo)
        {
            string applicationdata  = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            string dictionaryfolder = Path.Combine(applicationdata, string.Format("{0}\\{1}", ApplicationFolderName, DictionaryFolderName));

            var directoryInfo       = new DirectoryInfo(dictionaryfolder);
            var directories         = directoryInfo.EnumerateDirectories(cultureInfo.Name);
            var dictionaryDirectory = directories.SingleOrDefault();

            if (dictionaryDirectory == null)
            {
                return(null);
            }

            var dicFiles  = dictionaryDirectory.GetFiles("*.dic");
            var dicFile   = dicFiles.First();
            var dicstream = dicFile.OpenRead();

            var affFiles  = dictionaryDirectory.GetFiles("*.aff");
            var affFile   = affFiles.First();
            var affstream = affFile.OpenRead();

            var dictionary = new SpellCheckerOpenOfficeDictionary();

            dictionary.LoadFromStream(dicstream, affstream, null);

            var culture = new CultureInfo(dictionaryDirectory.Name);

            dictionary.Culture = culture;

            return(dictionary);
        }
        private void btn_DictLoad_Click(object sender, RoutedEventArgs e)
        {
            tb.IsEnabled      = false;
            LayoutRoot.Cursor = Cursors.Wait;

            SpellCheckerOpenOfficeDictionary dict =
                new SpellCheckerOpenOfficeDictionary();
            StreamResourceInfo ResourceStreamDic =
                App.GetResourceStream(new Uri("Dictionary/de_DE.dic", UriKind.Relative));
            Stream             dicStream         = ResourceStreamDic.Stream;
            StreamResourceInfo ResourceStreamAff =
                App.GetResourceStream(new Uri("Dictionary/de_DE.aff", UriKind.Relative));
            Stream             affStream           = ResourceStreamAff.Stream;
            StreamResourceInfo ResourceStreamAlpha =
                App.GetResourceStream(new Uri("Dictionary/german_alphabet.txt", UriKind.Relative));
            Stream alphaStream = ResourceStreamAlpha.Stream;

            dict.Culture = new CultureInfo("de-DE");
            dict.LoadFromStream(dicStream, affStream, alphaStream);
            SpellCheckerHelper.SpellChecker.Dictionaries.Add(dict);
            SpellCheckerHelper.SpellChecker.Culture = new CultureInfo("de-DE");

            tb.IsEnabled      = true;
            LayoutRoot.Cursor = Cursors.Arrow;
        }
Beispiel #4
0
        public MainPage()
        {
            InitializeComponent();

            textEdit.Text = @"Hushåll är en enhet av människor som delar bostad och de kan även ansvara för varandras försörjning.
Ofta finns släktskap eller intima relationer inom ett hushåll. 
Så behöver dock inte vara fallet, utan även strikt rationella skäl kan ligga till grund för hushållsbildning.";

            checker = new SpellChecker();
            // Clear the dictionaries
            //checker.Dictionaries.Clear();
            // Get the Swedish dictionary and grammar from the assembly
            Stream dict    = Assembly.GetExecutingAssembly().GetManifestResourceStream("DXSpellChecker_Sample_UTF16.sv_SE_utf16.dic");
            Stream grammar = Assembly.GetExecutingAssembly().GetManifestResourceStream("DXSpellChecker_Sample_UTF16.sv_SE_utf16.aff");
            // Create the dictionary
            SpellCheckerOpenOfficeDictionary dictionary = new SpellCheckerOpenOfficeDictionary();
            // Create the culture
            CultureInfo swedish = new CultureInfo("sv-SE");

            // Set dictionary culture
            dictionary.Culture = swedish;
            // Set encoding to UTF-16 (Unicode)
            dictionary.Encoding = Encoding.Unicode;
            // Load the dictionary
            // Note that culture and encoding settings should be specified before a dictionary is loaded
            dictionary.LoadFromStream(dict, grammar, null);
            // Add the dictionary to the collection
            checker.Dictionaries.Add(dictionary);

            // Set default culture of the spell checker
            checker.Culture = swedish;
        }
Beispiel #5
0
        public MainPage()
        {
            InitializeComponent();

            textEdit.Text = @"Η Μάχη της Μόσχας (ρώσικα: Битва под Москвой, γερμανικά: Schlacht um Moskau) 
είναι το όνομε που έχει δοθεί από σοβιετικούς ιστορικούς σε δύο περιόδους σημαντικών μαχών κατά μήκος ενός τομέα 600 χιλιομέτρων στο Ανατολικό Μέτωπο
κατά την διάρκεια του Β' Παγκοσμίου Πολέμου. Διαδραματίστηκε μεταξύ Οκτοβρίου 1941 και Ιανουαρίου 1942. 
Ο Χίτλερ θεωρούσε την Μόσχα, πρωτεύουσα της Σοβιετικής Ένωσης και μεγαλύτερη πόλη της, κύριο στρατηγικό στόχο των δυνάμεων του Άξονα στην Επιχείρηση Μπαρμπαρόσα.";


            checker = new SpellChecker();
            // clearing the dictionaries
            //checker.Dictionaries.Clear();
            // getting the Greek dictionary and grammar from the assembly
            Stream dict    = Assembly.GetExecutingAssembly().GetManifestResourceStream("GreekSpell.el_GR.dic");
            Stream grammar = Assembly.GetExecutingAssembly().GetManifestResourceStream("GreekSpell.el_GR.aff");
            // creating the dictionary
            SpellCheckerOpenOfficeDictionary dictionary = new SpellCheckerOpenOfficeDictionary();
            // creating the culture
            CultureInfo ellinika = new CultureInfo("el-GR");

            // loading the dictionary
            dictionary.LoadFromStream(dict, grammar, null);
            // setting the dictionary culture
            dictionary.Culture = ellinika;
            //adding the dictionary to the collection
            checker.Dictionaries.Add(dictionary);

            // setting the default culture of the spell checker
            checker.Culture = ellinika;
        }
Beispiel #6
0
        /// <summary>
        /// Set the <see cref="SpellCheckerOpenOfficeDictionary"/> and <see cref="CultureInfo"/> of the <see cref="SpellChecker"/>
        /// </summary>
        /// <param name="dictionary">
        /// The <see cref="SpellCheckerOpenOfficeDictionary"/> that is to be added to the <see cref="SpellChecker"/> if it is not yet added.
        /// </param>
        /// <param name="culture">
        /// The <see cref="CultureInfo"/> that is the active <see cref="CultureInfo"/> of the <see cref="SpellChecker"/>
        /// </param>
        private void SetSpellCheckerDictonary(SpellCheckerOpenOfficeDictionary dictionary, CultureInfo culture)
        {
            if (!this.spellChecker.Dictionaries.Contains(dictionary))
            {
                this.spellChecker.Dictionaries.Add(dictionary);
            }

            this.spellChecker.Culture = culture;
        }
        static SpellCheckerOpenOfficeDictionary LoadGreekDictionary()
        {
            Stream dict    = Assembly.GetExecutingAssembly().GetManifestResourceStream("RichEditSpellCheckerSL.Dic.el_GR.dic");
            Stream grammar = Assembly.GetExecutingAssembly().GetManifestResourceStream("RichEditSpellCheckerSL.Dic.el_GR.aff");
            SpellCheckerOpenOfficeDictionary dictionary = new SpellCheckerOpenOfficeDictionary();

            dictionary.LoadFromStream(dict, grammar, null);
            dictionary.Culture = new CultureInfo("el-GR");
            return(dictionary);
        }
        void richEdit1_Loaded(object sender, RoutedEventArgs e)
        {
            DevExpress.Xpf.SpellChecker.SpellChecker spellChecker = SpellCheckerHelper.SpellChecker;
            spellChecker.SpellCheckMode = SpellCheckMode.AsYouType;

            SpellCheckerOpenOfficeDictionary dictionary = LoadGreekDictionary();

            SpellCheckerHelper.SpellChecker.Dictionaries.Add(dictionary);
            SpellCheckerHelper.SpellChecker.Culture = dictionary.Culture;

            this.richEdit1.SpellChecker = spellChecker;
        }
        static SpellCheckerDictionaryBase GetLanguageDictionary(string path, string _culture)
        {
            SpellCheckerOpenOfficeDictionary dict = new SpellCheckerOpenOfficeDictionary();

            dict.DictionaryLoaded += new EventHandler(dic_DictionaryLoaded);

            dict.DictionaryPath = String.Format("{0}\\{1}.dic", path, _culture);
            dict.GrammarPath    = String.Format("{0}\\{1}.aff", path, _culture);
            dict.Culture        = new CultureInfo(_culture);
            dict.Load();
            dict.DictionaryLoaded -= dic_DictionaryLoaded;
            return(dict);
        }
Beispiel #10
0
        private void LoadDictionaries()
        {
            string currentDirectory = Directory.GetCurrentDirectory();

            SpellCheckerOpenOfficeDictionary openOfficeDictionaryEnglish = new SpellCheckerOpenOfficeDictionary();

            openOfficeDictionaryEnglish.DictionaryPath = currentDirectory + @"\..\..\Dictionaries\en_US\en_US.dic";
            openOfficeDictionaryEnglish.GrammarPath    = currentDirectory + @"\..\..\Dictionaries\en_US\en_US.aff";
            openOfficeDictionaryEnglish.Culture        = new CultureInfo("en-US");
            spellChecker1.Dictionaries.Add(openOfficeDictionaryEnglish);

            spellChecker1.Culture        = openOfficeDictionaryEnglish.Culture;
            spellChecker1.SpellCheckMode = SpellCheckMode.AsYouType;
        }
Beispiel #11
0
        public static void csLoadSpellCheckDictionaries(this SpellChecker sc, string currentDirectory = "")
        {
            //    new DevExpress.XtraSpellChecker.FormShowingEventHandler
            //sc.SpellingFormShowing += new DevExpress.XtraSpellChecker.SpellingFormShowingEventHandler(spellChecker1_SpellingFormShowing);
            //sc.OptionsFormShowing += new DevExpress.XtraSpellChecker.FormShowingEventHandler(spellChecker1_OptionsFormShowing);
            //sc.CheckCompleteFormShowing += new DevExpress.XtraSpellChecker.FormShowingEventHandler(spellChecker1_CheckCompleteFormShowing);
            sc.SpellingFormShowing      += spellChecker1_SpellingFormShowing;
            sc.OptionsFormShowing       += spellChecker1_OptionsFormShowing;
            sc.CheckCompleteFormShowing += spellChecker1_CheckCompleteFormShowing;
            if (string.IsNullOrEmpty(currentDirectory))
            {
                currentDirectory = MyLib.GetRelativeFolder() + @"\Spelling";
            }
            SpellCheckerOpenOfficeDictionary openOfficeDictionaryEnglish = new SpellCheckerOpenOfficeDictionary();
            string filename = currentDirectory + @"\en_US.dic";

            if (!File.Exists(filename))
            {
                "Bad Name".csTell();
            }
            openOfficeDictionaryEnglish.DictionaryPath = filename;

            filename = currentDirectory + @"\en_US.aff";
            if (!File.Exists(filename))
            {
                "Bad Name".csTell();
            }
            openOfficeDictionaryEnglish.GrammarPath = filename;

            openOfficeDictionaryEnglish.Culture = new CultureInfo("en-US");
            sc.Dictionaries.Add(openOfficeDictionaryEnglish);

            SpellCheckerCustomDictionary customDictionary = new SpellCheckerCustomDictionary();

            filename = currentDirectory + @"\EnglishAlphabet.txt";
            if (!File.Exists(filename))
            {
                "Bad Name".csTell();
            }
            customDictionary.AlphabetPath = filename;

            customDictionary.Culture = CultureInfo.InvariantCulture;
            sc.Dictionaries.Add(customDictionary);

            sc.Culture        = CultureInfo.InvariantCulture;
            sc.SpellCheckMode = SpellCheckMode.AsYouType;
        }
Beispiel #12
0
        /// <summary>
        /// Loads the dictionaries that are available as embedded resource
        /// </summary>
        private void LoadEmbeddedDictionaries()
        {
            var dict    = Assembly.GetExecutingAssembly().GetManifestResourceStream("CDP4Composition.Resources.Dictionaries.en_GB.dic");
            var grammar = Assembly.GetExecutingAssembly().GetManifestResourceStream("CDP4Composition.Resources.Dictionaries.en_GB.aff");

            var dictionary = new SpellCheckerOpenOfficeDictionary();

            dictionary.LoadFromStream(dict, grammar, null);
            this.spellCheckerDictionaries.Add(dictionary);

            var culture = new CultureInfo("en-GB");

            dictionary.Culture = culture;
            this.cultures.Add(culture);

            this.activeCulture = culture;
        }
        /*
         *              public static SpellCheckerOpenOfficeDictionary[] GetAllDictionaries()
         *              {
         *                      var result = new List<SpellCheckerOpenOfficeDictionary>();
         *
         *                      var fileNames = getAllCompleteCultureFileNames();
         *
         *                      foreach ( var fileName in fileNames )
         *                      {
         *                              var normalizedFileName = fileName.Replace( @"_", @"-" );
         *
         *                              var dictionary =
         *                                      new SpellCheckerOpenOfficeDictionary
         *                                              {
         *                                                      Culture = CultureInfo.GetCultureInfo( normalizedFileName ),
         *                                                      DictionaryPath = ZlpPathHelper.Combine( dictionaryBaseFolderPath.FullName, fileName + @".dic" ),
         *                                                      GrammarPath = ZlpPathHelper.Combine( dictionaryBaseFolderPath.FullName, fileName + @".aff" )
         *                                              };
         *
         *                              result.Add( dictionary );
         *                      }
         *
         *                      return result.ToArray();
         *              }
         */

        public static SpellChecker CreateSpellChecker(
            CultureInfo culture)
        {
            string dictionaryFilePath;
            string grammarFilePath;

            if (HasDictionariesForCulture(
                    culture,
                    out dictionaryFilePath,
                    out grammarFilePath))
            {
                Trace.WriteLine(
                    string.Format(
                        @"Using spell checker with culture '{0}'.",
                        culture));

                // http://www.devexpress.com/Help/?document=XtraSpellChecker/CustomDocument3158.htm&levelup=true.
                var spellChecker =
                    new SpellChecker
                {
                    Culture        = culture,
                    SpellCheckMode = SpellCheckMode.AsYouType,
                };
                spellChecker.CheckAsYouTypeOptions.CheckControlsInParentContainer = true;

                var dictionary =
                    new SpellCheckerOpenOfficeDictionary
                {
                    Culture        = culture,
                    DictionaryPath = dictionaryFilePath,
                    GrammarPath    = grammarFilePath
                };
                spellChecker.Dictionaries.Add(dictionary);

                return(spellChecker);
            }
            else
            {
                Trace.WriteLine(
                    string.Format(
                        @"No spell checker with culture '{0}' because no dictionaries available.",
                        culture));

                return(null);
            }
        }
Beispiel #14
0
        private void LoadOpenOfficeDictionaries()
        {
            #region #LoadOpenOfficeDictionaries
            spellChecker1.Dictionaries.Clear();

            SpellCheckerOpenOfficeDictionary openOfficeDictionaryEnglish = new SpellCheckerOpenOfficeDictionary();
            openOfficeDictionaryEnglish.DictionaryPath = @"Dictionaries\OpenOffice\en_US\en_US.dic";
            openOfficeDictionaryEnglish.GrammarPath    = @"Dictionaries\OpenOffice\en_US\en_US.aff";
            openOfficeDictionaryEnglish.Culture        = new CultureInfo("en-US");
            spellChecker1.Dictionaries.Add(openOfficeDictionaryEnglish);
            #endregion #LoadOpenOfficeDictionaries

            SpellCheckerOpenOfficeDictionary openOfficeDictionarySpanish = new SpellCheckerOpenOfficeDictionary();
            openOfficeDictionarySpanish.DictionaryPath = @"Dictionaries\OpenOffice\es_ES\es_ES.dic";
            openOfficeDictionarySpanish.GrammarPath    = @"Dictionaries\OpenOffice\es_ES\es_ES.aff";
            openOfficeDictionarySpanish.Culture        = new CultureInfo("es-ES");
            spellChecker1.Dictionaries.Add(openOfficeDictionarySpanish);

            LoadCustomDictionary();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="CultureInfoChangedEventArgs"/> class.
 /// </summary>
 /// <param name="culture">
 /// The <see cref="CultureInfo"/> instance that is the payload of the current event argument
 /// </param>
 /// <param name="dictionary">
 /// The <see cref="SpellCheckerOpenOfficeDictionary"/> that is the payload of the current event argument
 /// </param>
 public CultureInfoChangedEventArgs(CultureInfo culture, SpellCheckerOpenOfficeDictionary dictionary)
 {
     this.Culture    = culture;
     this.Dictionary = dictionary;
 }
		/*
				public static SpellCheckerOpenOfficeDictionary[] GetAllDictionaries()
				{
					var result = new List<SpellCheckerOpenOfficeDictionary>();

					var fileNames = getAllCompleteCultureFileNames();

					foreach ( var fileName in fileNames )
					{
						var normalizedFileName = fileName.Replace( @"_", @"-" );

						var dictionary =
							new SpellCheckerOpenOfficeDictionary
								{
									Culture = CultureInfo.GetCultureInfo( normalizedFileName ),
									DictionaryPath = ZlpPathHelper.Combine( dictionaryBaseFolderPath.FullName, fileName + @".dic" ),
									GrammarPath = ZlpPathHelper.Combine( dictionaryBaseFolderPath.FullName, fileName + @".aff" )
								};

						result.Add( dictionary );
					}

					return result.ToArray();
				}
		*/

		public static SpellChecker CreateSpellChecker(
			CultureInfo culture)
		{
			string dictionaryFilePath;
			string grammarFilePath;

			if (HasDictionariesForCulture(
				culture,
				out dictionaryFilePath,
				out grammarFilePath))
			{
				Trace.WriteLine(
					string.Format(
						@"Using spell checker with culture '{0}'.",
						culture));

				// http://www.devexpress.com/Help/?document=XtraSpellChecker/CustomDocument3158.htm&levelup=true.
				var spellChecker =
					new SpellChecker
					{
						Culture = culture,
						SpellCheckMode = SpellCheckMode.AsYouType,
					};
				spellChecker.CheckAsYouTypeOptions.CheckControlsInParentContainer = true;

				var dictionary =
					new SpellCheckerOpenOfficeDictionary
					{
						Culture = culture,
						DictionaryPath = dictionaryFilePath,
						GrammarPath = grammarFilePath
					};
				spellChecker.Dictionaries.Add(dictionary);

				return spellChecker;
			}
			else
			{
				Trace.WriteLine(
					string.Format(
						@"No spell checker with culture '{0}' because no dictionaries available.",
						culture));

				return null;
			}
		}