public void TestDataBindingSubList() { var boundDataGridView = new BoundDataGridView { BindingContext = new BindingContext(), DataSource = new BindingListSource(), }; using (boundDataGridView) { var columnIds = new[] { PropertyPath.Root, PropertyPath.Parse("Sequence"), PropertyPath.Parse("AminoAcidsList!*.Code"), PropertyPath.Parse("Molecule!*"), }; var viewSpec = new ViewSpec() .SetColumns(columnIds.Select(id => new ColumnSpec().SetPropertyPath(id))) .SetSublistId(PropertyPath.Parse("AminoAcidsList!*")); var viewInfo = new ViewInfo(new DataSchema(), typeof(LinkValue <Peptide>), viewSpec); // ReSharper disable once UseObjectOrCollectionInitializer var innerList = new BindingList <LinkValue <Peptide> >(); innerList.Add(new LinkValue <Peptide>(new Peptide("AD"), null)); ((BindingListSource)boundDataGridView.DataSource).SetViewContext(new TestViewContext(viewInfo.DataSchema, new[] { new RowSourceInfo(BindingListRowSource.Create(innerList), viewInfo) })); Assert.AreEqual(2, boundDataGridView.Rows.Count); innerList.Add(new LinkValue <Peptide>(new Peptide("TISE"), null)); Assert.AreEqual(6, boundDataGridView.Rows.Count); } }
public override ToolStripMenuItem CreateMenuItem(BoundDataGridView dataGridView) { var toolStripMenuItem = new ToolStripMenuItem(MenuItemText, null, (sender, args) => RemovePeaks(dataGridView)); if (!GetSelectedResults(dataGridView).Any()) { toolStripMenuItem.Enabled = false; } return(toolStripMenuItem); }
public override ToolStripMenuItem CreateMenuItem(BoundDataGridView dataGridView) { var menuItem = new ToolStripMenuItem(MenuItemText, null, (sender, args) => DeleteNodes(dataGridView)); if (!GetSelectedNodes(dataGridView).Any()) { menuItem.Enabled = false; } return(menuItem); }
public void RemovePeaks(SrmDocument.DOCUMENT_TYPE docType, BoundDataGridView dataGridView) { var parent = FormUtil.FindTopLevelOwner(dataGridView); var selectedPeaks = GetSelectedPeaks(dataGridView).Distinct().ToArray(); if (selectedPeaks.Length == 0) { MessageDlg.Show(parent, Resources.RemovePeaksAction_RemovePeaks_No_peaks_are_selected); return; } var lookup = selectedPeaks.ToLookup(tuple => tuple.Item1, tuple => tuple.Item2).ToArray(); string message = GetConfirmRemoveMessage(docType, selectedPeaks.Length, lookup.Length); if (MultiButtonMsgDlg.Show(parent, message, MultiButtonMsgDlg.BUTTON_OK) != DialogResult.OK) { return; } var skylineWindow = GetSkylineWindow(dataGridView); lock (skylineWindow.GetDocumentChangeLock()) { skylineWindow.ModifyDocument(Resources.RemovePeaksAction_RemovePeaks_Remove_peaks, doc => { var longOperationRunner = new LongOperationRunner { ParentControl = parent, JobTitle = Resources.RemovePeaksAction_RemovePeaks_Removing_Peaks }; SrmDocument resultDocument = doc; doc = doc.BeginDeferSettingsChanges(); longOperationRunner.Run(broker => { for (int iGroup = 0; iGroup < lookup.Length; iGroup++) { broker.ProgressValue = iGroup * 100 / lookup.Length; if (broker.IsCanceled) { return; } doc = RemovePeaks(doc, lookup[iGroup]); } resultDocument = doc.EndDeferSettingsChanges(resultDocument, null); }); return(resultDocument); }, docPair => AuditLogEntry.CreateSingleMessageEntry( new MessageInfo(MessageType.removed_peaks, docPair.NewDocumentType, selectedPeaks.Length, lookup.Length))); } }
public override IEnumerable <Result> GetSelectedResults(BoundDataGridView dataGridView) { var rowItemValues = RowItemValues.FromDataGridView(typeof(TransitionResult), dataGridView); foreach (var rowItem in rowItemValues.GetSelectedRowItems(dataGridView)) { foreach (var result in rowItemValues.GetRowValues(rowItem).Cast <Result>()) { yield return(result); } } }
public override IEnumerable <SkylineDocNode> GetSelectedNodes(BoundDataGridView dataGridView) { var rowItemValues = RowItemValues.FromDataGridView(typeof(Entities.Transition), dataGridView); foreach (var rowItem in rowItemValues.GetSelectedRowItems(dataGridView)) { foreach (var transition in rowItemValues.GetRowValues(rowItem).Cast <Entities.Transition>()) { yield return(transition); } } }
public IEnumerable <Tuple <IdentityPath, ResultFileKey> > GetSelectedPeaks(BoundDataGridView dataGridView) { foreach (var result in GetSelectedResults(dataGridView)) { if (result.IsEmpty()) { continue; } var resultFile = result.GetResultFile(); var resultFileKey = new ResultFileKey(resultFile.Replicate.ReplicateIndex, resultFile.ChromFileInfoId, 0); var tuple = Tuple.Create(result.GetSkylineDocNode().IdentityPath, resultFileKey); yield return(tuple); } }
public override IEnumerable <SkylineDocNode> GetSelectedNodes(BoundDataGridView dataGridView) { var rowItemValues = RowItemValues.FromDataGridView(typeof(Protein), dataGridView); foreach (var rowItem in rowItemValues.GetSelectedRowItems(dataGridView)) { foreach (var protein in rowItemValues.GetRowValues(rowItem).Cast <Protein>()) { yield return(protein); } } foreach (var peptide in Peptides.GetSelectedNodes(dataGridView)) { yield return(((Entities.Peptide)peptide).Protein); } }
public override IEnumerable <Result> GetSelectedResults(BoundDataGridView dataGridView) { var rowItemValues = RowItemValues.FromDataGridView(typeof(PeptideResult), dataGridView); foreach (var rowItem in rowItemValues.GetSelectedRowItems(dataGridView)) { foreach (var result in rowItemValues.GetRowValues(rowItem).Cast <Result>()) { yield return(result); } } foreach (var precursorResult in Precursors.GetSelectedResults(dataGridView)) { yield return(((PrecursorResult)precursorResult).PeptideResult); } }
public override IEnumerable <SkylineDocNode> GetSelectedNodes(BoundDataGridView dataGridView) { var rowItemValues = RowItemValues.FromDataGridView(typeof(Entities.Peptide), dataGridView); foreach (var rowItem in rowItemValues.GetSelectedRowItems(dataGridView)) { foreach (var precursor in rowItemValues.GetRowValues(rowItem).Cast <Entities.Peptide>()) { yield return(precursor); } } foreach (var precursor in Precursors.GetSelectedNodes(dataGridView)) { yield return(((Precursor)precursor).Peptide); } }
private HashSet <ListItemId> GetSelectedListItems(BoundDataGridView dataGridView) { var listIds = new HashSet <ListItemId>(); if (dataGridView == null) { return(listIds); } var bindingSource = dataGridView.DataSource as BindingListSource; if (bindingSource == null) { return(listIds); } var selectedRows = dataGridView.SelectedRows.Cast <DataGridViewRow>() .Where(row => !row.IsNewRow) .Select(row => (RowItem)bindingSource[row.Index]).ToArray(); if (!selectedRows.Any()) { selectedRows = new[] { bindingSource.Current as RowItem }; } foreach (var rowItem in selectedRows) { if (rowItem == null) { continue; } var listItem = rowItem.Value as ListItem; if (listItem == null) { continue; } var existingRecord = listItem.GetRecord() as ListItem.ExistingRecordData; if (null != existingRecord) { listIds.Add(existingRecord.ListItemId); } } return(listIds); }
private List <SkylineDocNode> GetSelectedDocNodes(BoundDataGridView dataGridView) { var docNodes = new List <SkylineDocNode>(); var identityPaths = new HashSet <IdentityPath>(); if (null == dataGridView) { return(docNodes); } var bindingSource = dataGridView.DataSource as BindingListSource; if (null == bindingSource) { return(docNodes); } var selectedRows = dataGridView.SelectedRows.Cast <DataGridViewRow>() .Select(row => (RowItem)bindingSource[row.Index]).ToArray(); if (!selectedRows.Any()) { selectedRows = new[] { bindingSource.Current as RowItem }; } foreach (var rowItem in selectedRows) { if (rowItem == null) { continue; } var docNode = rowItem.Value as SkylineDocNode; if (docNode == null) { continue; } if (identityPaths.Add(docNode.IdentityPath)) { docNodes.Add(docNode); } } return(docNodes); }
private IEnumerable <SkylineDocNode> GetSelectedDocNodes(BoundDataGridView dataGridView) { if (null == dataGridView) { return(new SkylineDocNode[0]); } var bindingSource = dataGridView.DataSource as BindingListSource; if (null == bindingSource) { return(new SkylineDocNode[0]); } var selectedRows = dataGridView.SelectedRows.Cast <DataGridViewRow>() .Select(row => (RowItem)bindingSource[row.Index]).ToArray(); if (!selectedRows.Any() && bindingSource.Current is RowItem rowItem) { selectedRows = new[] { rowItem }; } return(selectedRows.Select(row => row.Value).OfType <SkylineDocNode>()); }
public static void DeleteSkylineDocNodes(SkylineWindow skylineWindow, BoundDataGridView dataGridView, IEnumerable <SkylineDocNode> docNodesToDelete) { var docNodes = (ICollection <SkylineDocNode>)DistinctNodes(docNodesToDelete).ToList(); if (docNodes.Count == 0) { return; } var owner = FormUtil.FindTopLevelOwner(dataGridView); var confirmationMessages = docNodes.Select(node => node.GetDeleteConfirmation(docNodes.Count)).Distinct() .ToArray(); string message = confirmationMessages.Length == 1 ? confirmationMessages[0] : SkylineDocNode.GetGenericDeleteConfirmation(docNodes.Count); if (MultiButtonMsgDlg.Show(owner, message, MultiButtonMsgDlg.BUTTON_OK) != DialogResult.OK) { return; } DeleteDocNodes(skylineWindow, new HashSet <IdentityPath>(docNodes.Select(node => node.IdentityPath))); }
/// <summary> /// Called just before the selection has changed in Skyline, and the LiveResultsGrid is going /// to be displaying a different view, this method saves the current widths of the columns. /// </summary> public void RememberColumnWidths(BoundDataGridView boundDataGridView) { var bindingListSource = boundDataGridView.DataSource as BindingListSource; if (null == bindingListSource || !bindingListSource.IsComplete) { return; } string gridColumnsKey = GetGridColumnsKey(bindingListSource.ViewInfo); if (null == gridColumnsKey) { return; } var itemProperties = bindingListSource.GetItemProperties(null); var gridColumnList = new List <GridColumn>(); var propertyPaths = new HashSet <PropertyPath>(); foreach (DataGridViewColumn column in boundDataGridView.Columns) { var columnPropertyDescriptor = itemProperties.Find(column.DataPropertyName, false) as ColumnPropertyDescriptor; if (null == columnPropertyDescriptor) { continue; } if (!propertyPaths.Add(columnPropertyDescriptor.PropertyPath)) { continue; } gridColumnList.Add(new GridColumn(GetPersistedColumnName(columnPropertyDescriptor.PropertyPath), true, column.Width)); } var allGridColumnLists = Properties.Settings.Default.GridColumnsList; allGridColumnLists.Add(new GridColumns(gridColumnsKey, gridColumnList)); Properties.Settings.Default.GridColumnsList = allGridColumnLists; }
protected void DoResultsGridView() { // Results Grid View RestoreViewOnScreen(25); PauseForScreenShot <LiveResultsGrid>("Take full screen capture of floating windows", 25); RestoreViewOnScreen(26); PauseForScreenShot("Main window layout", 26); // Not understood: WaitForOpenForm occasionally hangs in nightly test runs. Fixed it by calling // ShowDialog when LiveResultsGrid cannot be found. //var resultsGridForm = WaitForOpenForm<LiveResultsGrid>(); var resultsGridForm = FindOpenForm <LiveResultsGrid>() ?? ShowDialog <LiveResultsGrid>(() => SkylineWindow.ShowResultsGrid(true)); BoundDataGridView resultsGrid = null; RunUI(() => { resultsGrid = resultsGridForm.DataGridView; SkylineWindow.AutoZoomBestPeak(); SkylineWindow.SelectedPath = ((SrmTreeNode)SkylineWindow.SequenceTree.SelectedNode.Nodes[0]).Path; }); WaitForGraphs(); RunUI(() => { var precursorNoteColumn = resultsGrid.Columns.Cast <DataGridViewColumn>() .First(col => GetLocalizedCaption("PrecursorReplicateNote") == col.HeaderText); resultsGrid.CurrentCell = resultsGrid.Rows[0].Cells[precursorNoteColumn.Index]; resultsGrid.BeginEdit(true); // ReSharper disable LocalizableElement resultsGrid.EditingControl.Text = "Low signal"; // Not L10N // ReSharper restore LocalizableElement resultsGrid.EndEdit(); resultsGrid.CurrentCell = resultsGrid.Rows[1].Cells[resultsGrid.CurrentCell.ColumnIndex]; }); WaitForGraphs(); RunUI(() => SkylineWindow.SelectedResultsIndex = 1); WaitForGraphs(); PauseForScreenShot("Results Grid view subsection", 27); RunDlg <ViewEditor>(resultsGridForm.NavBar.CustomizeView, resultsGridViewEditor => { // TODO: Update tutorial instructions with new name. resultsGridViewEditor.ViewName = "NewResultsGridView"; var chooseColumnTab = resultsGridViewEditor.ChooseColumnsTab; foreach ( var column in new[] { PropertyPath.Parse("MinStartTime"), PropertyPath.Parse("MaxEndTime"), PropertyPath.Parse("LibraryDotProduct"), PropertyPath.Parse("TotalBackground"), PropertyPath.Parse("TotalAreaRatio") }) { Assert.IsTrue(chooseColumnTab.ColumnNames.Contains(GetLocalizedCaption(column.Name))); Assert.IsTrue(chooseColumnTab.TrySelect(column), "Unable to select {0}", column); chooseColumnTab.RemoveColumn(column); Assert.IsFalse(chooseColumnTab.ColumnNames.Contains(GetLocalizedCaption(column.Name))); } resultsGridViewEditor.OkDialog(); }); RunUI(() => SkylineWindow.SelectedNode.Expand()); // Custom Annotations, p. 25 var chooseAnnotationsDlg = ShowDialog <DocumentSettingsDlg>(SkylineWindow.ShowDocumentSettingsDialog); var editListDlg = ShowDialog <EditListDlg <SettingsListBase <AnnotationDef>, AnnotationDef> >(chooseAnnotationsDlg.EditAnnotationList); var defineAnnotationDlg = ShowDialog <DefineAnnotationDlg>(editListDlg.AddItem); RunUI(() => { defineAnnotationDlg.AnnotationName = "Tailing"; // Not L10N defineAnnotationDlg.AnnotationType = AnnotationDef.AnnotationType.true_false; defineAnnotationDlg.AnnotationTargets = AnnotationDef.AnnotationTargetSet.Singleton(AnnotationDef.AnnotationTarget.precursor_result); }); PauseForScreenShot <DefineAnnotationDlg>("Define Annotation form", 28); OkDialog(defineAnnotationDlg, defineAnnotationDlg.OkDialog); OkDialog(editListDlg, editListDlg.OkDialog); RunUI(() => chooseAnnotationsDlg.AnnotationsCheckedListBox.SetItemChecked(0, true)); PauseForScreenShot <DocumentSettingsDlg>("Annotation Settings form", 29); // p. 26 OkDialog(chooseAnnotationsDlg, chooseAnnotationsDlg.OkDialog); FindNode((564.7746).ToString(LocalizationHelper.CurrentCulture) + "++"); var liveResultsGrid = FindOpenForm <LiveResultsGrid>(); ViewEditor viewEditor = ShowDialog <ViewEditor>(liveResultsGrid.NavBar.CustomizeView); RunUI(() => { viewEditor.ChooseColumnsTab.ActivateColumn(2); Assert.IsTrue(viewEditor.ChooseColumnsTab.TrySelect( PropertyPath.Root.Property(AnnotationDef.ANNOTATION_PREFIX + "Tailing"))); viewEditor.ChooseColumnsTab.AddSelectedColumn(); }); PauseForScreenShot <ViewEditor.ChooseColumnsView>("Customize View form showing Tailing annotation checked", 30); OkDialog(viewEditor, viewEditor.OkDialog); PauseForScreenShot("Main window with Tailing column added to Results Grid"); // p. 27 }
public override ToolStripMenuItem CreateMenuItem(SrmDocument.DOCUMENT_TYPE docType, BoundDataGridView dataGridView) { var toolStripMenuItem = new ToolStripMenuItem(GetMenuItemText(docType), null, (sender, args) => RemovePeaks(docType, dataGridView)); if (!GetSelectedResults(dataGridView).Any()) { toolStripMenuItem.Enabled = false; } return(toolStripMenuItem); }
public abstract ToolStripMenuItem CreateMenuItem(SrmDocument.DOCUMENT_TYPE documentType, BoundDataGridView dataGridView);
public abstract IEnumerable <Result> GetSelectedResults(BoundDataGridView dataGridView);
protected SkylineWindow GetSkylineWindow(BoundDataGridView dataGridView) { return(((SkylineDataSchema)((BindingListSource)dataGridView.DataSource).ViewContext.DataSchema).SkylineWindow); }
/// <summary> /// Attaches a DataGridViewPasteHandler to the specified DataGridView. /// </summary> public static DataGridViewPasteHandler Attach(BoundDataGridView boundDataGridView) { return(new DataGridViewPasteHandler(boundDataGridView)); }
private DataGridViewPasteHandler(BoundDataGridView boundDataGridView) { DataGridView = boundDataGridView; DataGridView.KeyDown += DataGridViewOnKeyDown; }
protected void DeleteNodes(BoundDataGridView dataGridView) { DeleteSkylineDocNodes(GetSkylineWindow(dataGridView), dataGridView, GetSelectedNodes(dataGridView)); }
public override ToolStripMenuItem CreateMenuItem(SrmDocument.DOCUMENT_TYPE docType, BoundDataGridView dataGridView) { var menuItem = new ToolStripMenuItem(GetMenuItemText(docType), null, (sender, args) => DeleteNodes(dataGridView)); if (!GetSelectedNodes(dataGridView).Any()) { menuItem.Enabled = false; } return(menuItem); }
public abstract IEnumerable <SkylineDocNode> GetSelectedNodes(BoundDataGridView dataGridView);
public abstract ToolStripMenuItem CreateMenuItem(BoundDataGridView dataGridView);
protected void DeleteSkylineDocNodes(BoundDataGridView dataGridView, IEnumerable <SkylineDocNode> docNodes) { DeleteNodesAction.DeleteSkylineDocNodes(SkylineDataSchema.SkylineWindow, dataGridView, docNodes); }