private void AddDefaults() { if (RevisionIndex >= RevisionIndexCurrent) { return; } IList <KeyValuePair <ViewGroupId, ViewSpec> > previousDefaults = GetDefaults(RevisionIndex).ToArray(); IList <KeyValuePair <ViewGroupId, ViewSpec> > currentDefaults = GetDefaults(RevisionIndexCurrent).ToArray(); foreach (var keyValuePair in currentDefaults) { if (previousDefaults.Contains(keyValuePair)) { continue; } var viewGroup = keyValuePair.Key; var viewSpec = keyValuePair.Value; ViewSpecList viewSpecList = GetViewSpecList(viewGroup); var currentView = viewSpecList.ViewSpecs.FirstOrDefault(view => view.Name == viewSpec.Name); if (currentView == null || previousDefaults.Contains(new KeyValuePair <ViewGroupId, ViewSpec>(viewGroup, currentView))) { viewSpecList = viewSpecList.ReplaceView(viewSpec.Name, viewSpec); _viewSpecLists[viewGroup.Name] = viewSpecList; } } RevisionIndex = RevisionIndexCurrent; }
private ViewSpecList SortViewSpecList(ViewSpecList viewSpecList) { var viewSpecs = viewSpecList.ViewSpecs.ToArray(); var stringComparer = StringComparer.Create(SkylineDataSchema.DataSchemaLocalizer.FormatProvider, true); Array.Sort(viewSpecs, (v1, v2) => stringComparer.Compare(v1.Name, v2.Name)); return(new ViewSpecList(viewSpecs)); }
protected IEnumerable <ViewSpec> LoadViews(string filename) { using (var stream = File.OpenRead(filename)) { var viewSerializer = new XmlSerializer(typeof(ViewSpecList)); ViewSpecList viewSpecList = (ViewSpecList)viewSerializer.Deserialize(stream); return(viewSpecList.ViewSpecs); } }
public override void ExportViewsToFile(Control owner, ViewSpecList viewSpecList, string fileName) { XmlSerializer xmlSerializer = new XmlSerializer(typeof(ViewSpecList)); SafeWriteToFile(owner, fileName, stream => { xmlSerializer.Serialize(stream, viewSpecList); return(true); }); }
public override void ExportViewsToFile(Control owner, ViewSpecList views, string fileName) { var xmlSerializer = new XmlSerializer(typeof(ViewSpecList)); using (FileStream stream = File.OpenWrite(fileName)) { xmlSerializer.Serialize(stream, views); stream.Close(); } }
void IDocumentChangeListener.DocumentOnChanged(object sender, DocumentChangedEventArgs args) { var viewSpecList = _skylineDataSchema.Document.Settings.DataSettings.ViewSpecList; if (!Equals(viewSpecList, _documentViews)) { _documentViews = viewSpecList; FireChanged(); } }
public override ViewSpecList GetViewSpecList(ViewGroupId viewGroup) { ViewSpecList viewSpecList = base.GetViewSpecList(viewGroup); if (Equals(viewGroup, ViewGroup.BUILT_IN.Id)) { viewSpecList = new ViewSpecList(viewSpecList.ViewSpecs, GetBuiltInViewLayouts()); } return(viewSpecList); }
public override int GetHashCode() { unchecked { int result = _annotationDefs.GetHashCodeDeep(); result = result * 397 + _groupComparisonDefs.GetHashCodeDeep(); result = result * 397 + ViewSpecList.GetHashCode(); result = result * 397 + (PanoramaPublishUri == null ? 0 : PanoramaPublishUri.GetHashCode()); result = result * 397 + (DocumentGuid == null ? 0 : DocumentGuid.GetHashCode()); return(result); } }
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)); }
/// <summary> /// Reads reports from a stream. /// The list of reports might be in one of 3 formats. /// <see cref="ReportSpecList"/> if it is from a version of Skyline before 2.5 /// <see cref="ViewSpecList"/> if it was shared from "Manage Views" in the Document Grid in Skyline 2.5 /// (this was a mistake, it should have been a ReportOrViewSpecList). /// <see cref="ReportOrViewSpecList"/> if it was Shared from File>Export Report in Skyline 2.5 or greater. /// </summary> public static List <ReportOrViewSpec> DeserializeReportList(Stream stream) { XmlReader xmlReader = new XmlTextReader(stream); xmlReader.Read(); if (xmlReader.IsStartElement("views")) // Not L10N { ViewSpecList viewSpecList = ViewSpecList.Deserialize(xmlReader); return(viewSpecList.ViewSpecs.Select(view => new ReportOrViewSpec(view)).ToList()); } var reportOrViewSpecList = new ReportOrViewSpecListNoDefaults(); reportOrViewSpecList.ReadXml(xmlReader); return(reportOrViewSpecList.ToList()); }
public void ExportViews(string filename) { var viewSpecList = ViewContext.GetViewSpecList(chooseViewsControl1.SelectedGroup.Id); var selectedViewNames = new HashSet <string>(chooseViewsControl1.SelectedViews.Select(viewName => viewName.Name)); viewSpecList = new ViewSpecList(viewSpecList.ViewSpecs.Where(view => selectedViewNames.Contains(view.Name))); if (null == filename) { ViewContext.ExportViews(this, viewSpecList); } else { ViewContext.ExportViewsToFile(this, viewSpecList, filename); } }
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); } } }
public override void ExportViews(Control owner, ViewSpecList viewSpecList) { using (var saveFileDialog = new SaveFileDialog { InitialDirectory = Settings.Default.ExportResultsDirectory, CheckPathExists = true, Filter = ViewFileFilter, }) { saveFileDialog.ShowDialog(owner); if (!string.IsNullOrEmpty(saveFileDialog.FileName)) { ExportViews(owner, viewSpecList); } } }
// ReSharper restore NonLocalizedString public override void ExportViews(Control owner, ViewSpecList viewSpecList) { using (var saveFileDialog = new SaveFileDialog { InitialDirectory = Settings.Default.ActiveDirectory, CheckPathExists = true, Filter = TextUtil.FileDialogFilterAll(Resources.ExportReportDlg_ShowShare_Skyline_Reports, ReportSpecList.EXT_REPORTS) }) { saveFileDialog.ShowDialog(FormUtil.FindTopLevelOwner(owner)); if (!string.IsNullOrEmpty(saveFileDialog.FileName)) { ExportViewsToFile(owner, viewSpecList, saveFileDialog.FileName); } } }
public void TestViewSpecXml() { var viewSpecList = new ViewSpecList(new[] { new ViewSpec().SetName("ViewName") .SetColumns(new[] { new ColumnSpec(PropertyPath.Root), new ColumnSpec(PropertyPath.Parse("A.B")), }), }); var xmlSerializer = new XmlSerializer(typeof(ViewSpecList)); var stream = new MemoryStream(); xmlSerializer.Serialize(stream, viewSpecList); stream.Seek(0, SeekOrigin.Begin); var roundTrip = xmlSerializer.Deserialize(stream); Assert.AreEqual(viewSpecList, roundTrip); }
public void AddListener(Action listener) { if (_listeners == null) { if (null != _persistedViews) { _persistedViews.Changed += PersistedViewsOnChanged; } if (null != _skylineDataSchema) { _documentViews = _skylineDataSchema.Document.Settings.DataSettings.ViewSpecList; _skylineDataSchema.Listen(this); } _listeners = new HashSet <Action>(); } if (!_listeners.Add(listener)) { throw new InvalidOperationException("Listener already added"); // Not L10N } }
public TopographViewGroups(ViewSpecList oldViewSpecList) { oldViewSpecList = oldViewSpecList ?? ViewSpecList.EMPTY; Dictionary <ViewGroupId, List <ViewSpec> > viewGroups = new Dictionary <ViewGroupId, List <ViewSpec> >(); foreach (var viewSpec in oldViewSpecList.ViewSpecs) { var viewGroup = TopographViewGroup.GetGroupId(viewSpec); List <ViewSpec> viewSpecs; if (!viewGroups.TryGetValue(viewGroup, out viewSpecs)) { viewSpecs = new List <ViewSpec>(); viewGroups.Add(viewGroup, viewSpecs); } viewSpecs.Add(viewSpec); } foreach (var entry in viewGroups) { SetViewSpecList(entry.Key, new ViewSpecList(entry.Value)); } }
public override void ExportViews(Control owner, ViewSpecList views) { throw new NotSupportedException(); }
public void CopyToGroup(ViewGroup group) { var selectedViews = new ViewSpecList(chooseViewsControl1.SelectedViews.Select(viewName => ViewContext.GetViewSpecList(viewName.GroupId).GetView(viewName.Name))); ViewContext.CopyViewsToGroup(this, group, selectedViews); }
protected override void SaveViewSpecList(ViewGroupId viewGroupId, ViewSpecList viewSpecList) { Settings.Default.Reload(); Settings.Default.TopographViewGroups.SetViewSpecList(viewGroupId, viewSpecList); Settings.Default.Save(); }
public DataSettings ChangeViewSpecList(ViewSpecList viewSpecList) { return(ChangeProp(ImClone(this), im => im.ViewSpecList = viewSpecList)); }
public override void CopyViewsToGroup(Control control, ViewGroup viewGroup, ViewSpecList viewSpecList) { throw new NotSupportedException(); }
public void ExportViews(string filename) { var viewSpecList = ViewContext.GetViewSpecList(chooseViewsControl1.SelectedGroup.Id); var selectedViewNames = new HashSet<string>(chooseViewsControl1.SelectedViews.Select(viewName => viewName.Name)); viewSpecList = new ViewSpecList(viewSpecList.ViewSpecs.Where(view => selectedViewNames.Contains(view.Name))); if (null == filename) { ViewContext.ExportViews(this, viewSpecList); } else { ViewContext.ExportViewsToFile(this, viewSpecList, filename); } }
protected override void SaveViewSpecList(ViewGroupId viewGroup, ViewSpecList viewSpecList) { _viewSpecLists[viewGroup] = viewSpecList; }
public void CopyToGroup(ViewGroup group) { var selectedViews = new ViewSpecList(chooseViewsControl1.SelectedViews.Select(viewName=>ViewContext.GetViewSpecList(viewName.GroupId).GetView(viewName.Name))); ViewContext.CopyViewsToGroup(this, group, selectedViews); }
/// <summary> /// Construct a new PersistedViews, migrating over the values from the old ViewSpecList /// and ReportSpecList properties. Views that are in use by an external tool get put in /// the External Tools group, and views that are /// </summary> public PersistedViews(ReportSpecList reportSpecList, ViewSpecList viewSpecList, ToolList toolList) { var viewItems = new List <ViewSpec>(); if (null != viewSpecList) { viewItems.AddRange(viewSpecList.ViewSpecs); } if (null != reportSpecList) { RevisionIndex = reportSpecList.RevisionIndex + 1; foreach (var newView in ReportSharing.ConvertAll(reportSpecList.Select(reportSpec => new ReportOrViewSpec(reportSpec)), new SrmDocument(SrmSettingsList.GetDefault()))) { if (viewItems.Any(viewSpec => viewSpec.Name == newView.Name)) { continue; } viewItems.Add(newView); } } var viewSpecLists = new Dictionary <ViewGroup, Dictionary <string, ViewSpec> >(); foreach (var viewItem in viewItems) { ViewGroup group; if (toolList.Any(tool => tool.ReportTitle == viewItem.Name)) { group = ExternalToolsGroup; } else { group = MainGroup; } Dictionary <string, ViewSpec> list; if (!viewSpecLists.TryGetValue(group, out list)) { list = new Dictionary <string, ViewSpec>(); viewSpecLists.Add(group, list); } if (!list.ContainsKey(viewItem.Name)) { list.Add(viewItem.Name, viewItem); } else { for (int i = 1;; i++) { string name = viewItem.Name + i; if (!list.ContainsKey(name)) { list.Add(name, viewItem.SetName(name)); break; } } } } foreach (var entry in viewSpecLists) { SetViewSpecList(entry.Key.Id, new ViewSpecList(entry.Value.Values)); } AddDefaults(); }
public override void ExportViewsToFile(Control owner, ViewSpecList views, string fileName) { throw new NotSupportedException(); }