public ConnectionAdorner(DesignerCanvas designer, Connection connection) : base(designer) { this.designerCanvas = designer; adornerCanvas = new Canvas(); this.visualChildren = new VisualCollection(this); this.visualChildren.Add(adornerCanvas); this.connection = connection; this.connection.PropertyChanged += new PropertyChangedEventHandler(AnchorPositionChanged); InitializeDragThumbs(); drawingPen = new Pen(Brushes.LightSlateGray, 1); drawingPen.LineJoin = PenLineJoin.Round; }
protected override void OnMouseUp(MouseButtonEventArgs e) { if (HitConnector != null) { Connector sourceConnector = this.sourceConnector; Connector sinkConnector = this.HitConnector; Connection newConnection = new Connection(sourceConnector, sinkConnector); // connections are added with z-index of zero this.designerCanvas.Children.Insert(0, newConnection); } if (HitDesignerItem != null) { this.HitDesignerItem.IsDragConnectionOver = false; } if (this.IsMouseCaptured) this.ReleaseMouseCapture(); AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(this.designerCanvas); if (adornerLayer != null) { adornerLayer.Remove(this); } }