WFA_psychometric_chart.Form1_main.addCursorFunctionForLineDisconnectConnect C# (CSharp) Method

addCursorFunctionForLineDisconnectConnect() public method

This adds cursor function as dotted cursor which need to be redrawn constantly it updates the value of the dotted cursor
public addCursorFunctionForLineDisconnectConnect ( MouseEventArgs e ) : void
e MouseEventArgs Mouse event argument while performing onMouseMove
return void
        public void addCursorFunctionForLineDisconnectConnect(MouseEventArgs e)
        {//--This function helps to draw a mouse move event..
            //--This is done to prevent mouse event e.x called before chart is loaded other wise the program will crash
            if (!chart1.IsAccessible && load == 0)
            {
                load = 1;
                return;

            }

            //this event occurs and compares the values in the list first and identifies if the values
            if ((e.X > chart1.ChartAreas[0].Position.X && e.Y > chart1.ChartAreas[0].Position.Y) && (e.X < chart1.Width && e.Y < chart1.Height))
            {
                try
                {
                    //Point position = e.Location;
                    double xValue = chart1.ChartAreas[0].AxisX.PixelPositionToValue(e.X);
                    double yValue = chart1.ChartAreas[0].AxisY.PixelPositionToValue(e.Y);

                    xAxis1 = xValue;
                    yAxis1 = yValue;
                    if ((xAxis1 >= 0 && xAxis1 <= 50) && (yAxis1 >= 0 && yAxis1 <= 30)) {
                        //Console.Write("xval = " + xValue + "yvalue = " + yValue);
                        if (menuStripNodeInfoValues.Count > 0)
                        {
                            //foreach(var values in menuStripNodeInfoValues)

                            for (int i = 0; i < menuStripNodeInfoValues.Count; i++)
                            {

                                if ((xValue > menuStripNodeInfoValues[i].xVal - 0.25 && xValue < menuStripNodeInfoValues[i].xVal + 0.25) && (yValue > menuStripNodeInfoValues[i].yVal - 0.25 && yValue < menuStripNodeInfoValues[i].yVal + 0.25))
                                {

                                    idOfNodeSelected = menuStripNodeInfoValues[i].id;
                                    if (Cursor == Cursors.Cross)
                                    {
                                        Cursor = Cursors.Hand;
                                    }

                                    //--Whenever this occurs lets move on to attaching the the node or say refreshing and replotting....
                                    //--For this as well lets rise a flag..
                                    flagNodeSelectedForConnect = 1;
                                    break;//this break is for if found the value no longer loop increases the perfomances..
                                }
                                else
                                {
                                    if (Cursor != Cursors.Cross)
                                    {
                                        this.Cursor = Cursors.Cross;
                                        // readyForMouseClick = 0;//dissable on click event.
                                        flagNodeSelectedForConnect = 0;
                                    }

                                }
                            }
                        }//close of if menuStripAllValue>0
                    }//close of if
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }//--close of the if..



        }//close of the actual function...public void
Form1_main