WFA_psychometric_chart.Form1_main.UpdateMixPointOnNodeMovement C# (CSharp) Method

UpdateMixPointOnNodeMovement() public method

Function update the mix values and helps in movement when the mouse movement is done related values Function helps in updating the mix point x and y value when other node are moved
public UpdateMixPointOnNodeMovement ( ) : void
return void
        public void UpdateMixPointOnNodeMovement()
        {
            /*
                         1.Identify the node that has been changed
                         2. Find the corresponding node and change its x and y coordinate accordingly

            */

            string nodeID = menuStripNodeInfoValues[tempIndexForNode].id;//This node has change

            temporaryMixNodeList.Clear();//Clearing the mix node
          //  for (int j = 0; j < menuStripNodeInfoValues.Count; j++)
            //{
                //if (nodeID == menuStripNodeInfoValues[j].id)
                //{
                    //For every node we need to check ok 
                    //if (menuStripNodeInfoValues[j].temperature_source == "Mix")
                    //{
                        //Only for mix hai
                        string mixNodePrevNodeId = "";
                        string mixNodeNextNodeId = "";
                        for (int i = 0; i < mixNodeInfoList.Count; i++)
                        {
                            //--we need to identify mix node
                            if (nodeID == mixNodeInfoList[i].previousNodeID)
                            {
                                // mixNodePrevNodeId = mixNodeInfoList[i].previousNodeID;
                                temporaryMixNodeList.Add(new TempDataTypeForMixNode
                                {
                                    chartID = mixNodeInfoList[i].chartID,
                                    nodeID = mixNodeInfoList[i].nodeID,
                                    nextNodeID = mixNodeInfoList[i].nextNodeID,
                                    previousNodeID = mixNodeInfoList[i].previousNodeID
                                });
                            }
                            else if (nodeID == mixNodeInfoList[i].nextNodeID)
                            {
                                //mixNodeNextNodeId = mixNodeInfoList[i].nextNodeID;
                                temporaryMixNodeList.Add(new TempDataTypeForMixNode
                                {
                                    chartID = mixNodeInfoList[i].chartID,
                                    nodeID = mixNodeInfoList[i].nodeID,
                                    nextNodeID = mixNodeInfoList[i].nextNodeID,
                                    previousNodeID = mixNodeInfoList[i].previousNodeID
                                });
                            }

                        }

                        //--Found mix node and previous node id 
                        //--Now lets get x1,y1 ,x2,y2, and m and n value

                       // break;//Exit form the loop no need to do more
                    //}//close of if mix value
               // }//Close of if
           // } //Close of for loop

            //Now lets update the node info form temporary mix nodelists
            for (int i = 0; i < temporaryMixNodeList.Count; i++)
            {
                string previousNodeID = temporaryMixNodeList[i].previousNodeID;
                string nextNodeID = temporaryMixNodeList[i].nextNodeID;
                double n = 0;//from next nodeid
                double m = 0;//from previous node id
                double x1 = 0;  //x1,y1 is for previous node id 
                double y1 = 0;
                double x2 = 0; //For next node id
                double y2 = 0;
                //Start the updating here
                for (int x = 0; x < menuStripNodeInfoValues.Count; x++)
                {
                    if (previousNodeID == menuStripNodeInfoValues[x].id)
                    {
                        //Previous node id update
                        m = menuStripNodeInfoValues[x].airFlow;
                        x1 = menuStripNodeInfoValues[x].xVal;
                        y1 = menuStripNodeInfoValues[x].yVal;
                    }
                    else if (nextNodeID == menuStripNodeInfoValues[x].id)
                    {
                        //Previous node id update
                        n = menuStripNodeInfoValues[x].airFlow;
                        x2 = menuStripNodeInfoValues[x].xVal;
                        y2 = menuStripNodeInfoValues[x].yVal;
                    }
                }

                double x_mix = ((n * x2) + (m * x1)) / (m + n);
                double y_mix = ((n * y2) + (m * y1)) / (m + n);

                //Now lets update the values in 
                for (int x = 0; x < menuStripNodeInfoValues.Count; x++)
                {
                    if (temporaryMixNodeList[i].nodeID == menuStripNodeInfoValues[x].id)
                    {
                        //update and break

                        menuStripNodeInfoValues[x].xVal = x_mix;
                        menuStripNodeInfoValues[x].yVal = y_mix;    //Update complete
                        break;
                    }
                }

            }//Close of for

        }
Form1_main