private void CreateEdgeControl(VertexControl targetVertexControl) { if (sourceVertexControl == null) { editorManager.CreateVirtualEdge(targetVertexControl, targetVertexControl.GetPosition()); sourceVertexControl = targetVertexControl; HighlightBehaviour.SetHighlighted(sourceVertexControl, true); return; } if (Equals(sourceVertexControl, targetVertexControl)) { return; } var wordPrototype = viewModel.DataStructure.Elements.OfType<Word>().Single(); var addEdgeDialog = new AddEdgeWindow( new AddEdgeViewModel( wordPrototype.Attributes.Single( a => a.Name.Equals(CurrentConfiguration.Edge.LabelAttributeName)))); if (addEdgeDialog.ShowDialog().GetValueOrDefault()) { var edgeLabelText = string.Empty; var dataContext = addEdgeDialog.DataContext as AddEdgeViewModel; if (dataContext != null) { edgeLabelText = dataContext.Attributes.First().Value; } var sourceWordVertex = sourceVertexControl.Vertex as WordVertex; var targetWordVertex = targetVertexControl.Vertex as WordVertex; if ((sourceWordVertex == null) || (targetWordVertex == null)) { return; } targetWordVertex.WordWrapper.SetAttributeByName( CurrentConfiguration.Edge.SourceVertexAttributeName, sourceWordVertex.WordWrapper.GetAttributeByName(CurrentConfiguration.Edge.TargetVertexAttributeName)); targetWordVertex.WordWrapper.SetAttributeByName( CurrentConfiguration.Edge.LabelAttributeName, edgeLabelText); var data = new WordEdge((WordVertex)sourceVertexControl.Vertex, targetWordVertex) { Text = edgeLabelText }; var ec = new EdgeControl(sourceVertexControl, targetVertexControl, data); GgArea.InsertEdgeAndData(data, ec, 0, true); HighlightBehaviour.SetHighlighted(sourceVertexControl, false); sourceVertexControl = null; editorManager.DestroyVirtualEdge(); } viewModel.InvalidateCommands(); }
/// <summary> /// Shows windodow AddEdgeWindow /// </summary> private void AddEdge_Click(object sender, RoutedEventArgs e) { AddEdgeWindow addEdgeWindow = new AddEdgeWindow(this.machine); addEdgeWindow.Show(); }