private void ok_btn_clk(object sender, RoutedEventArgs e) { if (Name_txt.Text == "" || Path_txt.Text == "") { MessageBox.Show(Message_Helper.DB_NAME_PATH_NULL_Message); return; } if (!File.Exists(Path_txt.Text)) { MessageBox.Show(Message_Helper.DB_PATH_NOT_EXIST_Message); return; } Database new_database = new Database(Name_txt.Text, Path_txt.Text); bool is_in = false; for (int i = 0; i < MainW.databases.Count; ++i) { if (MainW.db_listView.SelectedIndex != i && MainW.databases[i].DB_Name == new_database.DB_Name) { is_in = true; break; } } if (is_in) { MessageBox.Show(Message_Helper.NAME_IS_USED_Message); return; } if (!Config_Helper.IsNameRight(new_database.DB_Name)) { MessageBox.Show(Message_Helper.NAME_WRONG); return; } if ((bool)this.add_con_cbx.IsChecked) { string path = Path_txt.Text; string old_path = path; path = path.Replace(".fasta", "_con.fasta"); Path_txt.Text = path; if (!File_Helper.add_database_containment(old_path, path, Config_Helper.containment_path)) { return; } new_database.DB_Path = Path_txt.Text; MessageBox.Show(Message_Helper.DB_CONTAINMENT_PATH_Message + new_database.DB_Path + "."); } int index = MainW.db_listView.SelectedIndex; MainW.databases[index] = new_database; MainW.db_listView.Items.Refresh(); MainW.is_update[0] = true; MainW.is_update_f(); MainW.db_listView.SelectedItem = new_database; MainW.db_listView.ScrollIntoView(new_database); this.Close(); }
private void ok_btn_clk(object sender, RoutedEventArgs e) { if (Name_txt.Text == "" || Path_txt.Text == "") { MessageBox.Show(Message_Helper.DB_NAME_PATH_NULL_Message); return; } if (!File.Exists(Path_txt.Text)) { MessageBox.Show(Message_Helper.DB_PATH_NOT_EXIST_Message); return; } Database new_database = new Database(Name_txt.Text, Path_txt.Text); if (MainW.databases.Contains(new_database)) { MessageBox.Show(Message_Helper.NAME_IS_USED_Message); return; } if (!Config_Helper.IsNameRight(new_database.DB_Name)) { MessageBox.Show(Message_Helper.NAME_WRONG); return; } if ((bool)this.add_con_cbx.IsChecked) { string path = Path_txt.Text; string old_path = path; path = path.Replace(".fasta", "_contaminant.fasta"); Path_txt.Text = path; if (!File_Helper.add_database_containment(old_path, path, Config_Helper.containment_path)) { return; } new_database.DB_Path = Path_txt.Text; MessageBox.Show(Message_Helper.DB_CONTAINMENT_PATH_Message + new_database.DB_Path + "."); } MainW.add_databases.Add(new_database); MainW.databases.Add(new_database); MainW.is_update[0] = true; MainW.is_update_f(); MainW.db_listView.SelectedItem = new_database; MainW.db_listView.ScrollIntoView(new_database); this.Close(); if (Application.Current.Properties["ArbitraryArgName"] != null) { MainW.is_update[0] = false; bool save_ok = File_Helper.save_DB(Config_Helper.database_ini, MainW.databases); MainW.Close(); } }
private void Apply_btn_clk(object sender, RoutedEventArgs e) { string name = this.name_txt.Text; string cleave = this.cleave_txt.Text; string ignore = this.ignore_txt.Text; ComboBoxItem cbi = this.N_C_comboBox.SelectedItem as ComboBoxItem; string n_c = cbi.Content as string; switch (n_c) { case "N-term": n_c = "N"; break; case "C-term": n_c = "C"; break; } bool is_flag = true; for (int i = 0; i < cleave.Length; ++i) { if (cleave[i] < 'A' || cleave[i] > 'Z') { is_flag = false; break; } } if (!is_flag) { MessageBox.Show(Message_Helper.EN_CLEAVE_A_TO_Z_Message); return; } if (cleave == "") { MessageBox.Show(Message_Helper.EN_CLEAVE_NULL_Message); return; } is_flag = true; for (int i = 0; i < ignore.Length; ++i) { if (ignore[i] < 'A' || ignore[i] > 'Z') { is_flag = false; break; } } if (!is_flag) { MessageBox.Show(Message_Helper.EN_IGNORE_A_TO_Z_Message); return; } if (ignore == "") { ignore = "_"; } Enzyme enzyme = new Enzyme(name, cleave, ignore, n_c); if (mainW.enzymes.Contains(enzyme)) { MessageBox.Show(Message_Helper.NAME_IS_USED_Message); return; } if (!Config_Helper.IsNameRight(enzyme.Name)) { MessageBox.Show(Message_Helper.NAME_WRONG); return; } mainW.add_enzymes.Add(enzyme); mainW.enzymes.Add(enzyme); mainW.is_update[3] = true; mainW.is_update_f(); mainW.enzyme_listView.SelectedItem = enzyme; mainW.enzyme_listView.ScrollIntoView(enzyme); this.Close(); }
private void Apply_btn_clk(object sender, RoutedEventArgs e) { string name = this.name_txt.Text; Element element = new Element(name); bool is_in = false; for (int i = 0; i < mainW.elements.Count; ++i) { if (mainW.element_listView.SelectedIndex != i && mainW.elements[i].Name == element.Name) { is_in = true; break; } } if (is_in) { MessageBox.Show(Message_Helper.NAME_IS_USED_Message); return; } if (!Config_Helper.IsNameRight(element.Name)) { MessageBox.Show(Message_Helper.NAME_WRONG); return; } List <double> mass_list = new List <double>(); List <double> ratio_list = new List <double>(); for (int i = 0; i < this.grid.RowDefinitions.Count; ++i) { if (this.grid.Children[i].Visibility == Visibility.Collapsed) { continue; } StackPanel sp = this.grid.Children[i] as StackPanel; TextBox mass_tbx = sp.Children[1] as TextBox; TextBox ratio_tbx = sp.Children[3] as TextBox; string mass_str = mass_tbx.Text; string ratio_str = ratio_tbx.Text; if (!Config_Helper.IsDecimalAllowed(mass_str) || !Config_Helper.IsDecimalAllowed(ratio_str)) { MessageBox.Show(Message_Helper.EL_MASS_RATIO_DOUBLE_Message); return; } mass_list.Add(double.Parse(mass_str)); ratio_list.Add(double.Parse(ratio_str)); } double all_ratio = 0.0; double max_mass = 0.0, max_ratio = 0.0; for (int i = 0; i < mass_list.Count; ++i) { all_ratio += ratio_list[i]; if (ratio_list[i] > max_ratio) { max_ratio = ratio_list[i]; max_mass = mass_list[i]; } } if (Math.Abs(all_ratio - 1.0) >= 1.0e-9) { MessageBox.Show(Message_Helper.EL_SUM_RATIO_ONE_Message); return; } element.MMass = max_mass; element.Mass = mass_list; element.Ratio = ratio_list; element.update_mass_str(); int index = mainW.element_listView.SelectedIndex; mainW.elements[index] = element; mainW.element_listView.Items.Refresh(); mainW.is_update[5] = true; mainW.is_update_f(); mainW.element_listView.SelectedItem = element; mainW.element_listView.ScrollIntoView(element); this.Close(); }
private void Apply_btn_clk(object sender, RoutedEventArgs e) { string name = name_txt.Text; if (name == "") { MessageBox.Show(Message_Helper.QU_NAME_NULL_Message); return; } Quantification new_q = new Quantification(name); for (int i = 0; i < this.grid.RowDefinitions.Count; ++i) { if (this.grid.Children[i].Visibility == Visibility.Collapsed) { continue; } StackPanel sp = this.grid.Children[i] as StackPanel; TextBox aa_tbx = sp.Children[1] as TextBox; TextBox label0_tbx = sp.Children[3] as TextBox; TextBox label1_tbx = sp.Children[5] as TextBox; string aa_str = aa_tbx.Text; string label0_str = label0_tbx.Text; string label1_str = label1_tbx.Text; bool is_right = false; if (aa_str.Length == 1 && (aa_str[0] == '*' || (aa_str[0] >= 'A' && aa_str[0] <= 'Z'))) { is_right = true; } if (!is_right) { MessageBox.Show(Message_Helper.QU_AA_A_TO_Z_Message); return; } is_right = false; for (int j = 0; j < mainW.elements.Count; ++j) { if (mainW.elements[j].Name == label0_str) { is_right = true; break; } } if (!is_right) { MessageBox.Show(Message_Helper.QU_LABEL0_NAME_Message); return; } is_right = false; for (int j = 0; j < mainW.elements.Count; ++j) { if (mainW.elements[j].Name == label1_str) { is_right = true; break; } } if (!is_right) { MessageBox.Show(Message_Helper.QU_LABEL1_NAME_Message); return; } Quant_Simple qs = new Quant_Simple(aa_str[0], label0_str, label1_str); new_q.All_quant.Add(qs); } new_q.All_quant_str = Quantification.get_string(new_q.Name, new_q.All_quant); bool is_in = false; for (int i = 0; i < mainW.quantifications.Count; ++i) { if (mainW.quant_listView.SelectedIndex != i && mainW.quantifications[i].Name == new_q.Name) { is_in = true; break; } } if (is_in) { MessageBox.Show(Message_Helper.NAME_IS_USED_Message); return; } if (!Config_Helper.IsNameRight(new_q.Name)) { MessageBox.Show(Message_Helper.NAME_WRONG); return; } int index = mainW.quant_listView.SelectedIndex; mainW.quantifications[index] = new_q; mainW.quant_listView.Items.Refresh(); mainW.is_update[2] = true; mainW.is_update_f(); mainW.quant_listView.SelectedItem = new_q; mainW.quant_listView.ScrollIntoView(new_q); this.Close(); }
private void apply_btn_clk(object sender, RoutedEventArgs e) { string name = name_txt.Text; string composition = composition_txt.Text; string mass_str = mass_txt.Text; ComboBoxItem cbi = position_comboBox.SelectedItem as ComboBoxItem; string position = cbi.Content as string; string position_display = ""; string site = site_txt.Text; string neutral_loss = Neutral_Loss_txt.Text; bool is_common = (bool)Common_checkBox.IsChecked; if (name == "" || composition == "" || !Config_Helper.IsDecimalAllowed(mass_str) || site == "") { if (name == "") { name_txt.Background = new SolidColorBrush(Colors.Red); } if (composition == "") { composition_txt.Background = new SolidColorBrush(Colors.Red); } if (!Config_Helper.IsDecimalAllowed(mass_str)) { mass_txt.Background = new SolidColorBrush(Colors.Red); } if (site == "") { site_txt.Background = new SolidColorBrush(Colors.Red); } if (neutral_loss != "") { string[] strs = neutral_loss.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < strs.Length; ++i) { if (!Config_Helper.IsDecimalAllowed(strs[i])) { Neutral_Loss_txt.Background = new SolidColorBrush(Colors.Red); } } } MessageBox.Show(Message_Helper.MO_INPUT_WRONG_Message); return; } if (Site_wrong(site)) { site_txt.Background = new SolidColorBrush(Colors.Red); MessageBox.Show(Message_Helper.MO_AA_REPEAT); return; } ObservableCollection <double> neutral_loss_list = new ObservableCollection <double>(); //默认以;进行分隔 if (neutral_loss != "") { string[] strs = neutral_loss.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < strs.Length; ++i) { if (!Config_Helper.IsDecimalAllowed(strs[i])) { Neutral_Loss_txt.Background = new SolidColorBrush(Colors.Red); MessageBox.Show(Message_Helper.MO_INPUT_WRONG_Message); return; } neutral_loss_list.Add(double.Parse(strs[i])); } } switch (position) { case "Anywhere": position = "NORMAL"; position_display = "NORMAL"; break; case "PepN-term": position = "PEP_N"; position_display = "Peptide N-term"; break; case "PepC-term": position = "PEP_C"; position_display = "Peptide C-term"; break; case "ProN-term": position = "PRO_N"; position_display = "Protein N-term"; break; case "ProC-term": position = "PRO_C"; position_display = "Protein C-term"; break; } Modification modification = new Modification(name, is_common, site, position, double.Parse(mass_str), composition, neutral_loss_list); modification.Position_Display = position_display; if (mainW.modifications.Contains(modification)) { MessageBox.Show(Message_Helper.NAME_IS_USED_Message); return; } if (!Config_Helper.IsNameRight(modification.Name)) { MessageBox.Show(Message_Helper.NAME_WRONG); return; } mainW.add_modifications.Add(modification); mainW.modifications.Add(modification); mainW.is_update[1] = true; mainW.is_update_f(); mainW.mod_listView.SelectedItem = modification; mainW.mod_listView.ScrollIntoView(modification); this.Close(); }