示例#1
0
        public Tuple <Clusterer, ClusteredReportResults, ReportColorScheme> GetClusteredResults()
        {
            Tuple <Clusterer, ClusteredReportResults, ReportColorScheme> resultsTuple = null;

            try
            {
                using (var longWaitDlg = new LongWaitDlg())
                {
                    longWaitDlg.PerformWork(FormUtil.FindTopLevelOwner(this), 1000,
                                            broker => { resultsTuple = GetClusteredResultsBackground(broker); });
                    if (longWaitDlg.IsCanceled)
                    {
                        return(null);
                    }
                }
            }
            catch (Exception exception)
            {
                MessageDlg.ShowWithException(FormUtil.FindTopLevelOwner(this), Resources.DataboundGridControl_GetClusteredResults_An_error_occured_while_performing_clustering_, exception);
                return(null);
            }

            if (resultsTuple == null)
            {
                MessageDlg.Show(FormUtil.FindTopLevelOwner(this),
                                Resources.DataboundGridControl_GetClusteredResults_Unable_to_choose_a_set_of_columns_to_use_for_hierarchical_clustering_);
                return(null);
            }

            return(resultsTuple);
        }
示例#2
0
        private MsDataFilePath[] GetWiffSubPaths(string filePath)
        {
            using (var longWaitDlg = new LongWaitDlg
            {
                Text = Resources.ImportResultsDlg_GetWiffSubPaths_Sample_Names,
                Message = string.Format(Resources.ImportResultsDlg_GetWiffSubPaths_Reading_sample_names_from__0__,
                                        Path.GetFileName(filePath))
            })
            {
                string[] dataIds = null;
                try
                {
                    longWaitDlg.PerformWork(this, 800, () => dataIds = MsDataFileImpl.ReadIds(filePath));
                }
                catch (Exception x)
                {
                    string message = TextUtil.LineSeparate(
                        string.Format(Resources.ImportResultsDlg_GetWiffSubPaths_An_error_occurred_attempting_to_read_sample_information_from_the_file__0__, filePath),
                        Resources.ImportResultsDlg_GetWiffSubPaths_The_file_may_be_corrupted_missing_or_the_correct_libraries_may_not_be_installed,
                        x.Message);
                    MessageDlg.ShowWithException(this, message, x);
                }

                return(DataSourceUtil.GetWiffSubPaths(filePath, dataIds, ChooseSamples));
            }
        }
        public bool TestSettings()
        {
            if (!ValidateValues())
            {
                return(false);
            }
            ChorusAccount chorusAccount = GetChorusAccount();
            ChorusSession chorusSession = new ChorusSession();

            try
            {
                CookieContainer cookieContainer = new CookieContainer();
                try
                {
                    chorusSession.Login(chorusAccount, cookieContainer);
                    MessageDlg.Show(this, Resources.EditChorusAccountDlg_TestSettings_Settings_are_correct);
                    return(true);
                }
                catch (ChorusServerException chorusException)
                {
                    MessageDlg.ShowException(this, chorusException);
                    textPassword.Focus();
                    return(false);
                }
            }
            catch (Exception x)
            {
                MessageDlg.ShowWithException(this, Resources.EditChorusAccountDlg_TestSettings_Error_connecting_to_server__ + x.Message, x);
                textServerURL.Focus();
                return(false);
            }
        }
示例#4
0
        public void CreateDb(string fileName)
        {
            // If the file exists, then the user chose to overwrite,
            // so delete the existing file.
            try
            {
                FileEx.SafeDelete(fileName);
            }
            catch (IOException x)
            {
                MessageDlg.ShowException(this, x);
                return;
            }

            Settings.Default.ProteomeDbDirectory = Path.GetDirectoryName(fileName);

            try
            {
                ProteomeDb.CreateProteomeDb(fileName);
            }
            catch (Exception x)
            {
                var message = TextUtil.LineSeparate(string.Format(
                                                        Resources
                                                        .BuildBackgroundProteomeDlg_btnCreate_Click_An_error_occurred_attempting_to_create_the_proteome_file__0__,
                                                        fileName), x.Message);
                MessageDlg.ShowWithException(this, message, x);
            }

            if (textName.Text.Length == 0)
            {
                textName.Text = Path.GetFileNameWithoutExtension(fileName);
            }
            textPath.Text = fileName;   // This will cause RefreshStatus()
        }
