/// <summary> /// Process selection operation /// </summary> /// <param name="e"></param> protected override void OnMouseMove(MouseEventArgs e) { base.OnMouseMove(e); // if mouse button is not pressed we have no drag operation, ... if (e.LeftButton != MouseButtonState.Pressed) { this.dragStartPoint = null; } // but if mouse button is pressed and start point value is set we do have one if (this.dragStartPoint.HasValue) { // create connection adorner DesignerCanvas designer = DiagramHelper.GetDiagramDesigner(this); if (designer != null) { AdornerLayer adornerLayer = AdornerLayer.GetAdornerLayer(designer); if (adornerLayer != null) { DiagramConnectorAdorner adorner = new DiagramConnectorAdorner(designer, this, this.dragStartPoint.Value); if (adorner != null) { adornerLayer.Add(adorner); e.Handled = true; } } } } }
/// <summary> /// Get start point of the possible selection operation. /// </summary> /// <param name="e"></param> protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e) { base.OnMouseLeftButtonDown(e); DesignerCanvas designer = DiagramHelper.GetDiagramDesigner(this); if (designer != null) { // position relative to DesignerCanvas this.dragStartPoint = new Point?(e.GetPosition(designer)); e.Handled = true; } }