This project is read-only.

Suspending the ViewExtentsChanged Event

Mar 24, 2014 at 10:14 PM
Is there anyway to suspend the ViewExtentsChangedEvent?
I have tried:

var mapFrame = Map.MapFrame as MapFrame;
var map = Map as Map;

None of the above seem to prevent the following from firing:

mapFrame.ViewExtentsChanged += MapFrameOnViewExtentsChanged;

In browsing through the Trunk I noticed that the LayerFrame seems to have a protected function called "SuspendExtentChanged" Should I be using this? How are we supposed to access it? Sorry, if this is a really simple question, but I feel like I have been banging my head against this too long.

Mar 25, 2014 at 5:37 AM
Yes, you need to create your own inheritor of MapFrame, inside which you can use protected methods SuspendExtentChanged()/ResumeExtentChanged().
Mar 26, 2014 at 6:58 PM
Hah, yeah, I was coding in circles (helps to step back sometimes). Anyway, I inherited the mapframe but there is another issue. Basically as I understand it when I suspend the the extent changed, it saves any extent changes that happen while it is suspended to a stack. On resume of the extent change all these view changes are applied? I would actually prefer to have an option that allows me to disregard any changes that happened during suspension on resume. The inherited mapframe doesnt appear to be able to do this as all the variables and objects i need to reset such as _lastExtent, _previousExtents, _nextExtents, are private.

Would it be alright to change a couple variables to protected?
Would it be better to pass some sort of bool into the suspension that indicates resume or dispose of view changes?
Maybe add some get/set to address this?
Perhaps another way that I am not aware of that would not require changing the DotSpatial.MapFrame code?

Mar 28, 2014 at 12:02 PM
Edited Mar 28, 2014 at 2:41 PM
The easiest way which i see - add protected property
bool RaiseExtentsChangedOnResume {get;set;}
By default it will be equals to true, but you will be able to change it in your inheritor.
Mar 28, 2014 at 7:24 PM
I was hoping I would not have to modify the existing dotspatial code as I would rather not maintain a separate branch, especially for something so trivial. Would this be something I could submit a patch of and have committed to the main project? Who/How goes about deciding what is added and what is not?

thanks again for your help
Mar 29, 2014 at 9:22 AM
If it is very critical for you, i can add this property to the trunk. But really i not see any reason why ViewExtentsChanged is raised in ResumeExtentChanged(). This is a really unexpected behavior. It is a same issue as in where LayerAdded was raised after resuming.
So better will be remove this event raising at all.
Mar 31, 2014 at 4:18 PM
Certainly not critical, I was under the impression that the behavior was expected. When I get a chance, I go track through it and see if I can isolate exactly why/where this is happening. Until then I just created a separate branch to do my testing with that I added the property to.
Apr 2, 2014 at 12:07 AM
Patch 16132 submitted

It seems that the stack was saving view changes as well as view-extent changes, thus it looked to me that it was saving all changes and firing them after the ExtentsChangedOnResume.