ArcGIS Explorer Desktop 1750 SDK:  MapItemChangeStatus  "Removed" fires early?

598
2
Jump to solution
07-09-2012 09:12 AM
DanHuber
New Contributor III
I've written a simple extension to automatically save the current map document whenever the user adds or removes a map item.   Whenever I call the SaveDocument() method after a 'MapItemChangeStatus.Removed' event, the item is still present in the map document even though it has been removed from the current map.  You can see this by stepping through the code and watching the item still remain on the map until the event fires, and then is removed after save method is called.   Also, closing and then reopening the document shows this is the case as the item is still there.

Any options besides writing a timer to handle this? 


C# code snip for extension:

[INDENT]public override void OnStartup()
{
  ESRI.ArcGISExplorer.Application.Application.MapItemChanged += new EventHandler<MapItemEventArgs>(Application_MapItemChanged);
}

void Application_MapItemChanged(object sender, MapItemEventArgs e)
{
  if (e.Status == MapItemChangeStatus.Added || e.Status == MapItemChangeStatus.Removed)
  {
    ESRI.ArcGISExplorer.Application.Application.SaveDocument();
  }
}[/INDENT]
0 Kudos
1 Solution

Accepted Solutions
norie
by
New Contributor III
I noticed the same behavior. It should work by firing the MapItemChanged event with "Removing", remove the item, then fire MapItemChange with "Removed."

But since it doesn't, you can create a System.Windows.Forms.Timer to check Application.IsDocumentDirty and call Application.SaveDocument at a specified Timer interval.

You can also create a handler for Application.DocumentClosed (which will fire upon document closing and application exiting) check Application.IsDocumentDirty and call Application.SaveDocument.

View solution in original post

0 Kudos
2 Replies
norie
by
New Contributor III
I noticed the same behavior. It should work by firing the MapItemChanged event with "Removing", remove the item, then fire MapItemChange with "Removed."

But since it doesn't, you can create a System.Windows.Forms.Timer to check Application.IsDocumentDirty and call Application.SaveDocument at a specified Timer interval.

You can also create a handler for Application.DocumentClosed (which will fire upon document closing and application exiting) check Application.IsDocumentDirty and call Application.SaveDocument.
0 Kudos
DanHuber
New Contributor III
I noticed the same behavior. It should work by firing the MapItemChanged event with "Removing", remove the item, then fire MapItemChange with "Removed."

But since it doesn't, you can create a System.Windows.Forms.Timer to check Application.IsDocumentDirty and call Application.SaveDocument at a specified Timer interval.

You can also create a handler for Application.DocumentClosed (which will fire upon document closing and application exiting) check Application.IsDocumentDirty and call Application.SaveDocument.


Thanks for the response.   I was hoping to avoid using a timer, but it may be my only way to work around this broken feature.
0 Kudos