WFA_psychometric_chart.Form_handler.addCursorFunctionForLineDisconnectConnect C# (CSharp) 메소드

addCursorFunctionForLineDisconnectConnect() 공개 메소드

public addCursorFunctionForLineDisconnectConnect ( MouseEventArgs e ) : void
e MouseEventArgs
리턴 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;
                    //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
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }//--close of the if..
        }