private ToolStripMenuItem MakeLayoutMenuItem(ViewLayout viewLayout) { return(new ToolStripMenuItem(viewLayout.Name, null, (sender, args) => { BindingListSource.ApplyLayout(viewLayout); })); }
protected override void OnDataBindingComplete(DataGridViewBindingCompleteEventArgs e) { var bindingListSource = DataSource as BindingListSource; var newViewContext = bindingListSource == null ? null : bindingListSource.ViewContext; if (!ReferenceEquals(_viewContext, newViewContext)) { if (_viewContext != null) { DataError -= _viewContext.OnDataError; } _viewContext = newViewContext; if (_viewContext != null) { DataError += _viewContext.OnDataError; } } if (!ReferenceEquals(_bindingListSource, bindingListSource)) { if (_bindingListSource != null) { _bindingListSource.AllRowsChanged -= BindingListSourceOnAllRowsChanged; _bindingListSource.ColumnFormats.FormatsChanged -= OnFormatsChanged; } _bindingListSource = bindingListSource; if (_bindingListSource != null) { _bindingListSource.AllRowsChanged += BindingListSourceOnAllRowsChanged; _bindingListSource.ColumnFormats.FormatsChanged += OnFormatsChanged; } } UpdateColumns(); base.OnDataBindingComplete(e); }
public void ApplyView(ViewGroup viewGroup, ViewSpec viewSpec) { var viewInfo = ViewContext.GetViewInfo(viewGroup, viewSpec); BindingListSource.SetViewContext(ViewContext, viewInfo); RefreshUi(); }
public void TestDataBindingIsSulfur() { var dataSchema = new DataSchema(); var viewSpec = new ViewSpec().SetColumns(new[] {new ColumnSpec(PropertyPath.Parse("Code")), new ColumnSpec(PropertyPath.Parse("Molecule!*.Key")),}) .SetFilters(new[] {new FilterSpec(PropertyPath.Parse("Molecule!*.Key"), FilterOperations.OP_EQUALS, "S")}); var bindingListSource = new BindingListSource(); bindingListSource.SetView(new ViewInfo(dataSchema, typeof(AminoAcid), viewSpec), AminoAcid.AMINO_ACIDS); Assert.AreEqual(2, bindingListSource.Count); }
void OnCopyView(object sender, EventArgs eventArgs) { var viewGroup = BindingListSource.ViewInfo.ViewGroup; if (Equals(ViewGroup.BUILT_IN, viewGroup)) { viewGroup = ViewContext.DefaultViewGroup; } var newView = ViewContext.CustomizeView(this, BindingListSource.ViewSpec.SetName(null), viewGroup); if (newView == null) { return; } BindingListSource.SetViewContext(ViewContext, ViewContext.GetViewInfo(viewGroup, newView)); }
public void CustomizeView() { var viewGroup = BindingListSource.ViewInfo.ViewGroup; var viewSpec = BindingListSource.ViewSpec; if (Equals(viewGroup, ViewGroup.BUILT_IN)) { viewSpec = viewSpec.SetName(string.Empty); viewGroup = ViewContext.DefaultViewGroup; } var newView = ViewContext.CustomizeView(this, viewSpec, viewGroup); if (newView == null) { return; } BindingListSource.SetViewContext(ViewContext, ViewContext.GetViewInfo(viewGroup, newView)); }
public void TestDataBindingIsNotNullFilter() { var dataSchema = new DataSchema(); var viewSpec = new ViewSpec().SetColumns(new[] {new ColumnSpec(PropertyPath.Parse("AminoAcidsDict!*.Value")),}) .SetSublistId(PropertyPath.Parse("AminoAcidsDict!*")); var viewSpecWithFilter = viewSpec.SetFilters(new[] { new FilterSpec(PropertyPath.Parse("AminoAcidsDict!*.Value"), FilterOperations.OP_IS_NOT_BLANK, null), }); var bindingListSource = new BindingListSource(); var bindingListSourceWithFilter = new BindingListSource(); bindingListSource.SetView(new ViewInfo(dataSchema, typeof(Peptide), viewSpec), null); bindingListSourceWithFilter.SetView(new ViewInfo(dataSchema, typeof(Peptide), viewSpecWithFilter), new[] {new Peptide("")}); Assert.AreEqual(0, bindingListSourceWithFilter.Count); bindingListSource.RowSource = bindingListSourceWithFilter.RowSource; Assert.AreEqual(1, bindingListSource.Count); }
public static void ShowPivotEditor(Control owner, BindingListSource bindingListSource, bool alwaysAddNewLevel) { var viewContext = bindingListSource.ViewContext; using (var groupingTotalForm = new PivotEditor(viewContext)) { var transformResults = bindingListSource.BindingListView.QueryResults.TransformResults; var currentPivotSpec = alwaysAddNewLevel ? null : transformResults.RowTransform as PivotSpec; IList <DataPropertyDescriptor> allProperties; if (currentPivotSpec == null) { allProperties = transformResults.PivotedRows.ItemProperties; groupingTotalForm.PivotSpec = PivotSpec.EMPTY; } else { groupingTotalForm.PivotSpec = currentPivotSpec; allProperties = transformResults.Parent.PivotedRows.ItemProperties; } if (allProperties.Count > MAX_COLUMN_COUNT) { string message = string.Format(Resources.PivotingForm_ShowPivotingForm_The_Pivot_Editor_cannot_be_shown_because_there_are_more_than__0__columns_, MAX_COLUMN_COUNT); viewContext.ShowMessageBox(owner, message, MessageBoxButtons.OK); return; } groupingTotalForm.AllProperties = allProperties; if (groupingTotalForm.ShowDialog(owner) == DialogResult.OK) { if (currentPivotSpec == null) { bindingListSource.BindingListView.TransformStack = bindingListSource.BindingListView.TransformStack.PushTransform(groupingTotalForm.PivotSpec); } else { bindingListSource.BindingListView.TransformStack = bindingListSource.BindingListView.TransformStack.Predecessor.PushTransform(groupingTotalForm.PivotSpec); } } } }
protected override void OnShown(EventArgs e) { base.OnShown(e); if (null != FoldChangeBindingSource) { _bindingListSource = FoldChangeBindingSource.GetBindingListSource(); _bindingListSource.ListChanged += BindingListSourceOnListChanged; if (_skylineWindow == null) { _skylineWindow = ((SkylineDataSchema) _bindingListSource.ViewInfo.DataSchema).SkylineWindow; if (_skylineWindow != null) { _skylineWindow.SequenceTree.AfterSelect += SequenceTreeOnAfterSelect; } } UpdateGraph(); } }
private void bindingNavigatorAddNewItem_Click(object sender, EventArgs e) { BindingListSource.AddNew(); }
public void TestMapping() { var settings = SrmSettingsList.GetDefault(); var document = new SrmDocument(settings); var documentContainer = new MemoryDocumentContainer(); documentContainer.SetDocument(document, null); using (var database = new Database(settings)) { var dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT); var sessionFactory = database.SessionFactory; foreach (var classMetaData in sessionFactory.GetAllClassMetadata().Values) { var tableType = classMetaData.GetMappedClass(EntityMode.Poco); foreach (var propertyName in classMetaData.PropertyNames) { if (propertyName == "Protein" && tableType == typeof (DbProteinResult)) { continue; } var queryDef = new QueryDef { Select = new[] {new ReportColumn(tableType, propertyName),} }; var reportSpec = new ReportSpec("test", queryDef); var newTableType = ReportSpecConverter.GetNewTableType(reportSpec); Assert.IsNotNull(newTableType, "No table for type {0}", tableType); var converter = new ReportSpecConverter(dataSchema); var viewInfo = converter.Convert(reportSpec); Assert.IsNotNull(viewInfo, "Unable to convert property {0} in table {1}", propertyName, tableType); Assert.AreEqual(1, viewInfo.DisplayColumns.Count, "No conversion for property {0} in table {1}", propertyName, tableType); Assert.IsNotNull(viewInfo.DisplayColumns[0].ColumnDescriptor, "Column not found for property {0} in table {1}", propertyName, tableType); var report = Report.Load(reportSpec); var resultSet = report.Execute(database); var bindingListSource = new BindingListSource(); bindingListSource.SetViewContext(new SkylineViewContext(viewInfo.ParentColumn, Array.CreateInstance(viewInfo.ParentColumn.PropertyType, 0)), viewInfo); var properties = bindingListSource.GetItemProperties(null); var oldCaptions = resultSet.ColumnInfos.Select(columnInfo => columnInfo.Caption).ToArray(); var newCaptions = properties.Cast<PropertyDescriptor>().Select(pd=>pd.DisplayName).ToArray(); if (oldCaptions.Length != newCaptions.Length) { Console.Out.WriteLine(oldCaptions); } CollectionAssert.AreEqual(oldCaptions, newCaptions, "Caption mismatch on {0} in {1}", propertyName, tableType); for (int i = 0; i < resultSet.ColumnInfos.Count; i++) { var columnInfo = resultSet.ColumnInfos[i]; var formatAttribute = (FormatAttribute)properties[i].Attributes[typeof(FormatAttribute)]; string message = string.Format("Format problem on column converted from {0} in {1}", columnInfo.ReportColumn.Column, columnInfo.ReportColumn.Table); if (null == columnInfo.Format) { Assert.IsTrue(null == formatAttribute || null == formatAttribute.Format, message); } else { Assert.IsNotNull(formatAttribute, message); Assert.AreEqual(columnInfo.Format, formatAttribute.Format, message); } if (columnInfo.IsNumeric) { Assert.IsNotNull(formatAttribute, message); Assert.AreEqual(TextUtil.EXCEL_NA, formatAttribute.NullValue, message); } else { Assert.IsTrue(null == formatAttribute || null == formatAttribute.NullValue, message); } } } } } }
public void CheckReport(ReportSpec reportSpec) { string message = string.Format("Report {0}", reportSpec.Name); var converter = new ReportSpecConverter(_dataSchema); var viewInfo = converter.Convert(reportSpec); var report = Report.Load(reportSpec); ResultSet resultSet; try { resultSet = report.Execute(_database); } catch (Exception) { return; } using (var bindingListSource = new BindingListSource()) { bindingListSource.SetViewContext(new SkylineViewContext(viewInfo.ParentColumn, GetRowSource(viewInfo)), viewInfo); var oldCaptions = resultSet.ColumnInfos.Select(columnInfo => columnInfo.Caption).ToArray(); var properties = bindingListSource.GetItemProperties(null); IList resultRows = bindingListSource; var newCaptions = properties.Cast<PropertyDescriptor>().Select(pd => pd.DisplayName).ToArray(); if (!oldCaptions.SequenceEqual(newCaptions)) { CollectionAssert.AreEqual(oldCaptions, newCaptions, message); } if (resultSet.RowCount != resultRows.Count) { Assert.AreEqual(resultSet.RowCount, resultRows.Count, message); } resultRows = SortRows(resultRows, properties); resultSet = SortResultSet(resultSet); for (int iRow = 0; iRow < resultSet.RowCount; iRow++) { for (int iCol = 0; iCol < resultSet.ColumnInfos.Count; iCol++) { var propertyDescriptor = properties[iCol]; object oldValue = resultSet.GetRow(iRow)[iCol]; object newValue = propertyDescriptor.GetValue(resultRows[iRow]); if (!Equals(oldValue, newValue)) { Assert.AreEqual(oldValue, newValue, message + "{0}:Values are not equal on Row {1} Column {2} ({3}) FullName:{4}", message, iRow, iCol, propertyDescriptor.DisplayName, propertyDescriptor.Name); } } } foreach (char separator in new[] { ',', '\t' }) { StringWriter oldStringWriter = new StringWriter(); var cultureInfo = LocalizationHelper.CurrentCulture; ResultSet.WriteReportHelper(resultSet, separator, oldStringWriter, cultureInfo); StringWriter newStringWriter = new StringWriter(); var skylineViewContext = (SkylineViewContext) bindingListSource.ViewContext; ProgressStatus progressStatus = new ProgressStatus("Status"); skylineViewContext.Export(null, ref progressStatus, viewInfo, newStringWriter, new DsvWriter(cultureInfo, separator)); var newLineSeparators = new[] { "\r\n" }; var oldLines = oldStringWriter.ToString().Split(newLineSeparators, StringSplitOptions.None); var newLines = newStringWriter.ToString().Split(newLineSeparators, StringSplitOptions.None); // TODO(nicksh): Old reports would hide columns for annotations that were not in the document. bool anyHiddenColumns = resultSet.ColumnInfos.Any(column => column.IsHidden); if (!anyHiddenColumns) { Assert.AreEqual(oldLines[0], newLines[0]); CollectionAssert.AreEquivalent(oldLines, newLines); } } } }
public void TestPivotResultsThenIsotopeLabel() { var assembly = typeof (LiveReportPivotTest).Assembly; XmlSerializer documentSerializer = new XmlSerializer(typeof(SrmDocument)); // ReSharper disable once AssignNullToNotNullAttribute var document = (SrmDocument)documentSerializer.Deserialize( assembly.GetManifestResourceStream(typeof(ReportSpecConverterTest), "silac_1_to_4.sky")); XmlSerializer reportSerializer = new XmlSerializer(typeof(ReportOrViewSpecList)); // ReSharper disable once AssignNullToNotNullAttribute var views = (ReportOrViewSpecList) reportSerializer.Deserialize( assembly.GetManifestResourceStream(typeof(ReportSpecConverterTest), "LiveReportPivots.skyr")); var view = views.First(reportSpec => reportSpec.Name == "ResultSummaryPivotResultsThenLabelType").ViewSpec; var bindingListSource = new BindingListSource(); var documentContainer = new MemoryDocumentContainer(); Assert.IsTrue(documentContainer.SetDocument(document, null)); var dataSchema = new SkylineDataSchema(documentContainer, DataSchemaLocalizer.INVARIANT); bindingListSource.SetViewContext(new DocumentGridViewContext(dataSchema), new ViewInfo(dataSchema, typeof(Precursor), view)); var expectedColumnNames = new[] { "PeptideSequence", "Chromatograms Replicate", "Chromatograms PeptideRetentionTime", "light IsotopeLabelType", "light MeanTotalArea", "light Chromatograms TotalArea", "heavy IsotopeLabelType", "heavy MeanTotalArea", "heavy Chromatograms TotalArea", }; var actualColumnNames = bindingListSource.GetItemProperties(null) .Cast<PropertyDescriptor>() .Select(pd => pd.DisplayName) .ToArray(); CollectionAssert.AreEqual(expectedColumnNames, actualColumnNames); }
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()); } }