private void ProcessDiagramMouseMoveFunction(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);
if ((xValue >= 0 && xValue <= 50) && (yValue >= 0 && yValue <= 30))
{
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(menuStripNodeInfoValues[i].temperature_source != "Mix") {
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))
{
//--This is changed from int to string code bbk305
idSelected = menuStripNodeInfoValues[i].id; //Now this is a string
tempIndexForNode = i;//This is for finding other values with searching for this we need index
if (Cursor != Cursors.Cross)
{
Cursor = Cursors.Hand;
//====This flag is for deleting the node===========//
FlagForNodeDelete = 1;//flag is ready on Node selected
nodeID_ForDeletingNode = idSelected;
deleteNodeToolStripMenuItem.Enabled = true; //Turn on the delete buttton
//=============end of flag for deleting===========//
}
//this.Cursor = Cursors.Hand;
//now this works so lets move forward.
readyForMouseClick = 1;//enable on click event
break;//this break is for if found the value no longer loop increases the perfomances..
}
else
{
if (Cursor != Cursors.Cross)
{
this.Cursor = Cursors.Arrow;
readyForMouseClick = 0;//dissable on click event.
//====This flag is for deleting the node===========//
FlagForNodeDelete = 0;//flag is ready OFF , Node NOT SELECTED
deleteNodeToolStripMenuItem.Enabled = false;//Turn of the delet button
//nodeID_ForDeletingNode = idSelected;
//=============end of flag for deleting===========//
}
}
//--Lets filter out the mix nodes---
}//Close of if section Mix section
//==This one is special case for mix node only
else if (menuStripNodeInfoValues[i].temperature_source == "Mix")
{
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))
{
//--This is changed from int to string code bbk305
idSelected = menuStripNodeInfoValues[i].id; //Now this is a string
tempIndexForNode = i;//This is for finding other values with searching for this we need index
if (Cursor != Cursors.Cross)
{
Cursor = Cursors.Hand;
//====This flag is for deleting the node===========//
FlagForNodeDelete = 1;//flag is ready on Node selected
nodeID_ForDeletingNode = idSelected;
deleteNodeToolStripMenuItem.Enabled = true; //Turn on the delete buttton
//=============end of flag for deleting===========//
}
//this.Cursor = Cursors.Hand;
//now this works so lets move forward.
//===This should be dissabled
// readyForMouseClick = 1;//enable on click event
break;//this break is for if found the value no longer loop increases the perfomances..
}
else
{
if (Cursor != Cursors.Cross)
{
this.Cursor = Cursors.Arrow;
/// readyForMouseClick = 0;//dissable on click event.
//====This flag is for deleting the node===========//
FlagForNodeDelete = 0;//flag is ready OFF , Node NOT SELECTED
deleteNodeToolStripMenuItem.Enabled = false;//Turn of the delet button
//nodeID_ForDeletingNode = idSelected;
//=============end of flag for deleting===========//
}
}
}
}//Close of for loop
}//close of if menuStripAllValue>0
if (mouseClickAction == 1)
{
if (Control.ModifierKeys == Keys.Alt)
{
//--This alter key is for moving along constant x-axis ...
// MessageBox.Show(" alt is pressed for x axis constant");
//menuStripNodeInfoValues[idSelected].xVal = xAxis1;
menuStripNodeInfoValues[tempIndexForNode].yVal = yAxis1;//This value is changed...
//====================For mix node movement = ===============//
UpdateMixPointOnNodeMovement();
//=====================End of mix node movemnt===================//
// label5.Text = "click past x =" + menuStripNodeInfoValues[idSelected].xVal + " y " + menuStripNodeInfoValues[idSelected].yVal;
series1.Points.Clear();
for (int i = 0; i < menuStripNodeLineInfoValues.Count; i++)//-- this -1 is done because for three points we have two line series..
{
// chart1.Series.Remove(menuStripNodeLineInfoValues[i].lineSeriesID);//--removing line series that joins node..
menuStripNodeLineInfoValues[i].lineSeriesID.Points.Clear();
}
//--this is redraw functionality
//foreach(var values in menuStripNodeInfoValues)
indexForSeriesNodePoint = 0;
for (int x = 0; x < menuStripNodeInfoValues.Count; x++)
{
string labelValue;
//if (menuStripNodeInfoValues[x].showItemText == "Label")
//{
// labelValue = menuStripNodeInfoValues[x].label;
//}
//else if (menuStripNodeInfoValues[x].showItemText == "Name")
//{
labelValue = menuStripNodeInfoValues[x].name;
//}
//else
//{
// labelValue = menuStripNodeInfoValues[x].source;
//}
//--this is changed as well code :bbk305
// ReDrawPoints(series1, menuStripNodeInfoValues[x].xVal, menuStripNodeInfoValues[x].yVal, menuStripNodeInfoValues[x].colorValue, menuStripNodeInfoValues[x].source, menuStripNodeInfoValues[x].name, menuStripNodeInfoValues[x].label, labelValue, menuStripNodeInfoValues[x].marker_Size);
ReDrawPoints(series1, menuStripNodeInfoValues[x].xVal, menuStripNodeInfoValues[x].yVal, menuStripNodeInfoValues[x].colorValue, menuStripNodeInfoValues[x].temperature_source, menuStripNodeInfoValues[x].humidity_source, menuStripNodeInfoValues[x].name, labelValue, menuStripNodeInfoValues[x].marker_Size);
//Updating values in database
if (flagForInsertOrUpdateDataToDB == 1)
{
// UpdateNodeInfoToDB(menuStripNodeInfoValues[x].id, menuStripNodeInfoValues[x].xVal, menuStripNodeInfoValues[x].yVal, menuStripNodeInfoValues[x].source, menuStripNodeInfoValues[x].name, menuStripNodeInfoValues[x].label, menuStripNodeInfoValues[x].colorValue, menuStripNodeInfoValues[x].showItemText, menuStripNodeInfoValues[x].marker_Size);
}
// incrementIndex++;
indexForSeriesNodePoint++;//Incrementing the index values
//--Every time it redraws the point we need to update to database the node values
}
//--resetting incrementIndex
//incrementIndex = 0;
if (menuStripNodeLineInfoValues.Count > 0)
{
for (int x = 0; x < menuStripNodeLineInfoValues.Count; x++)
{
// incrementIndex++;
//ReDrawLines(menuStripNodeInfoValues[x].id, menuStripNodeInfoValues[x].xVal, menuStripNodeInfoValues[x].yVal, menuStripNodeInfoValues[x].colorValue);
ReDrawLines(menuStripNodeLineInfoValues[x].ID, menuStripNodeLineInfoValues[x].prevNodeId, menuStripNodeLineInfoValues[x].nextNodeId, menuStripNodeLineInfoValues[x].lineSeriesID, menuStripNodeLineInfoValues[x].lineColorValue, menuStripNodeLineInfoValues[x].lineThickness, menuStripNodeLineInfoValues[x].name, menuStripNodeLineInfoValues[x].status);
}
}
chart1.Invalidate();
// incrementIndex = 0;//reset the values again..
// indexForSeriesNodePoint = 0;//Resetting the index value BBK305A
}
else if (Control.ModifierKeys == Keys.Shift)
{
//--This ctrl key is for moving along the y- axis...
//--THis function basically evolve when the shift key is pressed and mouse move.
// MessageBox.Show("shift is pressed for y axis constant");
//menuStripNodeInfoValues[idSelected].xVal = xAxis1;
menuStripNodeInfoValues[tempIndexForNode].xVal = xAxis1;//--This value is just changed
//menuStripNodeInfoValues[idSelected].yVal = yAxis1;
//====================For mix node movement = ===============//
UpdateMixPointOnNodeMovement();
//=====================End of mix node movemnt===================//
//label5.Text = "click past x =" + menuStripNodeInfoValues[idSelected].xVal + " y " + menuStripNodeInfoValues[idSelected].yVal;
series1.Points.Clear();
for (int i = 0; i < menuStripNodeLineInfoValues.Count; i++)//-- this -1 is done because for three points we have two line series..
{
//chart1.Series.Remove(menuStripNodeLineInfoValues[i].lineSeriesID);
menuStripNodeLineInfoValues[i].lineSeriesID.Points.Clear();
}
//--this is redraw functionality
//foreach(var values in menuStripNodeInfoValues)
indexForSeriesNodePoint = 0;
for (int x = 0; x < menuStripNodeInfoValues.Count; x++)
{
string labelValue;
//if (menuStripNodeInfoValues[x].showItemText == "Label")
//{
// labelValue = menuStripNodeInfoValues[x].label;
//}
//else if (menuStripNodeInfoValues[x].showItemText == "Name")
//{
labelValue = menuStripNodeInfoValues[x].name;
//}
//else
//{
// labelValue = menuStripNodeInfoValues[x].source;
//}
// ReDrawPoints(series1, menuStripNodeInfoValues[x].xVal, menuStripNodeInfoValues[x].yVal, menuStripNodeInfoValues[x].colorValue, menuStripNodeInfoValues[x].source, menuStripNodeInfoValues[x].name, menuStripNodeInfoValues[x].label, labelValue, menuStripNodeInfoValues[x].marker_Size);
ReDrawPoints(series1, menuStripNodeInfoValues[x].xVal, menuStripNodeInfoValues[x].yVal, menuStripNodeInfoValues[x].colorValue, menuStripNodeInfoValues[x].temperature_source, menuStripNodeInfoValues[x].humidity_source, menuStripNodeInfoValues[x].name, labelValue, menuStripNodeInfoValues[x].marker_Size);
//Updating values in database...
if (flagForInsertOrUpdateDataToDB == 1)
{
//UpdateNodeInfoToDB(menuStripNodeInfoValues[x].id, menuStripNodeInfoValues[x].xVal, menuStripNodeInfoValues[x].yVal, menuStripNodeInfoValues[x].source, menuStripNodeInfoValues[x].name, menuStripNodeInfoValues[x].label, menuStripNodeInfoValues[x].colorValue, menuStripNodeInfoValues[x].showItemText, menuStripNodeInfoValues[x].marker_Size);
}
// incrementIndex++;
indexForSeriesNodePoint++;
}
//--resetting incrementIndex
incrementIndex = 0;
if (menuStripNodeLineInfoValues.Count > 0)
{
for (int x = 0; x < menuStripNodeLineInfoValues.Count; x++)
{
incrementIndex++;
ReDrawLines(menuStripNodeLineInfoValues[x].ID, menuStripNodeLineInfoValues[x].prevNodeId, menuStripNodeLineInfoValues[x].nextNodeId, menuStripNodeLineInfoValues[x].lineSeriesID, menuStripNodeLineInfoValues[x].lineColorValue, menuStripNodeLineInfoValues[x].lineThickness, menuStripNodeLineInfoValues[x].name, menuStripNodeLineInfoValues[x].status);
}
}
chart1.Invalidate();
// incrementIndex = 0;//reset the values again..
// indexForSeriesNodePoint = 0;
}
else
{
//--Show indicator
////--Lets clear the indicator point first.
//seriesLineIndicator.Points.Clear();
//menuStripNodeInfoValues[idSelected].xVal = xAxis1;
//menuStripNodeInfoValues[idSelected].yVal = yAxis1;
menuStripNodeInfoValues[tempIndexForNode].xVal = xAxis1;
menuStripNodeInfoValues[tempIndexForNode].yVal = yAxis1;
//***********************For mix node section functions******************//
//Function helps in updating the mix point x and y value when other node are moved
UpdateMixPointOnNodeMovement();
//************************End of the mix node ************************//
//label5.Text = "click past x =" + menuStripNodeInfoValues[idSelected].xVal + " y " + menuStripNodeInfoValues[idSelected].yVal;
series1.Points.Clear();
for (int i = 0; i < menuStripNodeLineInfoValues.Count; i++)//-- this -1 is done because for three points we have two line series..
{
//chart1.Series.Remove(menuStripNodeLineInfoValues[i].lineSeriesID);
menuStripNodeLineInfoValues[i].lineSeriesID.Points.Clear();
}
//--this is redraw functionality
//foreach(var values in menuStripNodeInfoValues)
indexForSeriesNodePoint = 0;
for (int x = 0; x < menuStripNodeInfoValues.Count; x++)
{
string labelValue;
//if (menuStripNodeInfoValues[x].showItemText == "Label")
//{
// labelValue = menuStripNodeInfoValues[x].label;
//}
//else if (menuStripNodeInfoValues[x].showItemText == "Name")
//{
labelValue = menuStripNodeInfoValues[x].name;
//}
//else
//{
// labelValue = menuStripNodeInfoValues[x].source;
//}
// ReDrawPoints(series1, menuStripNodeInfoValues[x].xVal, menuStripNodeInfoValues[x].yVal, menuStripNodeInfoValues[x].colorValue, menuStripNodeInfoValues[x].source, menuStripNodeInfoValues[x].name, menuStripNodeInfoValues[x].label, labelValue, menuStripNodeInfoValues[x].marker_Size);
ReDrawPoints(series1, menuStripNodeInfoValues[x].xVal, menuStripNodeInfoValues[x].yVal, menuStripNodeInfoValues[x].colorValue, menuStripNodeInfoValues[x].temperature_source, menuStripNodeInfoValues[x].humidity_source, menuStripNodeInfoValues[x].name, labelValue, menuStripNodeInfoValues[x].marker_Size);
//Updating values in database...
if (flagForInsertOrUpdateDataToDB == 1)
{
//UpdateNodeInfoToDB(menuStripNodeInfoValues[x].id, menuStripNodeInfoValues[x].xVal, menuStripNodeInfoValues[x].yVal, menuStripNodeInfoValues[x].source, menuStripNodeInfoValues[x].name, menuStripNodeInfoValues[x].label, menuStripNodeInfoValues[x].colorValue, menuStripNodeInfoValues[x].showItemText, menuStripNodeInfoValues[x].marker_Size);
}
// incrementIndex++;
indexForSeriesNodePoint++;
}
//--resetting incrementIndex
// incrementIndex = 0;
if (menuStripNodeLineInfoValues.Count > 0)
{
// MessageBox.Show("MENUSTIRP NODE LINE INFO VALUE");
for (int x = 0; x < menuStripNodeLineInfoValues.Count; x++)
{
// MessageBox.Show("MENUSTIRP NODE LINE INFO VALUE");
// incrementIndex++;
//ReDrawLines(menuStripNodeInfoValues[x].id, menuStripNodeInfoValues[x].xVal, menuStripNodeInfoValues[x].yVal, menuStripNodeInfoValues[x].colorValue);
ReDrawLines(menuStripNodeLineInfoValues[x].ID, menuStripNodeLineInfoValues[x].prevNodeId, menuStripNodeLineInfoValues[x].nextNodeId, menuStripNodeLineInfoValues[x].lineSeriesID, menuStripNodeLineInfoValues[x].lineColorValue, menuStripNodeLineInfoValues[x].lineThickness, menuStripNodeLineInfoValues[x].name, menuStripNodeLineInfoValues[x].status);
}
}
chart1.Invalidate();
//incrementIndex = 0;//reset the values again..
// indexForSeriesNodePoint = 0;
//indexForSeriesNodePoint = 0;
}//closing of key else part
}
//Need to add here
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}//close of if chart1.ChartAreas[0]
}