protected override void OnMouseUp(MouseButtonEventArgs e) { if (HitConnector != null) { var sourceConnector = this.sourceConnector; var sinkConnector = HitConnector; var model = new ConnectionModel(sourceConnector.ConnectorViewModel.ConnectorModel, sinkConnector.ConnectorViewModel.ConnectorModel); var connectionViewModel = new ConnectionViewModel(sourceConnector.ConnectorViewModel, sinkConnector.ConnectorViewModel, model); var newConnection = new Connection(sourceConnector, sinkConnector, connectionViewModel); Panel.SetZIndex(newConnection, designerCanvas.Children.Count); designerCanvas.Children.Add(newConnection); var vm = designerCanvas.DataContext as EditorWindowViewModel; if (vm == null) throw new ArgumentNullException("designerCanvas.DataContext as EditorWindowViewModel"); vm.Add(connectionViewModel); } if (HitDesignerItem != null) { HitDesignerItem.IsDragConnectionOver = false; } if (IsMouseCaptured) ReleaseMouseCapture(); var adornerLayer = AdornerLayer.GetAdornerLayer(designerCanvas); if (adornerLayer != null) { adornerLayer.Remove(this); } }
public ConnectionViewModel(ConnectorViewModel source, ConnectorViewModel target, ConnectionModel model) { Source = source; Target = target; Model = model; }