I have a program that once you establish the configuration in a dialog box you need, it asks you to select multiple points, then determines the correct block based on your configuration and the points you selected and then inserts the block. It repeats the insert command, but not the dialog box as the configuration does not change during this session.
I need to be able to press the ESC key, or right click the mouse, to exit out of the while loop that repeats the point selection and insert portion of the routine. At this point there is no keyboard input, just selecting points as prompted.
How do I get my program to recognize that the ESC key, or right click the mouse, has been pressed and use that to exit my while loop?
Thanks for your suggestions.
Partial code shown here:
try
{
using (DBSvc.Transaction tr1 = rfmlDB.TransactionManager.StartTransaction())
{
curOsmode = System.Convert.ToInt32(App.GetSystemVariable("OSMODE"));
curOrtho = System.Convert.ToInt32(App.GetSystemVariable("ORTHOMODE"));
App.SetSystemVariable("OSMODE", 2815);
App.SetSystemVariable("ORTHOMODE", 1);
tr1.Commit();
}
Application.EnableVisualStyles();
App.ShowModalDialog(new frmRFML());
cfg = frmRFML.cfgArray;
// GetPoints and insert block until ESC or Enter selected
while (true)
{
GetPointsRFML(cfg.Levels);
//RFMLKeyCalc(xmHt); (future)
RFML_BlockName BlockNameRFML = new RFML_BlockName();
BlockInsert GetSupport = new BlockInsert();
bName = BlockNameRFML.BuildBlockName(xmHt, cfg, TGDVer);
GetSupport.InsertBlock(bsPoint, BlockNameRFML.BuildBlockName(xmHt, cfg, TGDVer));
try
{
using (DBSvc.Transaction tr2 = rfmlDB.TransactionManager.StartTransaction())
{
DBSvc.BlockTable blkTable = (DBSvc.BlockTable)tr2.GetObject(rfmlDB.BlockTableId, DBSvc.OpenMode.ForRead) as DBSvc.BlockTable;
if (blkTable.Has(bName))
{
Random rnd = new Random();
int stamp = rnd.Next();
string nbname = "z_" + bName + System.Convert.ToString(stamp);
var btr = (DBSvc.BlockTableRecord)tr2.GetObject(blkTable[bName], DBSvc.OpenMode.ForWrite);
btr.Name = nbname;
}
tr2.Commit();
}
}
catch (ArgumentException e)
{
MessageBox.Show(e.Message);
}
App.SetSystemVariable("OSMODE", curOsmode);
App.SetSystemVariable("ORTHOMODE", curOrtho);
//RFML_XmPositions.UpDateXmPosition(bName, ref xmHeight, ref xmSpread);
}
}
catch (ArgumentException e)
{
MessageBox.Show(e.Message);
}
}