private void Save_Databse_btn_clk(object sender, RoutedEventArgs e) { bool save_ok = File_Helper.save_DB(Config_Helper.database_ini, databases); if (save_ok) { write_file(); is_update[0] = false; is_update_f(); } }
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 close_window(object sender, System.ComponentModel.CancelEventArgs e) { bool is_update_t = false; for (int i = 0; i < 6; ++i) { if (is_update[i]) { is_update_t = true; break; } } if (!is_update_t) { //refresh_file(); return; } MessageBoxButton buttons = MessageBoxButton.YesNoCancel; MessageBoxImage icon = MessageBoxImage.Warning; string message = Message_Helper.Tab_Saved_Prompt; string caption = "Warning"; MessageBoxResult mbr = MessageBox.Show(message, caption, buttons, icon); if (mbr == MessageBoxResult.Yes) { write_file(); for (int i = 0; i < 6; ++i) { if (!is_update[i]) { continue; } switch (i) { case 0: if (!File_Helper.save_DB(Config_Helper.database_ini, databases)) { return; } break; case 1: if (!File_Helper.save_Mod(Config_Helper.modification_ini, modifications)) { return; } break; case 2: if (!File_Helper.save_Quantification(Config_Helper.quant_ini, quantifications)) { return; } break; case 3: if (!File_Helper.save_Enzyme(Config_Helper.enzyme_ini, enzymes)) { return; } break; case 4: if (!File_Helper.save_AA(Config_Helper.aa_ini, aas)) { return; } break; case 5: if (!File_Helper.save_Element(Config_Helper.element_ini, elements)) { return; } break; } } } else if (mbr == MessageBoxResult.No) { refresh_file(); return;// not save data, but still close the window. } else { e.Cancel = true; } }