public ConnectorAdorner( DesignerCanvas designer, Connector sourceConnector )
     : base( designer )
 {
     myDesignerCanvas = designer;
     mySourceConnector = sourceConnector;
     myDrawingPen = new Pen( Brushes.LightSlateGray, 1 );
     myDrawingPen.LineJoin = PenLineJoin.Round;
     Cursor = Cursors.Cross;
 }
        public Connection( Connector source, Connector sink )
        {
            if ( source == null )
            {
                throw new ArgumentNullException( "source" );
            }

            if ( sink == null )
            {
                throw new ArgumentNullException( "sink" );
            }

            ID = Guid.NewGuid();
            Source = source;
            Sink = sink;

            Unloaded += OnUnloaded;
        }
        private void OnDragStarted( object sender, DragStartedEventArgs e )
        {
            HitDesignerItem = null;
            HitConnector = null;
            myPathGeometry = null;
            Cursor = Cursors.Cross;
            myWasDotted = myConnection.IsDotted;
            myConnection.StrokeDashArray = new DoubleCollection( new double[] { 1, 2 } );

            if ( sender == mySourceDragThumb )
            {
                myFixConnector = myConnection.Sink;
                myDragConnector = myConnection.Source;
            }
            else if ( sender == mySinkDragThumb )
            {
                myDragConnector = myConnection.Sink;
                myFixConnector = myConnection.Source;
            }
        }
        private void HitTesting( Point hitPoint )
        {
            bool hitConnectorFlag = false;
            
            var hitObject = myDesignerCanvas.InputHitTest( hitPoint ) as DependencyObject;

            while ( hitObject != null &&
                   hitObject != mySourceConnector.ParentDesignerItem &&
                   hitObject.GetType() != typeof( DesignerCanvas ) )
            {
                if ( hitObject is Connector )
                {
                    HitConnector = hitObject as Connector;
                    hitConnectorFlag = true;
                }

                if ( hitObject is DesignerItem )
                {
                    HitDesignerItem = hitObject as DesignerItem;
                    if ( !hitConnectorFlag )
                    {
                        HitConnector = null;
                    }

                    return;
                }
                hitObject = VisualTreeHelper.GetParent( hitObject );
            }

            HitConnector = null;
            HitDesignerItem = null;
        }