Beispiel #1
0
 private void Load_ini()
 {
     if (this.tab_control.SelectedIndex == 0 && databases == null) //数据库配置界面
     {
         databases = File_Helper.load_DB(Config_Helper.database_ini);
         this.db_listView.ItemsSource = databases;
     }
     else if (this.tab_control.SelectedIndex == 1 && modifications == null) //修饰配置界面
     {
         modifications = File_Helper.load_Modification(Config_Helper.modification_ini);
         this.mod_listView.ItemsSource = modifications;
     }
     else if (this.tab_control.SelectedIndex == 2) //定量配置界面
     {
         quantifications = File_Helper.load_Quant(Config_Helper.quant_ini);
         this.quant_listView.ItemsSource = quantifications;
     }
     else if (this.tab_control.SelectedIndex == 3 && enzymes == null) //酶配置界面
     {
         enzymes = File_Helper.load_Enzyme(Config_Helper.enzyme_ini);
         this.enzyme_listView.ItemsSource = enzymes;
     }
     else if (this.tab_control.SelectedIndex == 4 && aas == null) //氨基酸配置界面
     {
         aas = File_Helper.load_AA(Config_Helper.aa_ini, this);
         this.aa_listView.ItemsSource = aas;
     }
     else if (this.tab_control.SelectedIndex == 5) //元素配置界面
     {
         this.element_listView.ItemsSource = elements;
     }
 }
Beispiel #2
0
        private void N_count_clk(object sender, RoutedEventArgs e)
        {
            this.aas           = File_Helper.load_AA(Config_Helper.aa_ini, this);
            this.modifications = File_Helper.load_Modification(Config_Helper.modification_ini);
            N_Count_window ncw = new N_Count_window(this);

            ncw.Show();
        }
Beispiel #3
0
        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();
        }
Beispiel #4
0
        private void Save_Element_btn_clk(object sender, RoutedEventArgs e)
        {
            bool save_ok = File_Helper.save_Element(Config_Helper.element_ini, elements);

            if (save_ok)
            {
                is_update[5] = false;
                is_update_f();
            }
        }
Beispiel #5
0
        private void Save_Amino_Acid_btn_clk(object sender, RoutedEventArgs e)
        {
            bool save_ok = File_Helper.save_AA(Config_Helper.aa_ini, aas);

            if (save_ok)
            {
                is_update[4] = false;
                is_update_f();
            }
        }
Beispiel #6
0
        private void Save_Quantification_btn_clk(object sender, RoutedEventArgs e)
        {
            bool save_ok = File_Helper.save_Quantification(Config_Helper.quant_ini, quantifications);

            if (save_ok)
            {
                write_file();
                is_update[2] = false;
                is_update_f();
            }
        }
Beispiel #7
0
        private void Save_Enzymes_btn_clk(object sender, RoutedEventArgs e)
        {
            bool save_ok = File_Helper.save_Enzyme(Config_Helper.enzyme_ini, enzymes);

            if (save_ok)
            {
                write_file();
                is_update[3] = false;
                is_update_f();
            }
        }
Beispiel #8
0
        private void Save_Modification_btn_clk(object sender, RoutedEventArgs e)
        {
            bool save_ok = File_Helper.save_Mod(Config_Helper.modification_ini, modifications);

            if (save_ok)
            {
                write_file();
                is_update[1] = false;
                is_update_f();
            }
        }
Beispiel #9
0
        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();
            }
        }
Beispiel #10
0
        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();
            }
        }
Beispiel #11
0
 //将六个ini文件还原成默认配置,防止用户误操作将ini文件弄坏
 private void restore_ini_files(object sender, RoutedEventArgs e)
 {
     File_Helper.restore_file(Config_Helper.database_ini, Config_Helper.database_default_ini);
     File_Helper.restore_file(Config_Helper.quant_ini, Config_Helper.quant_default_ini);
     File_Helper.restore_file(Config_Helper.modification_ini, Config_Helper.modification_default_ini);
     File_Helper.restore_file(Config_Helper.enzyme_ini, Config_Helper.enzyme_default_ini);
     File_Helper.restore_file(Config_Helper.aa_ini, Config_Helper.aa_default_ini);
     File_Helper.restore_file(Config_Helper.element_ini, Config_Helper.element_default_ini);
     this.databases       = null;
     this.modifications   = null;
     this.quantifications = null;
     this.enzymes         = null;
     this.aas             = null;
     this.elements        = File_Helper.load_Element(Config_Helper.element_ini, ref base_elements); //加载界面的时候即把元素表加载进来,因为修饰,氨基酸表都依靠它
     //注意!!!更新MainWindow中的elements的时候,同时也要更新Element中的index_hash
     Load_ini();
     MessageBox.Show("OK");
 }
Beispiel #12
0
        public MainWindow()
        {
            //add_CrashHandler();
            InitializeComponent();
            elements = File_Helper.load_Element(Config_Helper.element_ini, ref base_elements); //加载界面的时候即把元素表加载进来,因为修饰,氨基酸表都依靠它
            //注意!!!更新MainWindow中的elements的时候,同时也要更新Element中的index_hash
            if (Application.Current.Properties["ArbitraryArgName"] != null)
            {
                this.tab_control.SelectedIndex = int.Parse(Application.Current.Properties["ArbitraryArgName"] as string);

                for (int i = 0; i < this.tab_control.Items.Count; ++i)
                {
                    if (i != this.tab_control.SelectedIndex)
                    {
                        TabItem item = this.tab_control.Items[i] as TabItem;
                        item.Visibility = Visibility.Collapsed;
                    }
                }
            }
        }
Beispiel #13
0
        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;
            }
        }