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);
//add here
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 ((xValue > menuStripNodeInfoValues[i].xVal - 0.25 && xValue < menuStripNodeInfoValues[i].xVal + 0.25) && (yValue > menuStripNodeInfoValues[i].yVal - 0.25 && yValue < menuStripNodeInfoValues[i].yVal + 0.25))
{
idSelected = menuStripNodeInfoValues[i].id;
if (Cursor != Cursors.Cross)
{
Cursor = Cursors.Hand;
}
//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.
}
}
}
}//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[idSelected].yVal = yAxis1;
// 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)
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);
//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);
}
incrementIndex++;
//--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);
}
}
chart1.Invalidate();
incrementIndex = 0;//reset the values again..
}
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[idSelected].yVal = yAxis1;
//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)
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);
//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);
}
incrementIndex++;
}
//--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);
}
}
chart1.Invalidate();
incrementIndex = 0;//reset the values again..
}
else
{
//--Show indicator
////--Lets clear the indicator point first.
//seriesLineIndicator.Points.Clear();
menuStripNodeInfoValues[idSelected].xVal = xAxis1;
menuStripNodeInfoValues[idSelected].yVal = yAxis1;
//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)
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);
//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);
}
incrementIndex++;
}
//--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);
}
}
chart1.Invalidate();
incrementIndex = 0;//reset the values again..
}//closing of key else part
}
//if ends here
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}//close of if chart1.ChartAreas[0]
}