public static ViewSpecList Deserialize(XmlReader reader) { ViewSpecList viewSpecList = new ViewSpecList(); viewSpecList.ReadXml(reader); return(viewSpecList); }
public virtual void ReadXml(XmlReader reader) { var viewSpecLists = new Dictionary <string, ViewSpecList>(); if (reader.IsEmptyElement) { reader.Read(); } else { reader.Read(); while (true) { if (reader.IsStartElement(@"views")) { string groupName = reader.GetAttribute(@"name"); // ReSharper disable AssignNullToNotNullAttribute viewSpecLists.Add(groupName, ViewSpecList.Deserialize(reader)); // ReSharper restore AssignNullToNotNullAttribute } else if (reader.NodeType == XmlNodeType.EndElement) { reader.ReadEndElement(); break; } else { reader.Read(); } } } _viewSpecLists = viewSpecLists; }
public void RemoveView(ViewGroupId group, string viewName) { var viewSpecList = GetViewSpecList(@group); if (null == viewSpecList) { return; } viewSpecList = new ViewSpecList(viewSpecList.ViewSpecs.Where(spec => spec.Name != viewName)); SetViewSpecList(@group, viewSpecList); }
public virtual void CopyViewsToGroup(Control control, ViewGroup viewGroup, ViewSpecList viewSpecList) { var currentViews = GetViewSpecList(viewGroup.Id); var conflicts = new HashSet <string>(); foreach (var view in viewSpecList.ViewSpecs) { var existing = currentViews.GetView(view.Name); if (existing != null && !Equals(existing, view)) { conflicts.Add(view.Name); } } if (conflicts.Count > 0) { string message; if (conflicts.Count == 1) { message = string.Format(Resources.AbstractViewContext_CopyViewsToGroup_The_name___0___already_exists__Do_you_want_to_replace_it_, conflicts.First()); } else { var messageLines = new List <String>(); messageLines.Add(Resources.AbstractViewContext_CopyViewsToGroup_The_following_names_already_exist_); messageLines.AddRange(conflicts); messageLines.Add(Resources.AbstractViewContext_CopyViewsToGroup_Do_you_want_to_replace_them_); message = string.Join(Environment.NewLine, messageLines); } var result = ShowMessageBox(control, message, MessageBoxButtons.YesNoCancel); switch (result) { case DialogResult.Cancel: return; case DialogResult.Yes: currentViews = currentViews.Filter(view => !conflicts.Contains(view.Name)); break; } } foreach (var view in viewSpecList.ViewSpecs) { if (null == currentViews.GetView(view.Name)) { currentViews = currentViews.ReplaceView(null, view); currentViews = currentViews.SaveViewLayouts(currentViews.GetViewLayouts(view.Name) .Merge(viewSpecList.GetViewLayouts(view.Name).Layouts)); } } SaveViewSpecList(viewGroup.Id, currentViews); }
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 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 void SetViewSpecList(ViewGroupId viewGroup, ViewSpecList viewSpecList) { viewSpecList = viewSpecList ?? ViewSpecList.EMPTY; ViewSpecList oldList; if (!_viewSpecLists.TryGetValue(viewGroup.Name, out oldList)) { oldList = ViewSpecList.EMPTY; } if (Equals(oldList, viewSpecList)) { return; } if (!viewSpecList.ViewSpecs.Any()) { _viewSpecLists.Remove(viewGroup.Name); } else { _viewSpecLists[viewGroup.Name] = viewSpecList; } FireChanged(); }
public void SetViewSpecList(ViewGroupId viewGroup, ViewSpecList viewSpecList) { viewSpecList = viewSpecList ?? ViewSpecList.EMPTY; ViewSpecList oldList; if (!_viewSpecLists.TryGetValue(viewGroup.Name, out oldList)) { oldList = ViewSpecList.EMPTY; } if (Equals(oldList, viewSpecList)) { return; } if (!viewSpecList.ViewSpecs.Any()) { _viewSpecLists.Remove(viewGroup.Name); } else { _viewSpecLists[viewGroup.Name] = viewSpecList; } FireChanged(); }
public void SetViewSpecList(ViewGroupId viewGroup, ViewSpecList viewSpecList) { viewSpecList = viewSpecList ?? ViewSpecList.EMPTY; ViewSpecList oldList; if (!_viewSpecLists.TryGetValue(viewGroup.Name, out oldList)) { oldList = ViewSpecList.EMPTY; } if (Equals(oldList, viewSpecList)) { return; } // ReSharper disable once PossibleNullReferenceException if (!viewSpecList.ViewSpecs.Any()) { _viewSpecLists.Remove(viewGroup.Name); } else { _viewSpecLists[viewGroup.Name] = viewSpecList; } FireChanged(); }
protected bool Equals(ViewSpecList other) { return Equals(ViewSpecs, other.ViewSpecs); }
public static ViewSpecList Deserialize(XmlReader reader) { ViewSpecList viewSpecList = new ViewSpecList(); viewSpecList.ReadXml(reader); return viewSpecList; }
protected bool Equals(ViewSpecList other) { return(Equals(ViewSpecs, other.ViewSpecs)); }
public void RemoveView(ViewGroupId group, string viewName) { var viewSpecList = GetViewSpecList(@group); if (null == viewSpecList) { return; } viewSpecList = new ViewSpecList(viewSpecList.ViewSpecs.Where(spec => spec.Name != viewName)); SetViewSpecList(@group, viewSpecList); }
public override void ExportViews(Control owner, ViewSpecList views) { throw new NotSupportedException(); }
public override void ExportViewsToFile(Control owner, ViewSpecList views, string fileName) { throw new NotSupportedException(); }
protected abstract void SaveViewSpecList(ViewGroupId viewGroupId, ViewSpecList viewSpecList);
protected override void SaveViewSpecList(ViewGroupId viewGroup, ViewSpecList viewSpecList) { _viewSpecLists[viewGroup] = viewSpecList; }
protected override void SaveViewSpecList(ViewGroupId viewGroupId, ViewSpecList viewSpecList) { Settings.Default.Reload(); Settings.Default.TopographViewGroups.SetViewSpecList(viewGroupId, viewSpecList); Settings.Default.Save(); }
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(); } }
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); } } }
public abstract void ExportViewsToFile(Control owner, ViewSpecList views, string fileName);
public void ReadXml(XmlReader reader) { string uri = reader.GetAttribute(Attr.panorama_publish_uri); if (!string.IsNullOrEmpty(uri)) PanoramaPublishUri = new Uri(uri); string docGuid = reader.GetAttribute(Attr.document_guid); if (!string.IsNullOrEmpty(docGuid)) DocumentGuid = docGuid; var allElements = new List<IXmlSerializable>(); // Consume tag if (reader.IsEmptyElement) reader.Read(); else { reader.ReadStartElement(); reader.ReadElements(allElements, GetElementHelpers()); reader.ReadEndElement(); } _annotationDefs = MakeReadOnly(allElements.OfType<AnnotationDef>()); _groupComparisonDefs = MakeReadOnly(allElements.OfType<GroupComparisonDef>()); ViewSpecList = allElements.OfType<ViewSpecList>().FirstOrDefault() ?? ViewSpecList.EMPTY; }
public abstract void ExportViews(Control owner, ViewSpecList views);
public override void CopyViewsToGroup(Control control, ViewGroup viewGroup, ViewSpecList viewSpecList) { throw new NotSupportedException(); }
/// <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 DataSettings ChangeViewSpecList(ViewSpecList viewSpecList) { return ChangeProp(ImClone(this), im => im.ViewSpecList = viewSpecList); }