示例#5
0
 private bool GetPython()
 {
     try
     {
         using (var waitDlg = new LongWaitDlg {
             ProgressValue = 0
         })
         {
             // Short wait, because this can't possible happen fast enough to avoid
             // showing progress, except in testing
             waitDlg.PerformWork(this, 50, DownloadPython);
         }
         using (var waitDlg = new LongWaitDlg(null, false)
         {
             Message = Resources.PythonInstaller_GetPython_Installing_Python
         })
         {
             waitDlg.PerformWork(this, 50, InstallPython);
         }
         MessageDlg.Show(this, Resources.PythonInstaller_GetPython_Python_installation_completed_);
         return(true);
     }
     catch (Exception ex)
     {
         MessageDlg.ShowWithException(this, (ex.InnerException ?? ex).Message, ex);
     }
     return(false);
 }
示例#6
0
 private bool TestChorusAccount(ChorusAccount chorusAccount)
 {
     using (ChorusSession chorusSession = new ChorusSession(chorusAccount))
     {
         try
         {
             CookieContainer cookieContainer = new CookieContainer();
             try
             {
                 chorusSession.Login(chorusAccount, cookieContainer);
                 MessageDlg.Show(this, Resources.EditChorusAccountDlg_TestSettings_Settings_are_correct);
                 return(true);
             }
             catch (RemoteServerException chorusException)
             {
                 MessageDlg.ShowException(this, chorusException);
                 textPassword.Focus();
                 return(false);
             }
         }
         catch (Exception x)
         {
             MessageDlg.ShowWithException(this, Resources.EditChorusAccountDlg_TestSettings_Error_connecting_to_server__ + x.Message, x);
             textServerURL.Focus();
             return(false);
         }
     }
 }
        public void CreateDatabase(string path)
        {
            //The file that was just created does not have a schema, so SQLite won't touch it.
            //The file must have a schema or not exist for use with SQLite, so we'll delete
            //it and install a schema

            try
            {
                FileEx.SafeDelete(path);
            }
            catch (IOException x)
            {
                MessageDlg.ShowException(this, x);
                return;
            }

            //Create file, initialize db
            try
            {
                IonMobilityDb.CreateIonMobilityDb(path);

                textDatabase.Text = path;
            }
            catch (DatabaseOpeningException x)
            {
                MessageDlg.ShowException(this, x);
            }
            catch (Exception x)
            {
                var message = TextUtil.LineSeparate(string.Format(Resources.EditIonMobilityLibraryDlg_CreateDatabase_The_ion_mobility_library_file__0__could_not_be_created, path),
                                                    x.Message);
                MessageDlg.ShowWithException(this, message, x);
            }
        }
示例#8
0
        public bool WriteChromatograms(string filePath)
        {
            var fileNames = (from object fileName in checkedListVars.CheckedItems select fileName.ToString()).ToList();

            using (var longWaitDlg = new LongWaitDlg
            {
                Text = Resources.ExportChromatogramDlg_OkDialog_Exporting_Chromatograms,
            })
            {
                try
                {
                    longWaitDlg.PerformWork(this, 1000,
                                            broker => WriteChromatograms(filePath,
                                                                         broker,
                                                                         fileNames,
                                                                         LocalizationHelper.CurrentCulture,
                                                                         _chromExtractors,
                                                                         _chromSources));
                    if (longWaitDlg.IsCanceled)
                    {
                        return(false);
                    }
                }
                catch (Exception x)
                {
                    var message = TextUtil.LineSeparate(string.Format(Resources.ExportChromatogramDlg_OkDialog_Failed_attempting_to_save_chromatograms_to__0__, filePath),
                                                        x.Message);
                    MessageDlg.ShowWithException(this, message, x);
                }
            }
            return(true);
        }
示例#9
0
        private bool LoadPeptideSearchLibrary(LibrarySpec docLibSpec)
        {
            if (docLibSpec == null)
            {
                return(false);
            }

            using (var longWait = new LongWaitDlg
            {
                Text = Resources.BuildPeptideSearchLibraryControl_LoadPeptideSearchLibrary_Loading_Library
            })
            {
                try
                {
                    var status = longWait.PerformWork(WizardForm, 800, monitor => ImportPeptideSearch.LoadPeptideSearchLibrary(LibraryManager, docLibSpec, monitor));
                    if (status.IsError)
                    {
                        MessageDlg.ShowException(WizardForm, status.ErrorException);
                    }
                }
                catch (Exception x)
                {
                    MessageDlg.ShowWithException(WizardForm,
                                                 TextUtil.LineSeparate(string.Format(Resources.BuildPeptideSearchLibraryControl_LoadPeptideSearchLibrary_An_error_occurred_attempting_to_import_the__0__library_,
                                                                                     docLibSpec.Name), x.Message), x);
                }
            }
            return(ImportPeptideSearch.HasDocLib);
        }
