private void Apply_btn_clk(object sender, RoutedEventArgs e) { aa.Composition = this.composition_txt.Text; double mass = 0.0; aa.Element_composition = Element_composition.parse(mainW, aa.Composition, ref mass); aa.Mass = mass; int aa_index = mainW.aas.IndexOf(aa); mainW.aas[aa_index] = aa; mainW.aa_listView.ItemsSource = mainW.aas; mainW.aa_listView.Items.Refresh(); mainW.is_update[4] = true; mainW.is_update_f(); mainW.aa_listView.SelectedItem = aa; mainW.aa_listView.ScrollIntoView(aa); this.Close(); }
public static ObservableCollection <Amino_Acid> load_AA(string aa_ini_path, MainWindow mainW) { ObservableCollection <Amino_Acid> aas = new ObservableCollection <Amino_Acid>(); StreamReader sr = new StreamReader(aa_ini_path, Encoding.Default); while (!sr.EndOfStream) { string line = sr.ReadLine(); if (line.Length >= 1 && line.Substring(0, 1) == "R") { string[] strs = line.Split(new char[] { '=', '|' }, StringSplitOptions.RemoveEmptyEntries); string name = strs[1]; string compostion_str = strs[2]; Amino_Acid aa = new Amino_Acid(name); aa.Composition = compostion_str; double mass = 0.0; aa.Element_composition = Element_composition.parse(mainW, aa.Composition, ref mass); aa.Mass = mass; aas.Add(aa); } } sr.Close(); return(aas); }