public void Detach()
 {
     if (TextBox == null)
     {
         return;
     }
     HideStatementCompletionForm();
     if (_cancellationTokenSource != null)
     {
         _cancellationTokenSource.Cancel();
         _cancellationTokenSource = null;
     }
     _proteinMatcher = null;
     if (null != _proteomeDb)
     {
         _proteomeDb.Dispose();
         _proteomeDb = null;
     }
     TextBox.KeyDown         -= TextBox_KeyDown;
     TextBox.TextChanged     -= TextBox_TextChanged;
     TextBox.GotFocus        -= TextBox_GotFocus;
     TextBox.LostFocus       -= TextBox_LostFocus;
     TextBox.LocationChanged -= TextBox_LocationChanged;
     TextBox = null;
 }
Example #2
0
        private void RefreshStatus()
        {
            if (File.Exists(textPath.Text))
            {
                btnAddFastaFile.Enabled = true;
                ProteomeDb proteomeDb   = null;
                int        proteinCount = 0;
                try
                {
                    using (var longWaitDlg = new LongWaitDlg
                    {
                        Text = Resources.BuildBackgroundProteomeDlg_RefreshStatus_Loading_Proteome_File,
                        Message =
                            string.Format(
                                Resources.BuildBackgroundProteomeDlg_RefreshStatus_Loading_protein_information_from__0__,
                                textPath.Text)
                    })
                    {
                        longWaitDlg.PerformWork(this, 1000, () =>
                        {
                            proteomeDb = ProteomeDb.OpenProteomeDb(textPath.Text);
                            if (proteomeDb != null)
                            {
                                proteinCount = proteomeDb.GetProteinCount(); // This can be a lengthy operation on a large protdb, do it within the longwait
                            }
                        });
                    }
                    if (proteomeDb == null)
                    {
                        throw new Exception();
                    }

                    tbxStatus.Text =
                        string.Format(
                            Resources.BuildBackgroundProteomeDlg_RefreshStatus_The_proteome_file_contains__0__proteins,
                            proteinCount);
                }
                catch (Exception)
                {
                    tbxStatus.Text          = Resources.BuildBackgroundProteomeDlg_OkDialog_The_proteome_file_is_not_valid;
                    btnAddFastaFile.Enabled = false;
                }
                finally
                {
                    if (null != proteomeDb)
                    {
                        proteomeDb.Dispose();
                    }
                }
                textPath.ForeColor = Color.Black;
            }
            else
            {
                btnAddFastaFile.Enabled = false;
                tbxStatus.Text          = Resources.BuildBackgroundProteomeDlg_RefreshStatus_Click_the_Open_button_to_choose_an_existing_proteome_file_or_click_the_Create_button_to_create_a_new_proteome_file;
                textPath.ForeColor      = string.IsNullOrEmpty(textPath.Text) ? Color.Black : Color.Red;
            }
        }
Example #3
0
        private void RefreshStatus()
        {
            if (File.Exists(textPath.Text))
            {
                btnAddFastaFile.Enabled = true;
                ProteomeDb proteomeDb = null;
                try
                {
                    using (var longWaitDlg = new LongWaitDlg
                    {
                        Text = Resources.BuildBackgroundProteomeDlg_RefreshStatus_Loading_Proteome_File,
                        Message =
                            string.Format(
                                Resources.BuildBackgroundProteomeDlg_RefreshStatus_Loading_protein_information_from__0__,
                                textPath.Text)
                    })
                    {
                        longWaitDlg.PerformWork(this, 1000, () => proteomeDb = ProteomeDb.OpenProteomeDb(textPath.Text));
                    }
                    if (proteomeDb == null)
                    {
                        throw new Exception();
                    }

                    int proteinCount = proteomeDb.GetProteinCount();
                    var digestions   = proteomeDb.ListDigestions();
                    tbxStatus.Text =
                        string.Format(
                            Resources.BuildBackgroundProteomeDlg_RefreshStatus_The_proteome_file_contains__0__proteins,
                            proteinCount);
                    if (proteinCount != 0 && digestions.Count > 0)
                    {
                        tbxStatus.Text = TextUtil.LineSeparate(tbxStatus.Text,
                                                               Resources.BuildBackgroundProteomeDlg_RefreshStatus_The_proteome_has_already_been_digested);
                    }
                }
                catch (Exception)
                {
                    tbxStatus.Text          = Resources.BuildBackgroundProteomeDlg_OkDialog_The_proteome_file_is_not_valid;
                    btnAddFastaFile.Enabled = false;
                }
                finally
                {
                    if (null != proteomeDb)
                    {
                        proteomeDb.Dispose();
                    }
                }
            }
            else
            {
                btnAddFastaFile.Enabled = false;
                tbxStatus.Text          = Resources.BuildBackgroundProteomeDlg_RefreshStatus_Click_the_Open_button_to_choose_an_existing_proteome_file_or_click_the_Create_button_to_create_a_new_proteome_file;
            }
        }