Progressor issue in 2.3 Release?

299
1
10-17-2018 02:32 PM
MKa
by
Occasional Contributor III

When i delete a feature, I always ask our users if they are sure before I progress to delete or rollback in the OnRowDeleteEvent of my module.

//OnRowDeleteEvent 
//PROCEED with the delete
args.CancelEdit(() => Task.FromResult(true));



//CANCEL the Delete
args.CancelEdit(() => Task.FromResult(false));‍‍‍‍‍‍‍

But now it seems that the progressor comes up after my message box has already been shown.  My code is waiting for the result of the message box, so this "Deleting Selected Features" must be popping up on some type of out of the box code.  Is there a way to suppress this Progressor or maybe I need to take another approach now?

Before

Now

//My code waits for user response, but out of box progressor covers this up now
MessageBoxResult mbr = ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Are you sure you want to Delete this Feature?", "Confirm Delete",
MessageBoxButton.YesNo, MessageBoxImage.Warning);

if (mbr.Equals(MessageBoxResult.Yes))
{‍‍‍‍‍
0 Kudos
1 Reply
MKa
by
Occasional Contributor III

I was able to make this work in the new version now.  I think this is much cleaner now.  This allows you to get user input and act on it should the user select yes or no.  And it eliminates the progress dialog that was bothering me.  This below just checks for user trying to delete multiple items, but you could also put logic to do something after the user says they want to delete (I sometimes have to delete other objects if a parent polygon is deleted).  This would all happen in the task.  

But here is my simple stop on multiple feature delete attempt.

protected async static void OnRowDeleteEvent(RowChangedEventArgs args)
{
   try
   {
      // get the currently selected features in the map
      int selectedCount = await FeatureServiceManagement.GetMapSelectionCount();
      int selectedFeatureCount = await 
      FeatureServiceManagement.GetMapFeatureSelectionCount();
      if (selectedCount > 1 || selectedFeatureCount > 1)
      {
         //CANCEL the Delete
         args.CancelEdit(() => DeleteMultipleError());
         return;
      }
// other logic
//
//
//
}

public static Task<bool> DeleteMultipleError()
{
   return QueuedTask.Run(() =>
   {
      ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("You cannot delete multiple items at the same time", "Multiple Items Selected", MessageBoxButton.OK, MessageBoxImage.Stop);
      return Task.FromResult(false);
   });
}

‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos