private void SetLanguage(string language) { try { ClearLanguage(); var speller = new Hunspell(); var path = SpellCheckFolder(); var aff = Path.Combine(path, language + ".aff"); var dic = Path.Combine(path, language + ".dic"); if (File.Exists(aff) && File.Exists(dic)) { speller.Load(aff, dic); LoadCustomDictonary(speller); _speller = speller; _language = language; } else { Notify.Alert(language + " dictionary not found"); } } catch (Exception ex) { Notify.Alert($"{ex.Message} in {language ?? "null"} file"); } }
private void ApplyConfig(Config config) { if (config.InterfaceStyle == 0) //System toolStrip1.RenderMode = ToolStripRenderMode.System; else if (config.InterfaceStyle == 1) //Office 2003 toolStrip1.RenderMode = ToolStripRenderMode.ManagerRenderMode; //rtbIMText.BackColor = instance.Config.CurrentConfig.BgColour; if (instance.Config.CurrentConfig.EnableSpelling) { dicfile = instance.Config.CurrentConfig.SpellLanguage; // "en_GB.dic"; this.instance.AffFile = afffile = dicfile + ".aff"; this.instance.DictionaryFile = dicfile + ".dic"; dic = dir + dicfile; dicfile += ".dic"; if (!System.IO.File.Exists(dic + ".csv")) { //System.IO.File.Create(dic + ".csv"); using (StreamWriter sw = File.CreateText(dic + ".csv")) { sw.Dispose(); } } hunspell.Dispose(); hunspell = new Hunspell(); hunspell.Load(dir + afffile, dir + dicfile); ReadWords(); } else { hunspell.Dispose(); } }
private void ApplyConfig(Config config) { if (config.InterfaceStyle == 0) //System { toolStrip1.RenderMode = ToolStripRenderMode.System; } else if (config.InterfaceStyle == 1) //Office 2003 { toolStrip1.RenderMode = ToolStripRenderMode.ManagerRenderMode; } if (instance.Config.CurrentConfig.EnableSpelling) { dicfile = instance.Config.CurrentConfig.SpellLanguage; // "en_GB.dic"; this.instance.AffFile = afffile = dicfile + ".aff"; this.instance.DictionaryFile = dicfile + ".dic"; dic = dir + dicfile; dicfile += ".dic"; if (!System.IO.File.Exists(dic + ".csv")) { //System.IO.File.Create(dic + ".csv"); using (StreamWriter sw = File.CreateText(dic + ".csv")) { sw.Dispose(); } } hunspell.Dispose(); hunspell = new Hunspell(); hunspell.Load(dir + afffile, dir + dicfile); ReadWords(); } else { hunspell.Dispose(); } if (instance.Config.CurrentConfig.DisableRadar) { toolStrip1.Visible = false; tabControl1.TabPages.Remove(tabPage1); tabControl1.TabPages.Remove(tabPage2); picCompass.Visible = false; label1.Visible = false; label2.Visible = false; label19.Visible = false; label20.Visible = false; //tBar1.Visible = false; client.Grid.CoarseLocationUpdate -= new EventHandler<CoarseLocationUpdateEventArgs>(Grid_OnCoarseLocationUpdate); } else { //tBar1.Visible = true; //tBar1.Value = instance.Config.CurrentConfig.RadarRange; if (!tabControl1.TabPages.Contains(tabPage1)) { toolStrip1.Visible = true; tabControl1.TabPages.Remove(tabPage3); tabControl1.TabPages.Remove(tabPage4); tabPage1 = tp1; tabControl1.TabPages.Add(tabPage1); tabPage2 = tp2; tabControl1.TabPages.Add(tabPage2); picCompass.Visible = true; label1.Visible = true; label2.Visible = true; label19.Visible = true; label20.Visible = true; client.Grid.CoarseLocationUpdate += new EventHandler<CoarseLocationUpdateEventArgs>(Grid_OnCoarseLocationUpdate); } } if (instance.Config.CurrentConfig.DisableVoice) { tabControl1.TabPages.Remove(tabPage3); } else { if (!tabControl1.TabPages.Contains(tabPage3)) { tabControl1.TabPages.Remove(tabPage4); tabPage3 = tp3; tabControl1.TabPages.Add(tabPage3); } } if (instance.Config.CurrentConfig.DisableFavs) { tabControl1.TabPages.Remove(tabPage4); } else { if (!tabControl1.TabPages.Contains(tabPage4)) { tabPage4 = tp4; tabControl1.TabPages.Add(tabPage4); } } if (instance.Config.CurrentConfig.DisableRadar && instance.Config.CurrentConfig.DisableFavs && instance.Config.CurrentConfig.DisableVoice) { try { splitContainer1.SplitterDistance = splitContainer1.Width; //513 panel5.Visible = false; tabControl1.Visible = false; } catch (Exception ex) { //Logger.Log("MB ERROR: " + ex.Message, Helpers.LogLevel.Error); splitContainer1.SplitterDistance = splitContainer1.Width - splitContainer1.Panel2MinSize; } } else { splitContainer1.SplitterDistance = 513; panel5.Visible = true; tabControl1.Visible = true; //tabControl1.TabPages.Add(tabPage1); //tabControl1.TabPages.Add(tabPage2); //toolStrip1.Visible = true; //client.Grid.CoarseLocationUpdate += new EventHandler<CoarseLocationUpdateEventArgs>(Grid_OnCoarseLocationUpdate); } textBox1.Text = "Range: " + instance.Config.CurrentConfig.RadarRange.ToString(CultureInfo.CurrentCulture) + "m"; }
public void SetLanguage(SpellingLanguages language) { speller = new Hunspell(); var languageKey = LangLookup[language]; var assembly = Assembly.GetExecutingAssembly(); var dictionaryFileStart = string.Format("{0}.Document.SpellCheck.Dictionaries.{1}", assembly.GetName().Name, languageKey); var dictionaryFiles = assembly .GetManifestResourceNames() .Where(name => name.StartsWith(dictionaryFileStart)) .ToArray(); var affixes = dictionaryFiles.Where(name => name.EndsWith(".aff")).OrderBy(s => s); var dictionaries = dictionaryFiles.Where(name => name.EndsWith(".dic")).OrderBy(s => s); var dictionaryPairs = affixes.Zip(dictionaries, (aff, dic) => new { aff, dic }); foreach (var pair in dictionaryPairs) { using (var affStream = assembly.GetManifestResourceStream(pair.aff)) using (var dicStream = assembly.GetManifestResourceStream(pair.dic)) { if (affStream != null && dicStream != null) { var affBytes = new BinaryReader(affStream).ReadBytes((int)affStream.Length); var dicBytes = new BinaryReader(dicStream).ReadBytes((int)dicStream.Length); speller.Load(affBytes, dicBytes); } } } }