I have straight horizontal lines that I want the user to be able to drag vertically. How is this possible? I think the best option for choosing a line would be a fixed number of pixels next to the line. Therefore, if the mouse is +/- 2 pixels, I have to change the mouse cursor and make the line draggable. I see that the CurveItem class has IsSelectable and IsSelected properties. Will they have any functions in solving this problem? I cannot understand why they are intended for reading class documentation.
EDIT:
It seems that FindNearestPoint (and FindNearestObject ) only searches for actual points. How will I choose to work along the entire straight line? I think I will need to make my own regular βFindβ procedure, which will go through all the lines that I want to check, and for each calculate its imaginary point Y based on the position of the mouse X ( ? ) I also think about the slant lines for this goals, for horizontal / vertical lines it will be a little easier. At least it seems to be necessary for the curve, but I suppose the same thing needs to be done to select (in the middle of the section) LineObj?
I really did not know about the existence of LineObj . It seems that LineObj cannot change the coordinates of X2 / Y2 , since they are ReadOnly . So is it possible to drag point X2 / Y2 to LineObj in general?
EDIT 2:
There seems to be a problem with FindNearestPoint on the JapaneseCandleStick chart; When I click on the graph panel, it does not return the index of the nearest bar, but I believe that instead it selects the index with the nearest Y value, no matter how far from the x axis it is. Sometimes it is a bar to the right of the mouse, sometimes to the left of the mouse. So should it work?
I made this custom function myself, so I think everything is fine. Nevertheless, it would be nice to understand why FindNearestPoint acts this way.
This is the mouseDown code:
' Find nearest curve point:
Dim ciNearestCurve As CurveItem
Dim iNearestCurve As Integer
Dim b As Boolean = zgc.GraphPane.FindNearestPoint(mousePt, zgc.GraphPane.CurveList, ciNearestCurve, iNearestCurve)
If b Then
With ciNearestCurve(iNearestCurve)
Debug.Print(Date.FromOADate(.X) & " " & .Y & " " & .Z)
End With