private Task ShowAttributes() { return(QueuedTask.Run(() => { try { _fieldAttributes.Clear(); if (SelectedLayer == null || SelectedOID == null) { return; } var oidField = SelectedLayer.GetTable().GetDefinition().GetObjectIDField(); var qf = new ArcGIS.Core.Data.QueryFilter() { WhereClause = string.Format("{0} = {1}", oidField, SelectedOID) }; var cursor = SelectedLayer.Search(qf); Row row = null; if (cursor.MoveNext()) { row = cursor.Current; } if (row == null) { return; } var fields = row.GetFields(); lock (_lock) { foreach (ArcGIS.Core.Data.Field field in fields) { if (field.FieldType == FieldType.Geometry) { continue; } var val = row[field.Name]; FieldAttributeInfo fa = new FieldAttributeInfo(field, (val is DBNull || val == null) ? null : val.ToString()); _fieldAttributes.Add(fa); } } } catch (Exception) { } })); }
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); } })); }