internal void AddLayerToMap(string url) { //clear previous flag, if any _addFailed = false; OnPropertyChanged("AddStatus"); string id = url; //get the query result var result = _results.FirstOrDefault(ri => ri.ID == id); if (result == null) { throw new ApplicationException(string.Format("Debug: bad id {0}", id)); } QueuedTask.Run(action: async() => { if (LayerFactory.Instance.CanCreateLayerFrom(result) && MapView.Active?.Map != null) { LayerFactory.Instance.CreateLayer(result, MapView.Active.Map); } else if (MapFactory.Instance.CanCreateMapFrom(result)) { Map newMap = MapFactory.Instance.CreateMapFromItem(result); IMapPane newMapPane = await ProApp.Panes.CreateMapPaneAsync(newMap); } else { _addFailed = true;//cannot be added FrameworkApplication.Current.Dispatcher.Invoke(() => OnPropertyChanged("AddStatus")); } }); }
internal void AddLayerToMap(string url) { //clear previous flag, if any _addFailed = false; OnPropertyChanged("AddStatus"); string id = url; //get the query result var result = _results.FirstOrDefault(ri => ri.Id == id); if (result == null) { throw new ApplicationException(string.Format("Debug: bad id {0}", id)); } if (result.Item == null) { result.Item = ItemFactory.Create(id, ItemFactory.ItemType.PortalItem); } // Syntax can get complicated here // Question - do you need to await the QueuedTask.Run? If so, you need a Func<Task> // and not an Action. //http://stackoverflow.com/questions/20395826/explicitly-use-a-functask-for-asynchronous-lambda-function-when-action-overloa // //As it currently stands, this QueuedTask.Run will return to the caller on the first await QueuedTask.Run(action: async() => { if (LayerFactory.CanCreateLayerFrom(result.Item)) { LayerFactory.CreateLayer(result.Item, MapView.Active.Map); } else if (MapFactory.CanCreateMapFrom(result.Item)) { Map newMap = await MapFactory.CreateMapAsync(result.Item); IMapPane newMapPane = await ProApp.Panes.CreateMapPaneAsync(newMap); } else { _addFailed = true;//cannot be added FrameworkApplication.Current.Dispatcher.Invoke(() => OnPropertyChanged("AddStatus")); } }); }
private void OnActivePaneChanged(PaneEventArgs obj) { Pane pane = obj.IncomingPane; if (pane != null) { IMapPane mapPane = pane as IMapPane; if (mapPane != null) { IsCameraEnabled = true; } else { IsCameraEnabled = false; } } else { IsCameraEnabled = false; } }