示例#10
0
        public bool Open(string skypPath, IEnumerable <Server> servers, FormEx parentWindow = null)
        {
            SkypFile skyp = null;

            try
            {
                skyp = SkypFile.Create(skypPath, servers);

                using (var longWaitDlg = new LongWaitDlg
                {
                    Text = Resources.SkypSupport_Open_Downloading_Skyline_Document_Archive,
                })
                {
                    longWaitDlg.PerformWork(parentWindow ?? _skyline, 1000, progressMonitor => Download(skyp, progressMonitor, parentWindow));
                    if (longWaitDlg.IsCanceled)
                    {
                        return(false);
                    }
                }
                return(_skyline.OpenSharedFile(skyp.DownloadPath));
            }
            catch (Exception e)
            {
                if (_retryRemaining-- > 0 && skyp != null && e.Message.Contains(AddPanoramaServerMessage(skyp)))
                {
                    return(AddServerAndOpen(skypPath, e.Message, parentWindow));
                }
                else
                {
                    var message = TextUtil.LineSeparate(Resources.SkypSupport_Open_Failure_opening_skyp_file_, e.Message);
                    MessageDlg.ShowWithException(parentWindow ?? _skyline, message, e);
                    return(false);
                }
            }
        }
示例#11
0
 public void OkDialog()
 {
     if (radioProtein.Checked)
     {
         if (comboProteins.SelectedIndex == -1)
         {
             MessageDlg.Show(this, Resources.ChooseIrtStandardPeptidesDlg_OkDialog_Please_select_a_protein_containing_the_list_of_standard_peptides_for_the_iRT_calculator_);
             comboProteins.Focus();
             return;
         }
         var peptideGroupItem = comboProteins.SelectedItem as PeptideGroupItem;
         if (peptideGroupItem != null)
         {
             var protein = peptideGroupItem.PeptideGroup;
             _irtPeptideSequences = new HashSet <string>();
             foreach (var peptide in protein.Peptides)
             {
                 _irtPeptideSequences.Add(peptide.ModifiedSequence);
             }
             if (Document.PeptideGroupCount > 0)
             {
                 var pathFrom = Document.GetPathTo(Document.FindNodeIndex(protein.Id));
                 var pathTo   = Document.GetPathTo(Document.FindNodeIndex(Document.PeptideGroups.First().Id));
                 if (!Equals(pathFrom, pathTo))
                 {
                     IdentityPath newLocation;
                     Document = Document.MoveNode(pathFrom, pathTo, out newLocation);
                 }
             }
         }
     }
     else
     {
         if (!File.Exists(txtTransitionList.Text))
         {
             MessageDlg.Show(this, Resources.ChooseIrtStandardPeptides_OkDialog_Transition_list_field_must_contain_a_path_to_a_valid_file_);
             txtTransitionList.Focus();
             return;
         }
         try
         {
             IdentityPath selectPath;
             List <TransitionImportErrorInfo> errorList;
             var inputs = new MassListInputs(txtTransitionList.Text);
             Document = Document.ImportMassList(inputs, new IdentityPath(Document.PeptideGroups.First().Id), out selectPath, out _irtPeptides, out _librarySpectra, out errorList);
             if (errorList.Any())
             {
                 throw new InvalidDataException(errorList[0].ErrorMessage);
             }
             IrtFile = txtTransitionList.Text;
         }
         catch (Exception x)
         {
             MessageDlg.ShowWithException(this, string.Format(Resources.CreateIrtCalculatorDlg_OkDialog_Error_reading_iRT_standards_transition_list___0_, x.Message), x);
             return;
         }
     }
     DialogResult = DialogResult.OK;
 }
示例#12
0
        /// <summary>
        /// Inspects an exception thrown during XML deserialization, constructs an
        /// appropriate error message, and shows it in a message box.
        /// <para>
        /// Common problems like files truncated during transfer are handled, and
        /// line and column numbers are displayed in a sentence understandable by
        /// a normal user.</para>
        /// </summary>
        /// <param name="firstLine">First line of the message specific to the situation</param>
        /// <param name="path">Path to the XML file</param>
        /// <param name="x">An <see cref="Exception"/> thrown during XML parsing</param>
        public void ShowXmlParsingError(string firstLine, string path, Exception x)
        {
            if (!_showMessages)
            {
                return;
            }
            string messageException = XmlUtil.GetInvalidDataMessage(path, x);

            MessageDlg.ShowWithException(_parent, TextUtil.LineSeparate(firstLine, messageException), x);
        }
