/*Function which starts DAISY Translation*/ private void DoConvert() { try { for (int pGh = 1; pGh <= doc.Paragraphs.Count; pGh++) { progressBar1.Increment(1); float percentShow = (this.progressBar1.Value * 100) / count; lblProgress.Text = "Updation Process: " + percentShow.ToString() + "% " + "" + "completed"; Application.DoEvents(); MSword.WdLanguageID lngId = DetectLng(doc.Paragraphs[pGh].Range); try { doc.Paragraphs[pGh].Range.LanguageID = lngId; } catch (Exception e) { MessageBox.Show(e.Message); } } doc.Save(); WorkComplete(null); } catch (Exception e) { WorkComplete(e); } }
public MSword.WdLanguageID DetectLng(MSword.Range rngPgh) { MSword.WdLanguageID lngInfo; detectLng = new Hashtable(); for (int wrd = 1; wrd <= rngPgh.Words.Count; wrd++) { rngPgh.Words[wrd].LanguageDetected = false; rngPgh.Words[wrd].DetectLanguage(); lngInfo = rngPgh.Words[wrd].LanguageID; if (detectLng.Contains(lngInfo)) { detectLng[lngInfo] = Convert.ToInt16(detectLng[lngInfo]) + 1; } else { detectLng.Add(lngInfo, 0); } } highValue = 0; foreach (DictionaryEntry myEntry in detectLng) { String curValue = myEntry.Value.ToString(); if (Convert.ToInt16(curValue) > highValue) { highValue = Convert.ToInt16(curValue); lngId = (MSword.WdLanguageID)myEntry.Key; } } return(lngId); }
public LanguageItem(Word.WdLanguageID id, string name) { Id = id; Name = name; }