public HResult ClickButton(int id) { try { _active.ClickButton(id); return(HResult.OK); } catch (Exception ex) { return(ErrorUtil.GetHResult(ex)); } }
// helper method for processing the callback both in the // data-member case and the callback argument case private bool handleCallback(ActiveTaskDialog taskDialog, TaskDialogCallbackArgs args, MyData callbackData) { // This gets called continuously until we finished completely if (args.Notification == TaskDialogNotification.Timer) { // To make it longer we do some delay in every second call if (callbackData.delay) { System.Threading.Thread.Sleep(1000); } else { callbackData.counter += 10; taskDialog.SetProgressBarRange(0, 100); taskDialog.SetProgressBarPosition( callbackData.counter); // This is the main action - adding 100 lines 1 by 1 Database db = HostApplicationServices.WorkingDatabase; Transaction tr = db.TransactionManager.TopTransaction; BlockTable bt = (BlockTable)tr.GetObject( db.BlockTableId, OpenMode.ForRead); BlockTableRecord ms = (BlockTableRecord)tr.GetObject( bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite); Line ln = new Line( new Point3d(0, callbackData.counter, 0), new Point3d(10, callbackData.counter, 0)); ms.AppendEntity(ln); tr.AddNewlyCreatedDBObject(ln, true); // To make it appear on the screen - might be a bit costly tr.TransactionManager.QueueForGraphicsFlush(); acApp.DocumentManager.MdiActiveDocument.Editor.Regen(); // We are finished if (callbackData.counter >= 100) { // We only have a cancel button, // so this is what we can press taskDialog.ClickButton( (int)WinForms.DialogResult.Cancel); return(true); } } callbackData.delay = !callbackData.delay; } else if ( args.Notification == TaskDialogNotification.ButtonClicked) { // we only have a cancel button if (args.ButtonId == (int)WinForms.DialogResult.Cancel) { return(false); } } return(true); }