Exemple #1
0
        private void AddFolderFileMenuItem_Click(object sender, RoutedEventArgs e)
        {
            var addFolderFileMenuItem = e.Source as MenuItem;

            if (addFolderFileMenuItem != null)
            {
                var formatInfo = FileDialogFormatInfoFactory.Create(addFolderFileMenuItem.Tag.ToString());

                var folderBrowser = new CommonOpenFileDialog();
                folderBrowser.IsFolderPicker = true;
                var result = folderBrowser.ShowDialog();
                var thing  = "";
                if (result == CommonFileDialogResult.Ok)
                {
                    thing = folderBrowser.FileName;
                }

                var filters = formatInfo.Filter.Split('|');
                if (thing != "")
                {
                    var directory = new DirectoryInfo(thing);
                    foreach (var filter in filters)
                    {
                        if (!filter.Contains("."))
                        {
                            continue;
                        }

                        filters = filter.Split(';');

                        foreach (var fileExt in filters)
                        {
                            foreach (var file in directory.GetFiles(fileExt, SearchOption.AllDirectories))
                            {
                                if (file.Name.EndsWith("msgfdb_syn.txt"))
                                {
                                    formatInfo.Format = LcmsIdentificationTool.MsgfPlus;
                                }
                                else if (file.Name.EndsWith("_syn.txt"))
                                {
                                    formatInfo.Format = LcmsIdentificationTool.Sequest;
                                }
                                else if (file.Name.EndsWith("_xt.txt"))
                                {
                                    formatInfo.Format = LcmsIdentificationTool.XTandem;
                                }
                                else if (file.Name.EndsWith("msalign_syn.txt"))
                                {
                                    formatInfo.Format = LcmsIdentificationTool.MSAlign;
                                }

                                AnalysisJobViewModel.AnalysisJobItems.Add(new AnalysisJobItem(file.FullName,
                                                                                              formatInfo.Format));

                                if (formatInfo.Format == LcmsIdentificationTool.MSAlign)
                                {
                                    AnalysisJobViewModel.Options.TargetFilterType = TargetWorkflowType.TOP_DOWN;
                                }
                            }
                        }
                    }
                }
            }
        }
Exemple #2
0
        private void AddFileMenuItem_Click(object sender, RoutedEventArgs e)
        {
            var addFileMenuItem = e.Source as MenuItem;

            if (addFileMenuItem != null)
            {
                var formatInfo = FileDialogFormatInfoFactory.Create(addFileMenuItem.Tag.ToString());

                var openFileDialog = new Microsoft.Win32.OpenFileDialog
                {
                    RestoreDirectory = true,

                    Multiselect = true,
                    Title       = formatInfo.Title,
                    Filter      = formatInfo.Filter
                };

                var dialogRes = openFileDialog.ShowDialog();

                if (dialogRes.HasValue && dialogRes.Value == true)
                {
                    if (formatInfo.Format != LcmsIdentificationTool.Description)
                    {
                        foreach (var fileName in openFileDialog.FileNames)
                        {
                            if (fileName.EndsWith("msgfdb_syn.txt"))
                            {
                                formatInfo.Format = LcmsIdentificationTool.MsgfPlus;
                            }
                            else if (fileName.EndsWith("_syn.txt"))
                            {
                                formatInfo.Format = LcmsIdentificationTool.Sequest;
                            }
                            else if (fileName.EndsWith("_xt.txt"))
                            {
                                formatInfo.Format = LcmsIdentificationTool.XTandem;
                            }
                            else if (fileName.EndsWith("msalign_syn.txt"))
                            {
                                formatInfo.Format = LcmsIdentificationTool.MSAlign;
                            }

                            AnalysisJobViewModel.AnalysisJobItems.Add(new AnalysisJobItem(fileName, formatInfo.Format));

                            if (formatInfo.Format == LcmsIdentificationTool.MSAlign)
                            {
                                AnalysisJobViewModel.Options.TargetFilterType = TargetWorkflowType.TOP_DOWN;
                            }
                        }
                    }
                    else
                    {
                        var analysisJobDescriptionReader = new AnalysisJobDescriptionReader();

                        foreach (var fileName in openFileDialog.FileNames)
                        {
                            try
                            {
                                foreach (var analysisJobItem in analysisJobDescriptionReader.Read(fileName))
                                {
                                    AnalysisJobViewModel.AnalysisJobItems.Add(analysisJobItem);
                                }
                            }
                            catch
                            {
                                MessageBox.Show(
                                    this, String.Format(
                                        "MTDB Creator cannot read this file.{0}This is not a valid Dataset Description file, or its format is not correct.{0}{0}{1}",
                                        Environment.NewLine, fileName), Application.Current.MainWindow.Tag.ToString(),
                                    MessageBoxButton.OK, MessageBoxImage.Warning);
                            }
                        }
                    }

                    MainListView.Focus();
                }
            }
        }