protected void AttachMeasureAction(Map map) { if (!MeasureActionSelected && map != null) { MeasureActionSelected = true; //ToolLock = true; map.Layers.CollectionChanged += Layers_CollectionChanged; MeasureAction.Attach(map); MeasureAction.Execute(); } } protected void StartMeasureAction() { DisableMeasureAction(); foreach (Map map in InternalMaps) { map.PreviewMouseDown += Map_PreviewMouseDown; map.Cursor = Cursors.Hand; //Need to reset cursor because measure action changes it upon finish } } protected void DisableMeasureAction() { MeasureAction.Detach(); foreach (Map map in InternalMaps) map.PreviewMouseDown -= Map_PreviewMouseDown; MeasureActionSelected = false; //ToolLock = false; } //Events protected void Map_PreviewMouseDown(Object sender, System.Windows.Input.MouseButtonEventArgs e) { DisableMeasureAction(); AttachMeasureAction((Map)sender); } protected void Layers_CollectionChanged(Object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { //Restart measure action when finished if(MeasureActionSelected) { if (e.OldItems != null) { for (Int32 i = 0; i < e.OldItems.Count; i++) { if (e.OldItems is GraphicsLayer && ((GraphicsLayer)e.OldItems).ID == null) { StartMeasureAction(); break; } } } } }
Try to execute your code asynchrounously from your event handler.Something like :Dispatcher.BeginInvoke(ActivateActionTool);
Dispatcher.BeginInvoke(ActivateActionTool);
Try to execute your code asynchrounously from your event handler.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.