private void OnInheritanceGraphCompleted(TypeRelationshipDocument document) { if (!document.Edges.Any()) { MessageBox.Show("No nodes found"); return; } var presentation = myPresentationCreationService.CreatePresentation(Path.GetDirectoryName(AssemblyToAnalyseLocation)); var captionModule = presentation.GetPropertySetFor <Caption>(); var tooltipModule = presentation.GetPropertySetFor <ToolTipContent>(); var edgeStyleModule = presentation.GetPropertySetFor <EdgeStyle>(); var builder = new RelaxedGraphBuilder(); foreach (var edge in document.Edges) { var e = builder.TryAddEdge(edge.Item1, edge.Item2); edgeStyleModule.Add(new EdgeStyle(e.Id) { Color = edge.Item3 == ReferenceType.DerivesFrom ? Brushes.Black : Brushes.Blue }); } presentation.Graph = builder.Graph; foreach (var desc in document.Descriptors) { captionModule.Add(new Caption(desc.Id, desc.Name)); tooltipModule.Add(new ToolTipContent(desc.Id, desc.FullName)); } if (myAddToGraph && Model.Presentation != null && Model.Presentation.Graph != null) { presentation = Model.Presentation.UnionWith(presentation, () => myPresentationCreationService.CreatePresentation(Path.GetDirectoryName(AssemblyToAnalyseLocation))); myAddToGraph = false; } if (document.FailedItems.Any()) { foreach (var item in document.FailedItems) { var sb = new StringBuilder(); sb.AppendLine("Loading failed"); sb.AppendFormat("Item: {0}", item.Item); sb.AppendLine(); sb.AppendFormat("Reason: {0}", item.FailureReason); myStatusMessageService.Publish(new StatusMessage(sb.ToString())); } } Model.Presentation = presentation; }
private void Document_Changed(object sender, DocumentChangeEventArgs e) { Packages.Clear(); if (string.IsNullOrEmpty(Document.Text)) { return; } try { var spec = SpecUtils.Deserialize(Document.Text); // initially specs do not have Ids - generate them once and keep them bool idsGenerated = false; foreach (var cluster in spec.Packages.SelectMany(p => p.Clusters)) { if (cluster.Id == null) { cluster.Id = Guid.NewGuid().ToString(); idsGenerated = true; } } if (idsGenerated) { // we cannot change the doc while handling a doc change Application.Current.Dispatcher.BeginInvoke(new Action(() => { Document.Text = SpecUtils.Serialize(spec); Save(); })); } Packages.AddRange(spec.Packages.Select(p => p.Name)); } catch (Exception ex) { myStatusMessageService.Publish(new StatusMessage("ERROR:" + ex)); } CreateGraphCommand.RaiseCanExecuteChanged(); }