Update values
The following methods are available for updating the values in the tables: Marker_NewMarkerValues (updates the new channel values of the XMarker), XMarker_PositionChanges (updates the position value of the Marker) and YMarker_PositionChanged (updates the position value of the Marker). Since these methods are called through events, the respective marker is sent as a parameter.
This allows this marker to be found in the table first, so that the values can then be modified.
private void XMarker_PositionChanged(object sender, EventArgs e)
{
Marker tmpMarker = (Marker)sender;
//set new channel value
for (int k = 0; k < axisGroup.SubMember.OfType<MarkerContainer>().First().SubMember.OfType<Marker>().Count(); k++)
{
if (axisGroup.SubMember.OfType<MarkerContainer>().First().SubMember.OfType<Marker>().Where(x => x.Orientation == TwinCAT.Measurement.Scope.API.CursorAlignment.Vertical).ToArray()[k] == tmpMarker)
{
dataGridView1[0, k].Value = tmpMarker.Position;
break;
}
}
}
private void YMarker_PositionChanged(object sender, EventArgs e)
{
Marker tmpMarker = (Marker)sender;
for(int k = 0; k< axisGroup.SubMember.OfType<MarkerContainer>().First().SubMember.OfType<Marker>().Count(); k++)
{
if(axisGroup.SubMember.OfType<MarkerContainer>().First().SubMember.OfType<Marker>().Where(x => x.Orientation == TwinCAT.Measurement.Scope.API.CursorAlignment.Horizontal).ToArray()[k] == tmpMarker)
{
dataGridView2[1, k].Value = tmpMarker.Position;
break;
}
}
}
private void Marker_NewMarkerValues(object sender, EventArgs e)
{
try
{
Marker tmpMarker = (Marker)sender;
//set new channel value
for (int k = 0; k < axisGroup.SubMember.OfType<MarkerContainer>().First().SubMember.OfType<Marker>().Count(); k++)
{
if (axisGroup.SubMember.OfType<MarkerContainer>().First().SubMember.OfType<Marker>().ToArray()[k] == tmpMarker)
{
var dict = tmpMarker.GetAllValues();
for (int j = 0; j < dict.Count; j++)
{
dataGridView1[j + 2, k].Value = dict.ElementAt(j).Value;
}
break;
}
}
}
catch (Exception) { }
}