示例#13
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            string filterProtDb = TextUtil.FileDialogFiltersAll(FILTER_PROTDB);

            string fileName;

            using (var saveFileDialog = new SaveFileDialog
            {
                Filter = filterProtDb,
                InitialDirectory = Settings.Default.ProteomeDbDirectory,
                Title = Resources.BuildBackgroundProteomeDlg_btnCreate_Click_Create_Background_Proteome,
                OverwritePrompt = true,
            })
            {
                if (saveFileDialog.ShowDialog(this) == DialogResult.Cancel)
                {
                    return;
                }

                fileName = saveFileDialog.FileName;
            }

            // If the file exists, then the user chose to overwrite,
            // so delete the existing file.
            try
            {
                FileEx.SafeDelete(fileName);
            }
            catch (IOException x)
            {
                MessageDlg.ShowException(this, x);
                return;
            }

            Settings.Default.ProteomeDbDirectory = Path.GetDirectoryName(fileName);

            textPath.Text = fileName;
            if (textName.Text.Length == 0)
            {
                textName.Text = Path.GetFileNameWithoutExtension(fileName);
            }

            try
            {
                ProteomeDb.CreateProteomeDb(fileName);
            }
            catch (Exception x)
            {
                var message = TextUtil.LineSeparate(string.Format(Resources.BuildBackgroundProteomeDlg_btnCreate_Click_An_error_occurred_attempting_to_create_the_proteome_file__0__,
                                                                  fileName), x.Message);
                MessageDlg.ShowWithException(this, message, x);
            }

            RefreshStatus();
        }
示例#14
0
        public void OkDialog()
        {
            if (!_messageBoxHelper.ValidateNameTextBox(textName, out _name))
            {
                return;
            }
            if (_backgroundProteomeSpec == null || _name != _backgroundProteomeSpec.Name)
            {
                foreach (BackgroundProteomeSpec backgroundProteomeSpec in _existing)
                {
                    if (_name == backgroundProteomeSpec.Name)
                    {
                        _messageBoxHelper.ShowTextBoxError(textName, Resources.BuildBackgroundProteomeDlg_OkDialog_The_background_proteome__0__already_exists, _name);
                        return;
                    }
                }
            }
            if (string.IsNullOrEmpty(textPath.Text))
            {
                _messageBoxHelper.ShowTextBoxError(textPath, Resources.BuildBackgroundProteomeDlg_OkDialog_You_must_specify_a_proteome_file);
                return;
            }
            try
            {
                if (textPath.Text != Path.GetFullPath(textPath.Text))
                {
                    _messageBoxHelper.ShowTextBoxError(textPath, Resources.BuildBackgroundProteomeDlg_OkDialog_Please_specify_a_full_path_to_the_proteome_file);
                    return;
                }
                else if (!File.Exists(textPath.Text))
                {
                    _messageBoxHelper.ShowTextBoxError(textPath,
                                                       string.Format(Resources.BuildBackgroundProteomeDlg_OkDialog_The_proteome_file__0__does_not_exist, textPath.Text));
                    return;
                }

                ProteomeDb.OpenProteomeDb(textPath.Text);
            }
            catch (Exception x)
            {
                // In case exception is thrown opening protdb
                string message = TextUtil.LineSeparate(Resources.BuildBackgroundProteomeDlg_OkDialog_The_proteome_file_is_not_valid,
                                                       Resources.BuildBackgroundProteomeDlg_OkDialog_Choose_a_valid_proteome_file__or_click_the__Create__button_to_create_a_new_one_from_FASTA_files);
                MessageDlg.ShowWithException(this, message, x);
                return;
            }

            _databasePath           = textPath.Text;
            _name                   = textName.Text;
            _backgroundProteomeSpec = new BackgroundProteomeSpec(_name, _databasePath);
            DialogResult            = DialogResult.OK;
            Close();
        }
示例#15
0
        public void OkDialog()
        {
            var    helper = new MessageBoxHelper(this, true);
            string name;

            if (!helper.ValidateNameTextBox(tbxListName, out name))
            {
                return;
            }
            if (name != _listDefOriginal.ListName && _existing.Any(listDef => listDef.Name == name))
            {
                helper.ShowTextBoxError(tbxListName, string.Format(Resources.ListDesigner_OkDialog_There_is_already_a_list_named___0___, name));
                return;
            }
            var propertyNames = new HashSet <string>();

            for (int i = 0; i < _listProperties.Count; i++)
            {
                if (!propertyNames.Add(_listProperties[i].Name))
                {
                    MessageDlg.Show(this, Resources.ListDesigner_OkDialog_Duplicate_property_name);
                    dataGridViewProperties.CurrentCell = dataGridViewProperties.Rows[i].Cells[colPropertyName.Index];
                    return;
                }
            }
            string idProperty = comboIdProperty.SelectedItem as string;

            if (!string.IsNullOrEmpty(idProperty) && !propertyNames.Contains(idProperty))
            {
                MessageDlg.Show(this, Resources.ListDesigner_OkDialog_No_such_property);
                comboIdProperty.Focus();
                return;
            }
            string displayProperty = comboDisplayProperty.SelectedItem as string;

            if (!string.IsNullOrEmpty(displayProperty) && !propertyNames.Contains(displayProperty))
            {
                MessageDlg.Show(this, Resources.ListDesigner_OkDialog_No_such_property);
                comboDisplayProperty.Focus();
                return;
            }
            try
            {
                GetListDef();
            }
            catch (Exception e)
            {
                MessageDlg.ShowWithException(this, TextUtil.LineSeparate(Resources.ListDesigner_OkDialog_There_was_an_error_trying_to_apply_this_list_definition_to_the_original_data_, e.Message), e);
                return;
            }

            DialogResult = DialogResult.OK;
        }
