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(innerList, viewInfo)})); Assert.AreEqual(2, boundDataGridView.Rows.Count); innerList.Add(new LinkValue<Peptide>(new Peptide("TISE"), null)); Assert.AreEqual(6, boundDataGridView.Rows.Count); } }
public DisplayColumn(ViewInfo viewInfo, ColumnSpec columnSpec, ColumnDescriptor columnDescriptor) { ViewInfo = viewInfo; ColumnDescriptor = columnDescriptor; ColumnSpec = columnSpec; CollectionColumn = columnDescriptor == null ? null : columnDescriptor.CollectionAncestor() ?? viewInfo.ParentColumn; }
private void EnsureViewRoundTrips(ViewInfo viewInfo) { IEnumerable<PropertyPath> emptyPropertyPaths = new PropertyPath[0]; ValidateViewInfo(viewInfo); var transformer = new DocumentViewTransformer(); var viewInfoDocument = transformer.MakeIntoDocumentView(viewInfo, ref emptyPropertyPaths); Assert.AreEqual(typeof(SkylineDocument), viewInfoDocument.ParentColumn.PropertyType); ValidateViewInfo(viewInfoDocument); var viewInfoRoundTrip = transformer.ConvertFromDocumentView(viewInfoDocument, ref emptyPropertyPaths); Assert.AreEqual(viewInfo.ParentColumn.PropertyType, viewInfoRoundTrip.ParentColumn.PropertyType); Assert.AreEqual(viewInfo.GetViewSpec(), viewInfoRoundTrip.GetViewSpec()); }
public override void Preview(Control owner, ViewInfo viewInfo) { string title; if (string.IsNullOrEmpty(viewInfo.Name)) { title = Resources.DocumentGridViewContext_Preview_Preview_New_Report; } else { title = string.Format(Resources.DocumentGridViewContext_Preview_Preview___0_, viewInfo.Name); } var dialog = new DocumentGridForm(this) { ViewInfo = viewInfo, ShowViewsMenu = false, Text = title, }; dialog.ShowDialog(owner); }
private void ValidateViewInfo(ViewInfo viewInfo) { foreach (var column in viewInfo.DisplayColumns) { Assert.AreNotEqual(typeof(object), column.PropertyType, column.PropertyPath.ToString()); } }
public virtual void Preview(Control owner, ViewInfo viewInfo) { }
protected virtual string GetDefaultExportFilename(ViewInfo viewInfo) { string currentViewName = viewInfo.Name; return(viewInfo.ParentColumn.PropertyType.Name + (currentViewName == GetDefaultViewName() ? string.Empty : currentViewName)); }
protected RowSourceInfo FindRowSourceInfo(ViewInfo viewInfo) { return(FindRowSourceInfo(viewInfo.ParentColumn.PropertyType)); }
public void AddRef() { if (Interlocked.Increment(ref _referenceCount) == 1) { _skylineDataSchema = new SkylineDataSchema(GroupComparisonModel.DocumentContainer, SkylineDataSchema.GetLocalizedSchemaLocalizer()); var viewInfo = new ViewInfo(_skylineDataSchema, typeof(FoldChangeRow), GetDefaultViewSpec(new FoldChangeRow[0])) .ChangeViewGroup(ViewGroup.BUILT_IN); var rowSourceInfo = new RowSourceInfo(typeof(FoldChangeRow), new FoldChangeRow[0], new[] { viewInfo }); ViewContext = new GroupComparisonViewContext(_skylineDataSchema, new[]{rowSourceInfo}); _container = new Container(); _bindingListSource = new BindingListSource(_container); _bindingListSource.SetViewContext(ViewContext, viewInfo); GroupComparisonModel.ModelChanged += GroupComparisonModelOnModelChanged; GroupComparisonModelOnModelChanged(GroupComparisonModel, new EventArgs()); } }
private void btnRequery_Click(object sender, EventArgs e) { var halfLifeCalculator = new HalfLifeCalculator(Workspace, HalfLifeSettings) { ByFile = cbxGroupByFile.Checked, }; using (var longWaitDialog = new LongWaitDialog(TopLevelControl, "Calculating Half Lives")) { var longOperationBroker = new LongOperationBroker(halfLifeCalculator.Run, longWaitDialog); if (!longOperationBroker.LaunchJob()) { return; } } bool byCohort = cbxGroupByCohort.Checked; bool byTimePoint = cbxGroupByTimePoint.Checked; bool bySample = cbxGroupBySample.Checked; bool byFile = cbxGroupByFile.Checked; var displayRows = new List<DisplayRow>(); foreach (var resultRow in halfLifeCalculator.ResultRows) { var displayRow = new DisplayRow(halfLifeCalculator, resultRow); var rowDatasByCohort = new Dictionary<GroupKey, List<HalfLifeCalculator.ProcessedRowData>>(); foreach (var halfLife in resultRow.HalfLives) { if (resultRow.HalfLives.Count > 1 && string.IsNullOrEmpty(halfLife.Key) != byCohort) { continue; } foreach (var rowData in halfLife.Value.FilteredRowDatas) { GroupKey cohortKey = new GroupKey( byCohort ? rowData.RawRowData.MsDataFile.Cohort : null, byTimePoint ? rowData.RawRowData.MsDataFile.TimePoint : null, bySample ? rowData.RawRowData.MsDataFile.Sample : null, byFile ? rowData.RawRowData.MsDataFile.Name : null); List<HalfLifeCalculator.ProcessedRowData> list; if (!rowDatasByCohort.TryGetValue(cohortKey, out list)) { list = new List<HalfLifeCalculator.ProcessedRowData>(); rowDatasByCohort.Add(cohortKey, list); } list.Add(rowData); } } foreach (var cohortRowDatas in rowDatasByCohort) { displayRow.Results.Add(cohortRowDatas.Key, new GroupResult(this, displayRow, cohortRowDatas.Key, new ResultData(cohortRowDatas.Value))); } displayRows.Add(displayRow); } var viewInfo = bindingSource1.ViewInfo; var dataSchema = new TopographDataSchema(Workspace); if (viewInfo == null || "default" == viewInfo.Name) { viewInfo= new ViewInfo(ColumnDescriptor.RootColumn(dataSchema, typeof(DisplayRow)), GetDefaultViewSpec(halfLifeCalculator.ByProtein)); } var viewContext = new TopographViewContext(Workspace, typeof (DisplayRow), displayRows, GetDefaultViewSpec(halfLifeCalculator.ByProtein)); bindingSource1.SetViewContext(viewContext, viewInfo); bindingSource1.RowSource = displayRows; dataGridViewSummary.Rows.Clear(); SetSummary("Tracer %", displayRows.Select(dr=>dr.Results).SelectMany(r=>r.Values .Select(cohortResult=>cohortResult.GetResultData().TracerPercentByArea))); SetSummary("Precursor Enrichment", displayRows.Select(dr=>dr.Results).SelectMany(r=>r.Values .Select(cohortResult=>cohortResult.GetResultData().IndPrecursorEnrichment))); SetSummary("Turnover", displayRows.Select(dr=>dr.Results).SelectMany(r=>r.Values .Select(cohortResult=>cohortResult.GetResultData().IndTurnover))); SetSummary("Area Under Curve", displayRows.Select(dr=>dr.Results).SelectMany(r=>r.Values .Select(cohortResult=>cohortResult.GetResultData().AreaUnderCurve))); }
public RowSourceInfo(IEnumerable rows, ViewInfo viewInfo) : this(viewInfo.ParentColumn.PropertyType, rows, new[] {viewInfo}) { }
public RowSourceInfo(IRowSource rows, ViewInfo viewInfo) : this(viewInfo.ParentColumn.PropertyType, rows, new[] { viewInfo }) { }
private ColumnDescriptor GetColumnDescriptor(DatabindingTableAttribute databindingTable, PropertyPath identifierPath) { identifierPath = PropertyPath.Parse(databindingTable.Property).Concat(identifierPath); var viewSpec = new ViewSpec().SetColumns(new[] { new ColumnSpec(identifierPath) }); var viewInfo = new ViewInfo(DataSchema, databindingTable.RootTable, viewSpec); return viewInfo.DisplayColumns.First().ColumnDescriptor; }
public KeyValuePair <ViewInfo, IEnumerable <PropertyPath> > UntransformView(ViewInfo view, IEnumerable <PropertyPath> propertyPaths) { return(new KeyValuePair <ViewInfo, IEnumerable <PropertyPath> >(view, propertyPaths)); }
public IEnumerable GetRowSource(ViewInfo viewInfo) { var type = viewInfo.ParentColumn.PropertyType; if (type == typeof (Protein)) { return new Proteins(_dataSchema); } if (type == typeof (Peptide)) { return new Peptides(_dataSchema, new[]{IdentityPath.ROOT}); } if (type == typeof (Precursor)) { return new Precursors(_dataSchema, new[]{IdentityPath.ROOT}); } if (type == typeof (Transition)) { return new Transitions(_dataSchema, new[]{IdentityPath.ROOT}); } throw new ArgumentException(string.Format("No row source for {0}", viewInfo.ParentColumn.PropertyType)); }
private void UpdateViewContext() { RememberActiveView(); IList rowSource = null; Type rowType = null; string builtInViewName = null; if (_selectedIdentityPaths.Count == 1) { var identityPath = _selectedIdentityPaths[0]; if (identityPath.Length == 2) { rowSource = new PeptideResultList(new Peptide(_dataSchema, identityPath)); rowType = typeof (PeptideResult); builtInViewName = "Peptide Results"; // Not L10N } else if (identityPath.Length == 3) { rowSource = new PrecursorResultList(new Precursor(_dataSchema, identityPath)); rowType = typeof (PrecursorResult); builtInViewName = "Precursor Results"; // Not L10N } else if (identityPath.Length == 4) { rowSource = new TransitionResultList(new Transition(_dataSchema, identityPath)); rowType = typeof (TransitionResult); builtInViewName = "Transition Results"; // Not L10N } } else { var pathLengths = _selectedIdentityPaths.Select(path => path.Length).Distinct().ToArray(); if (pathLengths.Length == 1) { var pathLength = pathLengths[0]; if (pathLength == 3) { rowSource = new MultiPrecursorResultList(_dataSchema, _selectedIdentityPaths.Select(idPath => new Precursor(_dataSchema, idPath))); rowType = typeof (MultiPrecursorResult); builtInViewName = "Multiple Precursor Results"; // Not L10N } if (pathLength == 4) { rowSource = new MultiTransitionResultList(_dataSchema, _selectedIdentityPaths.Select(idPath => new Transition(_dataSchema, idPath))); rowType = typeof (MultiTransitionResult); builtInViewName = "Multiple Transition Results"; // Not L10N } } } if (rowSource == null) { rowSource = new ReplicateList(_dataSchema); rowType = typeof (Replicate); builtInViewName = "Replicates"; // Not L10N } var parentColumn = ColumnDescriptor.RootColumn(_dataSchema, rowType); var builtInViewSpec = SkylineViewContext.GetDefaultViewInfo(parentColumn).GetViewSpec() .SetName(builtInViewName).SetRowType(rowType); if (null == BindingListSource.ViewContext || !BindingListSource.ViewContext.GetViewSpecList(ViewGroup.BUILT_IN.Id).ViewSpecs.Contains(builtInViewSpec)) { var oldViewContext = BindingListSource.ViewContext as ResultsGridViewContext; if (null != oldViewContext) { oldViewContext.RememberColumnWidths(DataGridView); } Debug.Assert(null != builtInViewName); var builtInView = new ViewInfo(parentColumn, builtInViewSpec).ChangeViewGroup(ViewGroup.BUILT_IN); var rowSourceInfo = new RowSourceInfo(rowSource, builtInView); var viewContext = new ResultsGridViewContext(_dataSchema, new[] {rowSourceInfo}); ViewInfo activeView = null; string activeViewName; if (Settings.Default.ResultsGridActiveViews.TryGetValue(rowSourceInfo.Name, out activeViewName)) { activeView = viewContext.GetViewInfo(ViewName.Parse(activeViewName)); } activeView = activeView ?? builtInView; BindingListSource.SetViewContext(viewContext, activeView); } BindingListSource.RowSource = rowSource; }
private void BtnRequeryOnClick(object sender, EventArgs e) { var halfLifeSettings = HalfLifeSettings; Settings.Default.Reload(); Settings.Default.HalfLifeSettings = halfLifeSettings; Settings.Default.Save(); var calculator = new HalfLifeCalculator(Workspace, halfLifeSettings) { ExcludedTimePoints = UpdateTimePoints(), }; using (var longWaitDialog = new LongWaitDialog(TopLevelControl, "Calculating Half Lives")) { var longOperationBroker = new LongOperationBroker(calculator.Run, longWaitDialog); if (!longOperationBroker.LaunchJob()) { return; } } var viewInfo = bindingSource1.ViewInfo; var rows = calculator.ResultRows.Select(row => new ResultRow(this, row)).ToArray(); if (viewInfo == null || "default" == viewInfo.Name) { viewInfo = new ViewInfo(ColumnDescriptor.RootColumn(bindingSource1.ViewInfo.DataSchema, typeof(ResultRow)), GetDefaultViewSpec(calculator.ByProtein)); bindingSource1.SetViewContext(GetViewContext(rows), viewInfo); } bindingSource1.RowSource = rows; }
public KeyValuePair<ViewInfo, IEnumerable<PropertyPath>> UntransformView(ViewInfo view, IEnumerable<PropertyPath> propertyPaths) { return new KeyValuePair<ViewInfo, IEnumerable<PropertyPath>>(view, propertyPaths); }
private void UpdateResults() { var results = GroupComparisonModel.Results; var rows = new List<FoldChangeRow>(); if (null != results) { var groupComparisonDef = results.GroupComparer.ComparisonDef; var adjustedPValues = PValues.AdjustPValues(results.ResultRows.Select( row => row.LinearFitResult.PValue)).ToArray(); for (int iRow = 0; iRow < results.ResultRows.Count; iRow++) { var resultRow = results.ResultRows[iRow]; var protein = new Protein(_skylineDataSchema, new IdentityPath(resultRow.Selector.Protein.Id)); Model.Databinding.Entities.Peptide peptide = null; if (null != resultRow.Selector.Peptide) { peptide = new Model.Databinding.Entities.Peptide(_skylineDataSchema, new IdentityPath(protein.IdentityPath, resultRow.Selector.Peptide.Id)); } rows.Add(new FoldChangeRow(protein, peptide, resultRow.Selector.LabelType, resultRow.Selector.MsLevel, resultRow.Selector.GroupIdentifier, resultRow.ReplicateCount, new FoldChangeResult(groupComparisonDef.ConfidenceLevel, adjustedPValues[iRow], resultRow.LinearFitResult))); } } var defaultViewSpec = GetDefaultViewSpec(rows); if (!Equals(defaultViewSpec, ViewContext.BuiltInViews.First())) { var viewInfo = new ViewInfo(_skylineDataSchema, typeof (FoldChangeRow), defaultViewSpec).ChangeViewGroup(ViewGroup.BUILT_IN); ViewContext.SetRowSources(new[] { new RowSourceInfo( rows, viewInfo) }); if (null != _bindingListSource.ViewSpec && _bindingListSource.ViewSpec.Name == defaultViewSpec.Name && !_bindingListSource.ViewSpec.Equals(defaultViewSpec)) { _bindingListSource.SetView(viewInfo, rows); } } _bindingListSource.RowSource = rows; }