private ViewLayoutList GetClusteredLayout() { var ppRunAbundances = PropertyPath.Root .Property(nameof(FoldChangeBindingSource.FoldChangeDetailRow.ReplicateAbundances)).DictionaryValues(); var roles = new List <Tuple <PropertyPath, ClusterRole> >(); roles.Add(Tuple.Create(PropertyPath.Root.Property(nameof(FoldChangeBindingSource.FoldChangeDetailRow.Protein)), ClusterRole.ROWHEADER)); roles.Add(Tuple.Create(PropertyPath.Root.Property(nameof(FoldChangeBindingSource.FoldChangeDetailRow.Peptide)), ClusterRole.ROWHEADER)); roles.Add(Tuple.Create( ppRunAbundances.Property(nameof(FoldChangeBindingSource.ReplicateRow.ReplicateSampleIdentity)), ClusterRole.COLUMNHEADER)); roles.Add(Tuple.Create( ppRunAbundances.Property(nameof(FoldChangeBindingSource.ReplicateRow.ReplicateGroup)), ClusterRole.COLUMNHEADER)); roles.Add(Tuple.Create(ppRunAbundances.Property(nameof(FoldChangeBindingSource.ReplicateRow.Abundance)), (ClusterRole)ClusterRole.ZSCORE)); var viewLayout = new ViewLayout(@"clustered").ChangeClusterSpec(new ClusteringSpec(roles.Select(role => new ClusteringSpec.ValueSpec(new ClusteringSpec.ColumnRef(role.Item1), role.Item2)))); var viewLayoutList = new ViewLayoutList(FoldChangeBindingSource.CLUSTERED_VIEW_NAME) .ChangeLayouts(new[] { viewLayout }) .ChangeDefaultLayoutName(viewLayout.Name); return(viewLayoutList); }
public void SetViewLayoutList(ViewGroupId viewGroup, ViewLayoutList list) { var viewSpecList = GetViewSpecList(viewGroup); viewSpecList = viewSpecList.SaveViewLayouts(list); SaveViewSpecList(viewGroup, viewSpecList); }
public void TestViewLayoutRowTransforms() { var dataSchema = new DataSchema(); var viewLayout = new ViewLayout("TestName").ChangeRowTransforms( new IRowTransform[] { new PivotSpec() .ChangeRowHeaders(new[] { new PivotSpec.Column(new ColumnId("RowHeaderOne")).ChangeCaption("MyCaption") }) .ChangeColumnHeaders(new[] { new PivotSpec.Column(new ColumnId("ColumnOne")), }) .ChangeValues(new[] { (PivotSpec.AggregateColumn) new PivotSpec.AggregateColumn(new ColumnId("ValueOne"), AggregateOperation.Cv).ChangeCaption("Aggregate column caption"), }), new RowFilter("filterText", true, new[] { new RowFilter.ColumnFilter(new ColumnId("column1"), FilterPredicate.CreateFilterPredicate(dataSchema, typeof(string), FilterOperations.OP_CONTAINS, "contains1")) }).SetColumnSorts(new[] { new RowFilter.ColumnSort(new ColumnId("columnSort1"), ListSortDirection.Ascending), new RowFilter.ColumnSort(new ColumnId("columnSort2"), ListSortDirection.Descending) }) } ).ChangeColumnFormats(new [] { Tuple.Create(new ColumnId("ColumnId1"), ColumnFormat.EMPTY.ChangeFormat("R").ChangeWidth(20)) }); var viewLayoutList = new ViewLayoutList("Test").ChangeLayouts(new [] { viewLayout }) .ChangeDefaultLayoutName("TestName"); var roundTrip = RoundTripToXml(viewLayoutList); Assert.AreEqual(viewLayoutList, roundTrip); }
public ViewSpecLayout ChangeName(string name) { return(ChangeProp(ImClone(this), im => { im.ViewSpec = ViewSpec.SetName(name); im.ViewLayoutList = ViewLayoutList.ChangeViewName(name); })); }
private void btnDelete_Click(object sender, System.EventArgs e) { var oldLayouts = ViewLayoutList.Layouts; var newLayouts = Enumerable.Range(0, oldLayouts.Count) .Except(listViewLayouts.SelectedIndices.Cast <int>()) .Select(index => oldLayouts[index]); ViewLayoutList = ViewLayoutList.ChangeLayouts(newLayouts); }
public ViewSpecList SaveViewLayouts(ViewLayoutList viewLayoutList) { IEnumerable <ViewLayoutList> newLayouts = ViewLayouts.Where(layout => layout.ViewName != viewLayoutList.ViewName); if (!viewLayoutList.IsEmpty) { newLayouts = new[] { viewLayoutList }.Concat(newLayouts); } return(new ViewSpecList(ViewSpecs, newLayouts)); }
public void ToggleDefault() { if (listViewLayouts.SelectedIndices.Count != 1) { return; } var viewLayout = ViewLayoutList.Layouts[listViewLayouts.SelectedIndices[0]]; ViewLayoutList = ViewLayoutList.ChangeDefaultLayoutName(IsDefault(viewLayout) ? null : viewLayout.Name); }
private static ViewLayoutList RoundTripToXml(ViewLayoutList viewLayoutList) { var viewSpecList = new ViewSpecList(new[] { new ViewSpec().SetName(viewLayoutList.ViewName) }); viewSpecList = viewSpecList.SaveViewLayouts(viewLayoutList); var xmlSerializer = new XmlSerializer(typeof(ViewSpecList)); var memoryStream = new MemoryStream(); xmlSerializer.Serialize(memoryStream, viewSpecList); memoryStream.Seek(0, SeekOrigin.Begin); var roundTripViewSpecList = (ViewSpecList)xmlSerializer.Deserialize(memoryStream); return(roundTripViewSpecList.GetViewLayouts(viewLayoutList.ViewName)); }
private static IEnumerable <ViewSpecLayout> MakeViewSpecLayouts(IEnumerable <ViewSpec> viewSpecs, IEnumerable <ViewLayoutList> viewLayouts) { Dictionary <string, ViewLayoutList> layoutsByName = viewLayouts?.ToDictionary(layout => layout.ViewName); foreach (var viewSpec in viewSpecs) { ViewLayoutList layouts = null; if (viewSpec.Name != null) { layoutsByName?.TryGetValue(viewSpec.Name, out layouts); } yield return(new ViewSpecLayout(viewSpec, layouts)); } }
protected override void SaveViewSpecList(ViewGroupId viewGroup, ViewSpecList viewSpecList) { Settings.Default.PersistedViews.SetViewSpecList(viewGroup, viewSpecList); if (Equals(viewGroup, PersistedViews.MainGroup.Id)) { ChangeDocumentViewSpecList(docViewSpecList => { var newViews = new Dictionary <string, ViewSpec>(); foreach (var viewSpec in viewSpecList.ViewSpecs) { newViews[viewSpec.Name] = viewSpec; } var newDocViews = new List <ViewSpec>(); var newLayouts = new List <ViewLayoutList>(); foreach (var oldDocView in docViewSpecList.ViewSpecs) { ViewSpec newDocView; if (newViews.TryGetValue(oldDocView.Name, out newDocView)) { newDocViews.Add(newDocView); ViewLayoutList viewLayoutList = viewSpecList.GetViewLayouts(oldDocView.Name); if (!viewLayoutList.IsEmpty) { newLayouts.Add(viewLayoutList); } } } return(new ViewSpecList(newDocViews, newLayouts)); }); var skylineWindow = SkylineDataSchema.SkylineWindow; if (skylineWindow != null) { skylineWindow.ModifyDocument(Resources.SkylineViewContext_SaveViewSpecList_Change_Document_Reports, doc => { var oldViewNames = new HashSet <string>( doc.Settings.DataSettings.ViewSpecList.ViewSpecs.Select(spec => spec.Name)); var newViewSpecList = viewSpecList.Filter(spec => oldViewNames.Contains(spec.Name)); if (Equals(newViewSpecList, doc.Settings.DataSettings.ViewSpecList)) { return(doc); } return(doc.ChangeSettings(doc.Settings.ChangeDataSettings( doc.Settings.DataSettings.ChangeViewSpecList(newViewSpecList)))); }, AuditLogEntry.SettingsLogFunction); } } }
private void ReadXml(XmlReader reader) { if (Views != null) { throw new ReadOnlyException(); } if (reader.IsEmptyElement) { ViewSpecLayouts = ImmutableList.Empty <ViewSpecLayout>(); reader.ReadElementString(@"views"); return; } reader.Read(); var viewItems = new List <ViewSpec>(); var layouts = new List <ViewLayoutList>(); while (true) { if (reader.IsStartElement(@"view")) { viewItems.Add(ViewSpec.ReadXml(reader)); } else if (reader.IsStartElement(@"layouts")) { layouts.Add(ViewLayoutList.ReadXml(reader)); } else if (reader.NodeType == XmlNodeType.EndElement) { reader.ReadEndElement(); break; } else { reader.Skip(); } } ViewSpecLayouts = ImmutableList.ValueOf(MakeViewSpecLayouts(viewItems, layouts)); }
public View(ViewSpec spec, ViewLayoutList layouts) { ViewSpec = spec; _layouts = layouts; }
private static ViewLayoutList EnsureName(ViewLayoutList layouts, string name) { layouts = layouts ?? ViewLayoutList.EMPTY; return(layouts.ViewName == name ? layouts : layouts.ChangeViewName(name)); }
public ViewSpecLayout(ViewSpec viewSpec, ViewLayoutList layouts) { ViewSpec = viewSpec; ViewLayoutList = EnsureName(layouts, viewSpec.Name); }
public override int GetHashCode() { unchecked { return(((ViewSpec != null ? ViewSpec.GetHashCode() : 0) * 397) ^ (ViewLayoutList != null ? ViewLayoutList.GetHashCode() : 0)); } }