private void StartGCode(bool step)
{
try
{
if (!serialPort.IsOpen)
{
enableControlsForPrinting();
MessageBox.Show("Port not open.");
}
else if (GCodes.Items.Count == 0)
{
enableControlsForPrinting();
MessageBox.Show("GCode list empty.");
}
else
{
disableControlsForPrinting();
SentRowsLbl.Text = "Sent rows: 0";
List<GCodeListViewItem> gcodes = new List<GCodeListViewItem>(GCodes.Items.Count);
foreach (GCodeListViewItem gcode in GCodes.Items)
gcodes.Add(gcode);
backgroundWorker.RunWorkerAsync(new object[] { step, gcodes });
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}