How to implement previous/next extent functionality

658
4
12-05-2017 06:42 AM
GintautasKmieliauskas
Regular Contributor

I am trying to implement on my runtime application previous/next extent functionality like in ArcMap or ArcGIS Pro using

ViewpointChanged event but on each action with viewpoint changing (zooming, panning and etc.) I get more than one event. How can I check is it last event for current action?

0 Kudos
4 Replies
AnttiKajanus1
Regular Contributor II

You should use GeoView.NavigationCompleted Event to get the viewpoint out and then save that. Then you can use any navigation methods with the viewpoint to invoke the navigation.

0 Kudos
GintautasKmieliauskas
Regular Contributor

Hi Antti,

I have changed ViewpointChanged event to NavigationCompleted but situation is still the same. My fixed zoomin tool  (code below) generates more than one event. More than one event I get on my application startup to.

private async void FixedZoomIn_Click(object sender, RoutedEventArgs e)

{

try

{

MainWindow Form = Application.Current.Windows[0] as MainWindow;

if (Form == null) return;

Viewpoint vp = Form.MyMapView.GetCurrentViewpoint(ViewpointType.CenterAndScale);

Viewpoint nvp = new Viewpoint(vp.TargetGeometry as MapPoint, vp.TargetScale / 2);

await Form.MyMapView.SetViewpointAsync(nvp);

}

catch (Exception ex)

{

System.Diagnostics.Debug.WriteLine(ex.ToString(), System.Reflection.Assembly.GetExecutingAssembly().FullName);

}

}

0 Kudos
dotMorten_esri
Esri Frequent Contributor

The above code would generate the event each time the SetviewpointAsync method completes. So if you click the button twice, you'll get two events. Are you seeing more than that? (and if so, make sure you only listen for the event once).

0 Kudos
GintautasKmieliauskas
Regular Contributor

Hi Morten,

I have checked and found that my button was clicked once but fires 2 NavigationCompleted events. My ribbonbutton has PreviewMouseDown implementation which lets prevent double clicks:

private void RibbonButton_PreviewMouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e)

{

if (e.ClickCount >= 2)

{

e.Handled = true;

}

}

The same situation I get when I try to maximize or restore my application size. I get 2 NavigationCompleted events each time.

Maybe problem is Ribbon usage?

0 Kudos