<< Click to Display Table of Contents >> Navigation: The System Automation Tab > Automatic XYZ Acquisition > Table Macro programming > Table Macro Programming - Example code |
public Exception ProcessMacroTable(int nRows, ref bool[] chkBox, ref float[] x, ref float[] y, ref float[] focus, ref float[] zoom, ref string[] Macro, ref System.Drawing.Color[,] colCell)
{
try
{
float refX = 0;
float refY = 0;
float refFocus = 0;
float refZoom = 0;
for (int r = 0; r < nRows; r++)
{
if (null != Macro[r])
{
// Parse and color code Macro-field
string cmt = Macro[r];
System.Drawing.Color colMacro = System.Drawing.Color.White;
if (cmt.Contains("Hello") == true)
{
colMacro = System.Drawing.Color.Yellow;
chkBox[r] = true;
}
if (cmt.Contains("Goodbye") == true)
{
colMacro = System.Drawing.Color.Pink;
chkBox[r] = false;
}
// Specify a test macro M0 - store data
if (cmt.Contains("M0") == true)
{
Macro[r] = "M0 REF";
refX = x[r];
refX = y[r];
refFocus = focus[r];
refZoom = zoom[r];
}
// Specify a test macro M1
if (cmt.Contains("M1") == true)
{
colMacro = System.Drawing.Color.Lime;
Macro[r] = "M1 ADD";
x[r] = x[r - 1] + refX;
y[r] = y[r - 1] + refY;
focus[r] = focus[r - 1] + refFocus;
}
// Specify a test macro M2
if (cmt.Contains("M2") == true)
{
colMacro = System.Drawing.Color.Cyan;
Macro[r] = "M2 MUL";
x[r] = 2 * x[r - 1];
y[r] = 3 * y[r - 1];
focus[r] = 4 * focus[r - 1];
}
colCell[r, 3] = colMacro;
// Color code X-fields
colCell[r, 0] = (x[r] > 10) ? System.Drawing.Color.SpringGreen : System.Drawing.Color.PaleGreen;
// Color code Y-fields
colCell[r, 1] = (y[r] > 10) ? System.Drawing.Color.SpringGreen : System.Drawing.Color.PaleGreen;
// Color code Z-fields
colCell[r, 2] = (focus[r] > 10) ? System.Drawing.Color.SpringGreen : System.Drawing.Color.PaleGreen;
}
}
}
catch (Exception ex)
{
return ex;
}
return new Exception(null, null);
}