示例#16
0
        public void OkDialog()
        {
            var    helper = new MessageBoxHelper(this);
            string name;

            if (!helper.ValidateNameTextBox(tbxName, out name))
            {
                return;
            }

            if (name != _originalName && _existing.Any(existingRuleSet => existingRuleSet.Name == name))
            {
                helper.ShowTextBoxError(tbxName, string.Format(Resources.MetadataRuleEditor_OkDialog_There_is_already_a_metadata_rule_named___0___, name));
                return;
            }

            var ruleSet = MetadataRuleSet;

            for (int rowIndex = 0; rowIndex < ruleSet.Rules.Count; rowIndex++)
            {
                var rule = ruleSet.Rules[rowIndex];
                if (rule.Source == null)
                {
                    MessageDlg.Show(this, string.Format(Resources.MetadataRuleEditor_OkDialog__0__cannot_be_blank, colSource.HeaderText));
                    SelectCell(dataGridViewRules, colSource, rowIndex);
                    return;
                }

                if (!string.IsNullOrEmpty(rule.Pattern))
                {
                    try
                    {
                        var _ = new Regex(rule.Pattern);
                    }
                    catch (Exception exception)
                    {
                        MessageDlg.ShowWithException(this, Resources.MetadataRuleEditor_OkDialog_This_is_not_a_valid_regular_expression_, exception);
                        SelectCell(dataGridViewRules, colPattern, rowIndex);
                        return;
                    }
                }

                if (rule.Target == null)
                {
                    MessageDlg.Show(this, string.Format(Resources.MetadataRuleEditor_OkDialog__0__cannot_be_blank, colTarget.HeaderText));
                    SelectCell(dataGridViewRules, colTarget, rowIndex);
                    return;
                }
            }


            DialogResult = DialogResult.OK;
        }
示例#17
0
 private void AddSubFolders(Server server, TreeNode node, JToken folder)
 {
     try
     {
         AddChildContainers(server, node, folder);
     }
     catch (Exception x)
     {
         MessageDlg.ShowWithException(this, TextUtil.LineSeparate(Resources.PublishDocumentDlg_addSubFolders_Error_retrieving_server_folders,
                                                                  x.Message), x);
     }
 }
示例#18
0
        public void AddFastaFile(string fastaFilePath)
        {
            String databasePath = textPath.Text;

            Settings.Default.FastaDirectory = Path.GetDirectoryName(fastaFilePath);
            int duplicateSequenceCount = 0;

            using (var longWaitDlg = new LongWaitDlg {
                ProgressValue = 0
            })
            {
                try
                {
                    longWaitDlg.PerformWork(this, 0, progressMonitor =>
                    {
                        ProteomeDb proteomeDb = File.Exists(databasePath)
                            ? ProteomeDb.OpenProteomeDb(databasePath)
                            : ProteomeDb.CreateProteomeDb(databasePath);
                        using (proteomeDb)
                        {
                            using (var reader = File.OpenText(fastaFilePath))
                            {
                                IProgressStatus status = new ProgressStatus(longWaitDlg.Message);
                                proteomeDb.AddFastaFile(reader, progressMonitor, ref status, false, out duplicateSequenceCount);
                            }
                        }
                    });
                }
                catch (Exception x)
                {
                    var message = TextUtil.LineSeparate(string.Format(Resources.BuildBackgroundProteomeDlg_AddFastaFile_An_error_occurred_attempting_to_add_the_FASTA_file__0__,
                                                                      fastaFilePath), x.Message);
                    MessageDlg.ShowWithException(this, message, x);
                    return;
                }
            }

            string path = Path.GetFileName(fastaFilePath);

            if (path != null)
            {
                listboxFasta.Items.Add(path);
            }
            RefreshStatus();

            if (duplicateSequenceCount > 0)
            {
                MessageDlg.Show(this, string.Format(Resources.BuildBackgroundProteomeDlg_AddFastaFile_The_added_file_included__0__repeated_protein_sequences__Their_names_were_added_as_aliases_to_ensure_the_protein_list_contains_only_one_copy_of_each_sequence_, duplicateSequenceCount));
            }
        }
