Exemplo n.º 1
0
        // 添加要素
        private async void add2SHP_Click(object sender, RoutedEventArgs e)
        {
            if (table.CanAdd() && layersComboBox.Items.Count >= 1 && curSelGraphic != null && layersComboBox.SelectedIndex >= 0)
            {
                // 图层
                featureLayer = (FeatureLayer)(myMapView.Map.OperationalLayers[layersComboBox.SelectedIndex]);
                // 属性表
                table = featureLayer.FeatureTable;

                QueryParameters query = new QueryParameters();
                query.WhereClause = string.Format("upper(FID) = \"0\"");
                FeatureQueryResult queryResult = await table.QueryFeaturesAsync(query);

                IEnumerator <Feature> resultFeatures = queryResult.GetEnumerator();
                List <Feature>        features       = new List <Feature>();
                while (resultFeatures.MoveNext())
                {
                    features.Add(resultFeatures.Current);
                }

                Feature tempGeoElement = features[0];

                Feature addFeature = table.CreateFeature(features[0].Attributes, curSelGraphic.Geometry);
                await table.AddFeatureAsync(addFeature);

                t1.Text = "要素保存成功!";
            }
        }
Exemplo n.º 2
0
 // 编辑要素
 private async void edit2SHP_Click(object sender, RoutedEventArgs e)
 {
     if (table.CanEditGeometry())
     {
         try
         {
             Feature changedFeature = (Feature)myShapeFileResult.GeoElements[0];
             if (curSelGraphic != null)
             {
                 Feature newFeature = table.CreateFeature(changedFeature.Attributes, curSelGraphic.Geometry);
                 changedFeature.Geometry = curSelGraphic.Geometry;
                 await table.UpdateFeatureAsync(changedFeature);
             }
         }
         catch (Exception e2)
         {
             MessageBox.Show(e2.Message);
         }
     }
 }