コード例 #1
0
        public void refreshLayers()
        {
            if (MapView.Active == null)
            {
                return;
            }

            QueuedTask.Run(() =>
            {
                //Combobox
                _allFeatureLayers = new ObservableCollection <string>();

                foreach (var f in MapView.Active.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>())
                {
                    var okAdd     = true;
                    var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector(true);

                    var featSelectionOIDs = f.GetSelection().GetObjectIDs();

                    inspector.Load(f, featSelectionOIDs);

                    if (inspector.HasAttributes)
                    {
                        if (inspector.Count(a => a.FieldName.ToLower() == "type_couv1") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "type_couv2") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "part_str") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "et1_dens") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "et2_dens") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "et1_haut") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "et2_haut") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "couv_gaule") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "et_domi") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "origine") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "an_origine") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "reb_ess1") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "reb_ess2") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "reb_ess3") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "etagement") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "et1_age") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "et2_age") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "perturb") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "an_perturb") == 0)
                        {
                            okAdd = false;
                        }
                        if (inspector.Count(a => a.FieldName.ToLower() == "co_ter") == 0)
                        {
                            okAdd = false;
                        }

                        if (okAdd)
                        {
                            _allFeatureLayers.Add(f.Name);
                        }
                    }
                }

                this.AllFeatureLayers = new ReadOnlyObservableCollection <string>(_allFeatureLayers);
                NotifyPropertyChanged("AllFeatureLayers");
            });
        }
コード例 #2
0
        private void saveTableEdits()
        {
            if (MapView.Active == null)
            {
                return;
            }

            QueuedTask.Run(() =>
            {
                // Check to see if there is a selected feature layer
                var featLayer = MapView.Active.Map.GetLayersAsFlattenedList().FirstOrDefault(l => l.Name == SelectedFeatureLayer) as FeatureLayer;
                if (featLayer == null)
                {
                    return;
                }
                // Get the selected records, and check/exit if there are none:
                var featSelectionOIDs = featLayer.GetSelection().GetObjectIDs();
                if (featSelectionOIDs.Count == 0 || featSelectionOIDs.Count > 1)
                {
                    return;
                }

                try
                {
                    var inspector = new ArcGIS.Desktop.Editing.Attributes.Inspector(true);
                    inspector.Load(featLayer, featSelectionOIDs);

                    if (inspector.HasAttributes)
                    {
                        if (inspector.Count(a => a.FieldName.ToUpper() == "type_couv1") > 0)
                        {
                            inspector["type_couv1"] = _dataNaipf2019.TxtTbType1;
                        }

                        var editOp  = new EditOperation();
                        editOp.Name = "Edit " + featLayer.Name + ", " + Convert.ToString(featSelectionOIDs.Count) + " records.";
                        editOp.Modify(inspector);
                        editOp.ExecuteAsync();

                        //MessageBox.Show("Update operation completed.", "Editing with Inspector");
                    }
                    else
                    {
                        //MessageBox.Show("The Attribute provided is not valid. " +
                        //    "\r\n Ensure your attribute name is correct.", "Invalid attribute");
                        // return;
                    }
                }
                catch (Exception exc)
                {
                    // Catch any exception found and display a message box.
                    MessageBox.Show("Exception caught: " + exc.Message);
                    return;
                }
                finally
                {
                    if (Project.Current.HasEdits)
                    {
                        Project.Current.SaveEditsAsync();
                    }
                }
            });
        }