示例#19
0
 private bool ValidateRow(object[] columns, IWin32Window parent, int lineNumber)
 {
     try
     {
         // Create and validate isolation window.
         CreateEditIsolationWindow(columns, lineNumber);
     }
     catch (Exception x)
     {
         MessageDlg.ShowWithException(parent,
                                      string.Format(Resources.GridViewDriver_ValidateRow_On_line__0__1__, lineNumber, x.Message), x);
         return(false);
     }
     return(true);
 }
示例#20
0
 // find matches using a FASTA file
 // needed for Testing purposes so we can skip ImportFasta() because of the OpenFileDialog
 public void UseFastaFile(string file)
 {
     checkBoxListMatches.Items.Clear();
     try
     {
         using (var stream = File.Open(file, FileMode.Open))
         {
             FindProteinMatchesWithFasta(stream);
         }
     }
     catch (IOException e)
     {
         MessageDlg.ShowWithException(this, Resources.AssociateProteinsDlg_UseFastaFile_There_was_an_error_reading_from_the_file_, e);
     }
 }
示例#21
0
        public void ShowExportSpectralLibraryDialog(Control owner)
        {
            if (Document.MoleculeTransitionGroupCount == 0)
            {
                MessageDlg.Show(owner, Resources.SkylineWindow_ShowExportSpectralLibraryDialog_The_document_must_contain_at_least_one_peptide_precursor_to_export_a_spectral_library_);
                return;
            }
            else if (!Document.Settings.HasResults)
            {
                MessageDlg.Show(owner, Resources.SkylineWindow_ShowExportSpectralLibraryDialog_The_document_must_contain_results_to_export_a_spectral_library_);
                return;
            }

            using (var dlg = new SaveFileDialog
            {
                Title = Resources.SkylineWindow_ShowExportSpectralLibraryDialog_Export_Spectral_Library,
                OverwritePrompt = true,
                DefaultExt = BiblioSpecLiteSpec.EXT,
                Filter = TextUtil.FileDialogFiltersAll(BiblioSpecLiteSpec.FILTER_BLIB)
            })
            {
                if (!string.IsNullOrEmpty(DocumentFilePath))
                {
                    dlg.InitialDirectory = Path.GetDirectoryName(DocumentFilePath);
                }

                if (dlg.ShowDialog(owner) == DialogResult.Cancel)
                {
                    return;
                }

                try
                {
                    using (var longWaitDlg = new LongWaitDlg
                    {
                        Text = Resources.SkylineWindow_ShowExportSpectralLibraryDialog_Export_Spectral_Library,
                        Message = string.Format(Resources.SkylineWindow_ShowExportSpectralLibraryDialog_Exporting_spectral_library__0____, Path.GetFileName(dlg.FileName))
                    })
                    {
                        longWaitDlg.PerformWork(owner, 800, monitor => ExportSpectralLibrary(dlg.FileName, monitor));
                    }
                }
                catch (Exception x)
                {
                    MessageDlg.ShowWithException(owner, TextUtil.LineSeparate(string.Format(Resources.SkylineWindow_ShowExportSpectralLibraryDialog_Failed_exporting_spectral_library_to__0__, dlg.FileName), x.Message), x);
                }
            }
        }
示例#22
0
 public void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     Program.MainWindow.BeginInvoke(new Action(() =>
     {
         if (e.Error != null)
         {
             MessageDlg.ShowWithException(Program.MainWindow, string.Format(Resources.ActionTutorial_DownloadTutorials_Error__0_, e.Error), e.Error);
         }
         else if (string.IsNullOrEmpty(SkyFileLocationInZip))
         {
             MessageDlg.Show(Program.MainWindow,
                             string.Format(Resources.ActionTutorial_client_DownloadFileCompleted_File_saved_at___0_, getTempPath()));
             Process.Start(PdfFileLocation); // Opens Tutorial PDF in users default browser.
         }
     }));
 }
