Better error handling in spell check user dictionary is corrupt

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2195 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-11-16 12:45:03 +00:00
parent 2c785bd401
commit f4ecf273de
3 changed files with 19 additions and 26 deletions

View File

@ -78,7 +78,6 @@
this.labelDescription1.Size = new System.Drawing.Size(316, 13);
this.labelDescription1.TabIndex = 8;
this.labelDescription1.Text = "Subtitle Edit\'s spell check is based on the NHunspell engine which";
this.labelDescription1.Click += new System.EventHandler(this.labelDescription1_Click);
//
// comboBoxDictionaries
//
@ -111,7 +110,6 @@
this.labelChooseLanguageAndClickDownload.Size = new System.Drawing.Size(201, 13);
this.labelChooseLanguageAndClickDownload.TabIndex = 11;
this.labelChooseLanguageAndClickDownload.Text = "Choose your languge and click download";
this.labelChooseLanguageAndClickDownload.Click += new System.EventHandler(this.labelChooseLanguageAndClickDownload_Click);
//
// labelPleaseWait
//
@ -121,7 +119,6 @@
this.labelPleaseWait.Size = new System.Drawing.Size(73, 13);
this.labelPleaseWait.TabIndex = 12;
this.labelPleaseWait.Text = "Please wait...";
this.labelPleaseWait.Click += new System.EventHandler(this.labelPleaseWait_Click);
//
// GetDictionaries
//

View File

@ -221,20 +221,5 @@ namespace Nikse.SubtitleEdit.Forms
}
private void labelPleaseWait_Click(object sender, EventArgs e)
{
}
private void labelChooseLanguageAndClickDownload_Click(object sender, EventArgs e)
{
}
private void labelDescription1_Click(object sender, EventArgs e)
{
}
}
}

View File

@ -274,16 +274,27 @@ namespace Nikse.SubtitleEdit.Forms
_userWordList = new List<string>();
_userPhraseList = new List<string>();
_userWordDictionary = new XmlDocument();
if (File.Exists(Utilities.DictionaryFolder + _languageName + "_user.xml"))
string fileName = Utilities.DictionaryFolder + _languageName + "_user.xml";
if (File.Exists(fileName))
{
_userWordDictionary.Load(Utilities.DictionaryFolder + _languageName + "_user.xml");
foreach (XmlNode node in _userWordDictionary.DocumentElement.SelectNodes("word"))
try
{
string word = node.InnerText.Trim().ToLower();
if (word.Contains(" "))
_userPhraseList.Add(word);
else
_userWordList.Add(word);
_userWordDictionary.Load(fileName);
foreach (XmlNode node in _userWordDictionary.DocumentElement.SelectNodes("word"))
{
string word = node.InnerText.Trim().ToLower();
if (word.Contains(" "))
_userPhraseList.Add(word);
else
_userWordList.Add(word);
}
}
catch (Exception exception)
{
MessageBox.Show("Unable to load user dictionary for " + _languageName + " from file: " + fileName + Environment.NewLine +
Environment.NewLine +
exception.Source + ": " + exception.Message);
_userWordDictionary.LoadXml("<words />");
}
}
else