public TagTrainer() { InitializeComponent(); dataContainer = new DataContainer(); dataContainer.Version = TagTrainer.FileVersion; dataContainer.tagToSentenceMap = new Dictionary<string, Tuple<List<string>, List<string>>>(); softwareVersionLabel.Text = TagTrainer.SoftwareVersion; this.LoadFromFile(); }
private void LoadFromFile() { if (File.Exists(TagTrainer.fileName)) { FileStream fileStream = null; try { fileStream = new FileStream(TagTrainer.fileName, FileMode.Open); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(DataContainer)); TagTrainer.dataContainer = (DataContainer)serializer.ReadObject(fileStream); tagComboBox.Items.Clear(); foreach (string key in TagTrainer.dataContainer.tagToSentenceMap.Keys) { tagComboBox.Items.Add(key); } fileNameLabel.Text = new FileInfo(TagTrainer.fileName).FullName; fileVersionLabel.Text = TagTrainer.dataContainer.Version; } finally { if (fileStream != null) { fileStream.Close(); } } } else { MessageBox.Show("No file found named " + TagTrainer.fileName); } }