示例#23
0
        public void AddFastaFile(string fastaFilePath)
        {
            String databasePath = textPath.Text;

            Settings.Default.FastaDirectory = Path.GetDirectoryName(fastaFilePath);
            using (var longWaitDlg = new LongWaitDlg {
                ProgressValue = 0
            })
            {
                var progressMonitor = new ProgressMonitor(longWaitDlg);
                try
                {
                    longWaitDlg.PerformWork(this, 0, () =>
                    {
                        ProteomeDb proteomeDb = File.Exists(databasePath)
                            ? ProteomeDb.OpenProteomeDb(databasePath)
                            : ProteomeDb.CreateProteomeDb(databasePath);
                        using (proteomeDb)
                        {
                            using (var reader = File.OpenText(fastaFilePath))
                            {
                                proteomeDb.AddFastaFile(reader, progressMonitor.UpdateProgress);
                            }
                        }
                    });
                }
                catch (Exception x)
                {
                    var message = TextUtil.LineSeparate(string.Format(Resources.BuildBackgroundProteomeDlg_AddFastaFile_An_error_occurred_attempting_to_add_the_FASTA_file__0__,
                                                                      fastaFilePath), x.Message);
                    MessageDlg.ShowWithException(this, message, x);
                    return;
                }
            }

            string path = Path.GetFileName(fastaFilePath);

            if (path != null)
            {
                listboxFasta.Items.Add(path);
            }
            RefreshStatus();
        }
示例#24
0
 public void SetFastaContent(string fastaFilePath)
 {
     try
     {
         var fileInfo = new FileInfo(fastaFilePath);
         if (fileInfo.Length > MAX_FASTA_TEXTBOX_LENGTH)
         {
             _fastaFile    = true;
             tbxFasta.Text = fastaFilePath;
         }
         else
         {
             _fastaFile    = false;
             tbxFasta.Text = GetFastaFileContent(fastaFilePath);
         }
     }
     catch (Exception x)
     {
         MessageDlg.ShowWithException(WizardForm, TextUtil.LineSeparate(string.Format(Resources.ImportFastaControl_SetFastaContent_Error_adding_FASTA_file__0__, fastaFilePath), x.Message), x);
     }
 }
示例#25
0
 public bool ExportToFile(Control owner, ViewInfo viewInfo, string fileName, DsvWriter dsvWriter)
 {
     try
     {
         return(SafeWriteToFile(owner, fileName, stream =>
         {
             bool success = false;
             using (
                 var longWait = new LongWaitDlg
             {
                 Text = Resources.ExportReportDlg_ExportReport_Generating_Report
             })
             {
                 var action = new Action <IProgressMonitor>(broker =>
                 {
                     IProgressStatus status = new ProgressStatus(Resources.ExportReportDlg_ExportReport_Building_report);
                     broker.UpdateProgress(status);
                     using (var writer = new StreamWriter(stream))
                     {
                         success = Export(broker, ref status, viewInfo, writer, dsvWriter);
                         writer.Close();
                     }
                     if (success)
                     {
                         broker.UpdateProgress(status.Complete());
                     }
                 });
                 longWait.PerformWork(owner, 1500, action);
             }
             return success;
         }));
     }
     catch (Exception x)
     {
         Trace.TraceWarning("Error exporting to file: {0}", x); // Not L10N
         MessageDlg.ShowWithException(owner,
                                      string.Format(Resources.ExportReportDlg_ExportReport_Failed_exporting_to, fileName, x.Message), x);
         return(false);
     }
 }
示例#26
0
 public void AddDirectory(string dirPath)
 {
     using (var longWaitDlg = new LongWaitDlg
     {
         Text = Resources.BuildLibraryDlg_AddDirectory_Find_Input_Files,
     })
     {
         try
         {
             var inputFiles = new List <string>();
             longWaitDlg.PerformWork(this, 800, broker => FindInputFiles(dirPath, inputFiles, broker));
             AddInputFiles(inputFiles);
         }
         catch (Exception x)
         {
             var message = TextUtil.LineSeparate(string.Format(Resources.BuildLibraryDlg_AddDirectory_An_error_occurred_reading_files_in_the_directory__0__,
                                                               dirPath),
                                                 x.Message);
             MessageDlg.ShowWithException(this, message, x);
         }
     }
 }
示例#27
0
        private bool DoFillDown(ILongWaitBroker longWaitBroker, PropertyDescriptor[] propertyDescriptors, int firstRowIndex, int lastRowIndex)
        {
            bool anyChanges     = false;
            var  firstRowValues = propertyDescriptors.Select(pd => pd.GetValue(BindingListSource[firstRowIndex])).ToArray();
            int  totalRows      = lastRowIndex - firstRowIndex + 1;

            for (int iRow = firstRowIndex + 1; iRow <= lastRowIndex; iRow++)
            {
                if (longWaitBroker.IsCanceled)
                {
                    return(anyChanges);
                }
                longWaitBroker.ProgressValue = 100 * (iRow - firstRowIndex) / totalRows;
                longWaitBroker.Message       = string.Format(Resources.DataboundGridControl_DoFillDown_Filling__0___1__rows, iRow - firstRowIndex, totalRows);
                var row = BindingListSource[iRow];
                for (int icol = 0; icol < propertyDescriptors.Length; icol++)
                {
                    var propertyDescriptor = propertyDescriptors[icol];
                    try
                    {
                        propertyDescriptor.SetValue(row, firstRowValues[icol]);
                        anyChanges = true;
                    }
                    catch (Exception e)
                    {
                        MessageDlg.ShowWithException(this, TextUtil.LineSeparate(Resources.DataboundGridControl_DoFillDown_Error_setting_value_,
                                                                                 e.Message), e);
                        var column = DataGridView.Columns.OfType <DataGridViewColumn>()
                                     .FirstOrDefault(col => col.DataPropertyName == propertyDescriptor.Name);
                        if (null != column)
                        {
                            DataGridView.CurrentCell = DataGridView.Rows[iRow].Cells[column.Index];
                        }
                        return(anyChanges);
                    }
                }
            }
            return(anyChanges);
        }
