Revert state in attribute window while row change event

713
5
01-22-2024 03:57 AM
TonyO
by
Emerging Contributor

 

Hi,

For the table changes, I am listening to RowChangedEvent. Inside the handler method of this event I have a message box with Yes or No options. When you click No, edits will be cancelled.

I have two use cases to handle after that:

1. Sometimes my message box is hidden due to the Update Features Progress Dialog. How to make sure the message box will not be hidden behind the progress dialog?

2. Message box with Yes or No options occurs after applying the changes in the Attribute window. When No is clicked to make sure that change shouldn't be applied, can we make the state in the attribute window back to the previous one after clicking No? 

NOTE: Message box is appearing inside the handler of RowChangeEvent which got triggered after the changes are applied from the attribute window for that table.

@Wolf @GKmieliauskas @CharlesMacleod  @NarelleChedzey 

Tags (1)
0 Kudos
5 Replies
TonyO
by
Emerging Contributor
0 Kudos
GKmieliauskas
Esri Regular Contributor

Hi,

1. MessageBox should be called from UI thread, because RowEvent callbacks are always called on the QueuedTask. If you could get your Progress Dialog window handler, you could use MessageBox Show method overload with window handler.

2. I have tried cancel edit on sample below and it reverts back value in Attribute Table window, but not in  Attribute Dockpane. It could be issue with Attribute Dockpane.

    protected override void OnClick()
    {
      //run on MCT
      QueuedTask.Run(() =>
      {
        var mapLayers = MapView.Active.Map.GetLayersAsFlattenedList().OfType<FeatureLayer>();
        foreach (var layer in mapLayers)
        {
          var layerTable = layer.GetTable();
          RowChangedEvent.Subscribe(onRowEvent, layerTable);
          RowCreatedEvent.Subscribe(onRowEvent, layerTable);
          RowDeletedEvent.Subscribe(onRowEvent, layerTable);
        }
      });
    }

    private void onRowEvent(RowChangedEventArgs obj)
    {
      obj.CancelEdit();
    }‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

0 Kudos
TonyO
by
Emerging Contributor

@GKmieliauskasProgress  dialog which is displaying is not ours but the Pro's. I am not sure we can get the window handler. And any examples?

0 Kudos
GKmieliauskas
Esri Regular Contributor

Try to set FrameworkApplication.Current.MainWindow as owner for MessageBox.

0 Kudos
TonyO
by
Emerging Contributor

 

@GKmieliauskas This is not working yet. Progress Dialog is coming above my message box.

0 Kudos