private void LoadDictionaryButton_Click(object sender, System.EventArgs e) { using (var dialog = new OpenFileDialog()) { dialog.Multiselect = false; dialog.CheckFileExists = true; dialog.CheckPathExists = true; dialog.ValidateNames = true; dialog.Title = "Please choose the Dictionary file that you would like to read"; dialog.FileName = "Dictionary.dic"; dialog.Filter = "LIWC Dictionary File|*.dic;*.txt"; if (dialog.ShowDialog() == DialogResult.OK) { try { string DicText = File.ReadAllText(dialog.FileName, Encoding.UTF8).Trim(); DictionaryMetaObject InputDictData = new DictionaryMetaObject(Path.GetFileName(dialog.FileName), "User-loaded dictionary", "", DicText); DictParser DP = new DictParser(); InputDictData.DictData = DP.ParseDict(InputDictData); DictDataToReturn = InputDictData; SelectedFileTextbox.Text = dialog.FileName; } catch { MessageBox.Show("There was an error while trying to read/load your dictionary file. Is your dictionary correctly formatted? Have you already added this dictionary to this plugin?", "Error reading dictionary", MessageBoxButtons.OK, MessageBoxIcon.Error); DictDataToReturn = null; SelectedFileTextbox.Text = ""; return; } } else { DictDataToReturn = null; SelectedFileTextbox.Text = ""; } } }
public void ImportSettings(Dictionary <string, string> SettingsDict) { RawFreqs = Boolean.Parse(SettingsDict["RawFreqs"]); IncludeStDevs = Boolean.Parse(SettingsDict["IncludeStDev"]); RoundValuesToNDecimals = Int32.Parse(SettingsDict["RoundLength"]); if (SettingsDict.ContainsKey("DictionaryLocation")) { DictionaryLocation = SettingsDict["DictionaryLocation"]; UserLoadedDictionary = new DictionaryMetaObject(DictionaryLocation, "User Loaded Dictionary", "", SettingsDict["DictionaryContents"]); try { DictParser DP = new DictParser(); UserLoadedDictionary.DictData = DP.ParseDict(UserLoadedDictionary); } catch { DictionaryLocation = ""; UserLoadedDictionary = null; } } }