how to create draggableLine

Oct 23, 2014 at 8:47 AM
I need for draggable VerticalLine(class). The D3 lib has draggablePoint but not draggableLine. How to do it.
Oct 24, 2014 at 10:06 AM
I'm try to extend VerticalLine.
public class DraggableLine : SimpleLine
    {
        Point p1;
        Point p2;
        bool dragging = false;
        Point dragStart;
        Vector shift;

        

        protected override void UpdateUIRepresentationCore()
        {
            var transform = Plotter.Viewport.Transform;
            Point p1 = new Point(Value, Plotter.Viewport.Visible.Top).DataToScreen(transform);
            Point p2 = new Point(Value, Plotter.Viewport.Visible.Bottom).DataToScreen(transform);
            LineGeometry.StartPoint = p1;
            LineGeometry.EndPoint = p2;
        }
       
        protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
        {
            dragStart = e.GetPosition(Plotter.Viewport).ScreenToData(Plotter.Viewport.Transform);
            shift = p1 - dragStart;
            dragging = true;

            CaptureMouse();
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            if (!dragging) return;

            Point mouseInData = e.GetPosition(Plotter.Viewport).ScreenToData(Plotter.Viewport.Transform);

            if (mouseInData != dragStart)
            {
                p1 = mouseInData + shift;
            }
        }

        protected override void OnMouseLeftButtonUp(MouseButtonEventArgs e)
        {
            ReleaseMouseCapture();
            dragging = false;
        }
    }
but OnMouseLeftButtonDown not called, only OnMouseLeftButtonUp works.