Beispiel #1
0
 /// <summary>
 /// Configures the custom dictionary settings.
 /// </summary>
 /// <param name="dictionary"></param>
 protected virtual void SetupCustomDictionary(SpellCheckerCustomDictionary dictionary)
 {
     dictionary.Encoding = System.Text.Encoding.UTF8;
     dictionary.Culture  = SpellChecker.Culture;
     if (SpellCheckerOptions.PathResolutionMode == FilePathResolutionMode.None)
     {
         SpellCheckerDictionaryStreamInfo streamInfo = GetDictionaryStreamInfo(true);
         try {
             dictionary.Load(streamInfo.DictionaryStream, streamInfo.AlphabetStream);
         }
         finally {
             if (streamInfo.AlphabetStream != null)
             {
                 streamInfo.AlphabetStream.Dispose();
                 streamInfo.AlphabetStream = null;
             }
             if (streamInfo.DictionaryStream != null)
             {
                 streamInfo.DictionaryStream.Dispose();
                 streamInfo.DictionaryStream = null;
             }
         }
     }
     else
     {
         SpellCheckerDictionaryFileInfo fileInfo = GetDictionaryFileInfo(true);
         dictionary.AlphabetPath   = fileInfo.AlphabetPath;
         dictionary.DictionaryPath = fileInfo.DictionaryPath;
     }
 }
Beispiel #2
0
 /// <summary>
 /// Initializes static default and custom dictionaries for the first time they are accessed in the application.
 /// </summary>
 private void EnsureDictionaries()
 {
     if (DefaultDictionary == null)
     {
         lock (lockObject) {
             if (DefaultDictionary == null)
             {
                 SpellCheckerISpellDictionary result = CreateDefaultDictionaryCore();
                 SetupDefaultDictionary(result);
                 DictionaryCreatedEventArgs args = new DictionaryCreatedEventArgs(result, false);
                 OnDictionaryCreated(args);
                 DefaultDictionary = args.Dictionary as SpellCheckerISpellDictionary ?? result;
             }
         }
     }
     if (CustomDictionary == null)
     {
         lock (lockObject) {
             if (CustomDictionary == null)
             {
                 SpellCheckerCustomDictionary result = CreateCustomDictionaryCore();
                 SetupCustomDictionary(result);
                 DictionaryCreatedEventArgs args = new DictionaryCreatedEventArgs(result, true);
                 OnDictionaryCreated(args);
                 CustomDictionary = args.Dictionary as SpellCheckerCustomDictionary ?? result;
             }
         }
     }
 }
