private Task UpdateForActiveMap(bool activeMapChanged = true, Dictionary <MapMember, List <long> > mapSelection = null) { return(QueuedTask.Run(() => { SelectedLayerInfo selectedLayerInfo = null; if (!_selectedLayerInfos.ContainsKey(_activeMap)) { selectedLayerInfo = new SelectedLayerInfo(); _selectedLayerInfos.Add(_activeMap, selectedLayerInfo); } else { selectedLayerInfo = _selectedLayerInfos[_activeMap]; } if (activeMapChanged) { RefreshLayerCollection(); SetProperty(ref _selectedLayer, (selectedLayerInfo.SelectedLayer != null) ? selectedLayerInfo.SelectedLayer : Layers.FirstOrDefault(), () => SelectedLayer); if (_selectedLayer == null) { FrameworkApplication.SetCurrentToolAsync("esri_mapping_exploreTool"); return; } selectedLayerInfo.SelectedLayer = SelectedLayer; } if (SelectedLayer == null) { RefreshSelectionOIDs(new List <long>()); } else { List <long> oids = new List <long>(); if (mapSelection != null) { if (mapSelection.ContainsKey(SelectedLayer)) { oids.AddRange(mapSelection[SelectedLayer]); } } else { oids.AddRange(SelectedLayer.GetSelection().GetObjectIDs()); } RefreshSelectionOIDs(oids); } SetProperty(ref _selectedOID, (selectedLayerInfo.SelectedOID != null && LayerSelection.Contains(selectedLayerInfo.SelectedOID)) ? selectedLayerInfo.SelectedOID : LayerSelection.FirstOrDefault(), () => SelectedOID); selectedLayerInfo.SelectedOID = SelectedOID; ShowAttributes(); })); }
private Task EditAnnotationSymbolAsync() { return(QueuedTask.Run(() => { EditOperation op = new EditOperation(); op.Name = "Change annotation graphic"; //At 2.1 we must use an edit operation Callback... op.Callback(context => { RowCursor rowCursor; if (SelectedLayer.GetSelection().GetCount() == 0) //The Selected layer has no selection { rowCursor = SelectedLayer.GetTable().Search(null, false); } else //Selection exists { var oidList = SelectedLayer.GetSelection().GetObjectIDs(); var oid = SelectedLayer.GetTable().GetDefinition().GetObjectIDField(); QueryFilter qf = new QueryFilter() { WhereClause = string.Format("({0} in ({1}))", oid, string.Join(",", oidList)) }; //Cursor must be non-recycling. Use the table ~not~ the layer..i.e. "GetTable().Search()" //SelectedLayer is ~your~ Annotation layer rowCursor = SelectedLayer.GetTable().Search(qf, false); } while (rowCursor.MoveNext()) { using (var af = rowCursor.Current as AnnotationFeature) { var graphic = af.GetGraphic() as CIMTextGraphic; graphic.Symbol = SelectedTextStyle.Symbol.MakeSymbolReference(); // update the graphic af.SetGraphic(graphic); // store is required af.Store(); //refresh layer cache context.Invalidate(af); } } }, SelectedLayer.GetTable()); op.Execute(); //set the label's visiblity if (IsLabelVisible) { (SelectedLayer as AnnotationLayer).SetVisibility(true); } })); }
private Task SelectedLayerChanged() { return(QueuedTask.Run(() => { if (SelectedLayer == null) { RefreshSelectionOIDs(new List <long>()); } else { var selection = SelectedLayer.GetSelection(); RefreshSelectionOIDs(selection.GetObjectIDs()); } SelectedOID = LayerSelection.FirstOrDefault(); })); }