示例#28
0
        private void ImportRangesFromFiles(MsDataFileUri[] dataSources)
        {
            try
            {
                IsolationScheme isolationScheme = null;
                using (var dlg = new LongWaitDlg
                {
                    Message = Resources.EditIsolationSchemeDlg_ImportRangesFromFiles_Reading_isolation_scheme___
                })
                {
                    var reader = new IsolationSchemeReader(dataSources);
                    dlg.PerformWork(this, 500, progressMonitor => isolationScheme = reader.Import("temp", progressMonitor)); // Not L10N
                }

                if (isolationScheme != null)
                {
                    cbSpecifyMargin.Checked     = isolationScheme.PrespecifiedIsolationWindows.Count(w => w.StartMargin.HasValue) > 1;
                    comboDeconvPre.SelectedItem = isolationScheme.SpecialHandling == IsolationScheme.SpecialHandlingType.OVERLAP_MULTIPLEXED
                        ? DeconvolutionMethod.OVERLAP
                        : DeconvolutionMethod.NONE;
                    _gridViewDriver.Items.Clear();
                    foreach (var isolationWindow in isolationScheme.PrespecifiedIsolationWindows)
                    {
                        _gridViewDriver.Items.Add(new EditIsolationWindow
                        {
                            Start       = isolationWindow.Start,
                            End         = isolationWindow.End,
                            StartMargin = isolationWindow.StartMargin
                        });
                    }
                }
            }
            catch (Exception x)
            {
                MessageDlg.ShowWithException(this, TextUtil.LineSeparate(Resources.EditIsolationSchemeDlg_ImportRangesFromFiles_Failed_reading_isolation_scheme_, x.Message), x);
            }
        }
示例#29
0
 public void LongWaitDlgAction(SkylineWindow skylineWindow)
 {
     skylineWindow.ResetDefaultSettings();
     try
     {
         using (var longWaitDlg = new LongWaitDlg
         {
             Text = Resources.ActionTutorial_LongWaitDlgAction_Downloading_Tutorial_Zip_File,
             Message =
                 String.Format(
                     Resources
                     .ActionTutorial_LongWaitDlgAction_Downloading_to___0__1_Tutorial_will_open_in_browser_when_download_is_complete_,
                     getTempPath(), Environment.NewLine),
             ProgressValue = 0
         })
         {
             longWaitDlg.PerformWork(skylineWindow, 1000, DownloadTutorials);
             if (longWaitDlg.IsCanceled)
             {
                 return;
             }
         }
         using (var longWaitDlg = new LongWaitDlg
         {
             Text =
                 Resources.ActionTutorial_LongWaitDlgAction_Extracting_Tutorial_Zip_File_in_the_same_directory_,
             ProgressValue = 0
         })
         {
             longWaitDlg.PerformWork(skylineWindow, 1000, ExtractTutorial);
         }
     }
     catch (Exception exception)
     {
         MessageDlg.ShowWithException(Program.MainWindow, string.Format(Resources.ActionTutorial_DownloadTutorials_Error__0_, exception.Message), exception);
     }
 }
示例#30
0
        private string GetFastaFileContent(string fastaFileName)
        {
            string fastaText = string.Empty;

            try
            {
                using (var readerFasta = new StreamReader(fastaFileName))
                {
                    var    sb = new StringBuilder();
                    string line;
                    while ((line = readerFasta.ReadLine()) != null)
                    {
                        sb.AppendLine(line);
                    }
                    fastaText = sb.ToString();
                }
            }
            catch (Exception x)
            {
                MessageDlg.ShowWithException(WizardForm, TextUtil.LineSeparate(string.Format(Resources.ImportFastaControl_GetFastaFileContent_Failed_reading_the_file__0__, fastaFileName), x.Message), x);
            }

            return(fastaText);
        }