Beispiel #3
0
        static ControlService()
        {
            string appdir = ConfigurationManager.AppSettings["ProWriteFontFile"];

            if (appdir.IndexOf(@":") == -1)
            {
                appdir = Application.StartupPath + @"\" + appdir;
            }
            else
            {
                appdir = ConfigurationManager.AppSettings["ProWriteFontFile"];
            }

            FontManager.Initialize(appdir);

            _libraryTree      = new LibraryTree();
            _signCombo        = new SignRepositoryItemLookUpEdit();
            _propertyGrid     = new PropertyGridControl();
            _effectTree       = new EffectTreeControl();
            _toolBox          = new ToolBoxControl();
            _timeSliceControl = new TimeSliceGroupControl();
            _signImage        = new SignImage();
            _signStatus       = new SignStatus();

            _barButtonPosition = new BarButtonItem();
            //_barButtonPosition.CategoryGuid = new System.Guid("77795bb7-9bc5-4dd2-a297-cc758682e23d");
            //_barButtonPosition.Id = 0;
            //_barButtonPosition.Name = "siPosition";

            _statusBar            = new RibbonStatusBar();
            _currentClip          = new CurrentClip();
            _spellChecker         = new DevExpress.XtraSpellChecker.SpellChecker();
            _signStorageIndicator = new SignStorageIndicator();

            _pictureBox = new PictureEdit();
            _pictureBox.Properties.ShowMenu = false;
            _pictureBox.Properties.SizeMode = DevExpress.XtraEditors.Controls.PictureSizeMode.Zoom;

            if (_libraryTree != null)
            {
                _libraryTree.Controller.RemoveLibraryItemEvent += new EventHandler <RemoveLibraryEventArgs>(Controller_RemoveLibraryItemEvent);
            }
            _fonts         = new List <PWFont>();
            _fontsBitMap   = new List <PWFont>();
            _fontsTrueType = new List <PWFont>();

            spellCheckTask = Task.Create((p) =>
            {
                CultureInfo engCulture = new CultureInfo("En-us");
                dictionary             = new SpellCheckerISpellDictionary(DemoUtils.GetRelativePath("american.xlg"), DemoUtils.GetRelativePath("english.aff"), engCulture);

                dictionary.AlphabetPath = DemoUtils.GetRelativePath("EnglishAlphabet.txt");
                customDictorary         = new SpellCheckerCustomDictionary();
                customDictorary.Culture = engCulture;

                SpellCheckerList.Load();
                customDictorary.AddWords(ServiceManager.Get <SpellCheckerList>());
            });
        }
        static SpellCheckerDictionaryBase GetCustomDictionary(string path, string _culture)
        {
            CultureInfo cInfo = new CultureInfo(_culture);
            SpellCheckerCustomDictionary custom_dict = new SpellCheckerCustomDictionary(String.Format("{0}\\{1}-custom.dic", path, _culture), cInfo);

            custom_dict.Encoding = System.Text.Encoding.GetEncoding(cInfo.TextInfo.ANSICodePage);
            custom_dict.Load();
            return(custom_dict);
        }
        protected override SpellChecker CreateSpellCheckerControl()
        {
            SpellChecker result = new SpellChecker();
            SpellCheckerCustomDictionary customDictionary = new SpellCheckerCustomDictionary(String.Empty, CultureInfo.InvariantCulture);

            result.Dictionaries.Add(customDictionary);
            result.SpellCheckMode = SpellCheckMode.AsYouType;
            return(result);
        }
Beispiel #6
0
 private void LoadCustomDictionary()
 {
     #region #LoadCustomDictionary
     SpellCheckerCustomDictionary customDictionary = new SpellCheckerCustomDictionary();
     customDictionary.AlphabetPath   = @"Dictionaries\EnglishAlphabet.txt";
     customDictionary.DictionaryPath = @"Dictionaries\CustomEnglish.dic";
     customDictionary.Culture        = CultureInfo.InvariantCulture;
     spellChecker1.Dictionaries.Add(customDictionary);
     #endregion #LoadCustomDictionary
 }
Beispiel #7
0
        private void Initialize()
        {
            sharedDictionaryStorage1.Dictionaries.Clear();
            SpellCheckerISpellDictionary dictionary = ControlService.SpellDictionary;

            sharedDictionaryStorage1.Dictionaries.Add(dictionary);

            customDictionary = ControlService.SpellCustomDictionary;
            sharedDictionaryStorage1.Dictionaries.Add(customDictionary);

            spellChecker1.Culture = customDictionary.Culture;

            barManager1.SetPopupContextMenu(this.memoEdit, popupMenu1);
            //DoCheck();
        }
Beispiel #8
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 #9
0
        protected void ASPxSpellChecker1_WordAdded(object sender, WordAddedEventArgs e)
        {
            ASPxSpellChecker             checker = sender as ASPxSpellChecker;
            SpellCheckerCustomDictionary dic     = checker.GetCustomDictionary();

            if (dic != null)
            {
                StringBuilder stb = new StringBuilder();
                for (int i = 0; i < dic.WordCount; i++)
                {
                    stb.AppendLine(dic[i]);
                }
                using (StreamWriter writer = new StreamWriter(userDictPath)) {
                    writer.Write(stb.ToString());
                }
            }
        }
Beispiel #10
0
        static ISpellCheckerDictionary GetCustomDictionary()
        {
            SpellCheckerCustomDictionary result = new SpellCheckerCustomDictionary();
            Stream dictionaryStream             = DemoUtils.GetDataStream(DemoUtils.PathToDictionaries, "CustomEnglish.dic");
            Stream alphabetStream = DemoUtils.GetDataStream(DemoUtils.PathToDictionaries, "EnglishAlphabet.txt");

            try {
                result.Load(dictionaryStream, alphabetStream);
            }
            catch {
            }
            finally {
                dictionaryStream.Close();
                alphabetStream.Close();
            }
            result.Culture = new CultureInfo("en-US");
            return(result);
        }