WFA_psychometric_chart.Form1_main.chart1_MouseMove C# (CSharp) Method

chart1_MouseMove() private method

private chart1_MouseMove ( object sender, MouseEventArgs e ) : void
sender object
e MouseEventArgs
return void
        private void chart1_MouseMove(object sender, MouseEventArgs e)
        {            
            //this part helps to get the x  and the y coordinate 
            //this coordinate finding is based on the plotting part of chart element type..
            var pos = e.Location;
            if (prevPosition.HasValue && pos == prevPosition.Value)
                return;
            // tooltip.RemoveAll();
            prevPosition = pos;
            var results = chart1.HitTest(pos.X, pos.Y, false, ChartElementType.PlottingArea);
            foreach (var result in results)
            {
                if (result.ChartElementType == ChartElementType.PlottingArea)
                {
                    var xVal = result.ChartArea.AxisX.PixelPositionToValue(pos.X);
                    var yVal = result.ChartArea.AxisY.PixelPositionToValue(pos.Y);

                    // if((currentXAxis>=0 && currentXAxis<=50)&&(currentYAxis>=0 && currentYAxis <= 30)) { 

                    if (((double)xVal >= 0 && (double)xVal <= 50) && ((double)yVal >= 0 && (double)yVal <= 30))
                    {
                        //--These currentXAxis and currentYAxis is used for showing the dotted line 
                        currentXAxis = (double)xVal;
                        currentYAxis = (double)yVal;

                        //lb_test.Text = "x = " + currentXAxis + ",y  = " + currentYAxis;
                        // if ((currentXAxis >= 0 && currentXAxis <= 50) && (currentYAxis >= 0 && currentYAxis <= 30))
                        //{

                        //now lets move on to making other part 
                        /*1.find dbt value => this is x axis value 
                         * 2.find sp.ratio value => this is yaxis value
                         */
                        lb_dbt.Text = Math.Round(xVal, 2).ToString();
                        lb_humidity_ratio.Text = Math.Round(yVal, 2).ToString();

                        //now lets move towards printing the relative humidity at that position and dew point and enthalpy also wbt
                        //first Relative humidity...
                        //first we need to see equation w = 622*phi*pg./(patm-phi*pg);
                        /*
                         we need to calc phi value given by ycord/30 as the max value is 30..
                         * second pg which is calculated by temperature pulled from the text file we need to fist 
                         * calculate the round up value of x coord to an integer...
                         */

                        //this part is not correct yet we need to do this again....

                        double phi = 0.00000;
                        //double y_axis = yVal;
                        //now for pg..
                        ArrayList temperature_value = new ArrayList();
                        ArrayList pg_value_from_txtfile = new ArrayList();

                        //--Copying the ref temp and humidity values..
                        temperature_value = t;
                        pg_value_from_txtfile = pg;

                        double temperature = Math.Round(xVal);
                        double corres_pg_value = 0.000000;
                        for (int i = 0; i < temperature_value.Count; i++)
                        {
                            if (temperature == Double.Parse(temperature_value[i].ToString()))
                            {
                                corres_pg_value = Double.Parse(pg_value_from_txtfile[i].ToString());

                                break;
                            }
                        }//close of for

                        double patm = AirPressureFromDB * 0.001; // this is in terms of kpa //101.325;//this is constant... //101.325;//this is constant...
                        //Lets check the patm value
                      //  lb_test1.Text = "patm = " + patm;
                        double w = yVal;
                        phi = w * patm / (622 * corres_pg_value + w * corres_pg_value);//this phi gives the relative humidty..
                        phi = phi * 100;//changing into percent..
                                        //now display in label...
                        lb_RH.Text = Math.Round(phi, 2).ToString();

                       // lb_test1.Text = " Humidity = " + phi;

                        //now lets calculate the dew point...
                        double humidity = phi;
                        double temperature1 = xVal;
                        double TD = 243.04 * (Math.Log(humidity / 100) + ((17.625 * temperature1) / (243.04 + temperature1))) / (17.625 - Math.Log(humidity / 100) - ((17.625 * temperature1) / (243.04 + temperature1)));
                        //now lets print this value..
                        lb_DP.Text = Math.Round(TD, 2).ToString();


                        //now lets move towards enthalpy...

                        Patm = patm * 10;  // 1013;
                        A = 6.116441;
                        m = 7.591386;
                        Tn = 240.7263;
                        B = 621.9907;

                        double Pws = A * Math.Pow(10, (m * TD) / (TD + Tn));

                        double X = B * Pws / (Patm - Pws);   //This one is formula 

                        h = temperature1 * (1.01 + (0.00189 * X)) + 2.5 * X; //This one is the enthalpy
                        //now lets display this value ..
                        lb_enthalpy.Text = Math.Round(h, 2).ToString();

                    }


                }//Closing of currentxval= 0-50 and 0-30 currentyval
            }

            if(flagForEditComfortZoneGraphically == 1)
            {

               if(flagForBorderLineSelectedForMoveForEditCF == 1)
                {
                    //--Perform redraw function 

                   
                    CursorFunctionForComfortZoneEditMode(e);

                }
                else { 
                //--IF edit comfort zone is enabled dont do other task just do the 
                //Task of comfort zone only and let other task hault for now
                ComfortZoneBorderLineDetectForEdit(e); // --This methods detects line movement
                }




            }
            else
            { 

            //--IF the line is selected/disconnected and then we need to connect to a node
            if (flagForDisconnectClick == 1)  //Disconnect is clicked then they talk
            {
                //--Creating temporary line..
                //--then redraw it again...
                addTemporarySeries();
                //--Now lets move on the showing the hand when hover over the Node lets do it bro...
                addCursorFunctionForLineDisconnectConnect(e);
                // lb_where.Text = "me : discon =1";

            }
            else {
                // lb_where.Text = "me : else line detect on";
                disconnectLineToolStripMenuItem.Enabled = false;

                //--This one is for two side of line disconnection -------//
                disconnectLineFromAToolStripMenuItem.Enabled = false;
                //disconnectLineFromBToolStripMenuItem.Enabled = false;

                nodeAToolStripMenuItem.Enabled = false;
                nodeBToolStripMenuItem.Enabled = false;
                addMixNodeToolStripMenuItem.Enabled = false;//Dissable add mix node
                //---End of two side of line disconnection section

                //--This is for the weather the line is moverover or not...
                LineDetectOnMouseMove(e);  
                                                                                             
                //--Lets add a function for the process diagram drawing..

                ProcessDiagramMouseMoveFunction(e);//--This does the adding and removing part             
            }

            }

        }//close of the main private void...
Form1_main