protected override Task OnToolActivateAsync(bool active) { if (_vm == null) { _vm = this.OverlayEmbeddableControl as OverlayControlViewModel; } if (_overlaySymbol == null) { QueuedTask.Run(() => { _overlaySymbol = SymbolFactory.ConstructPointSymbol(ColorFactory.Red, 12.0, SimpleMarkerStyle.Circle); }); } if (_trees == null) { _trees = ActiveMapView.Map.GetLayersAsFlattenedList().FirstOrDefault((lyr) => lyr.Name == "Tree") as BasicFeatureLayer; } if (_theInspector == null) { _theInspector = new Inspector(); var tuple = _theInspector.CreateEmbeddableControl(); _vm.InspectorView = tuple.Item2; _vm.InspectorViewModel = tuple.Item1; } return(base.OnToolActivateAsync(active)); }
public AttributeControlViewModel(XElement options) : base(options) { // create a new instance for the inspector _featureInspector = new Inspector(); // create an embeddable control from the inspector class to display on the pane var icontrol = _featureInspector.CreateEmbeddableControl(); // get view and viewmodel from the inspector InspectorView = icontrol.Item2; InspectorViewModel = icontrol.Item1; }
protected ShowAttributeViewModel() { // create a new instance for the inspector _attributeInspector = new Inspector(); // Tell the singleton module class Module1.AttributeInspector = AttributeInspector; Module1.AttributeViewModel = this; // create an embeddable control from the inspector class to display on the pane var icontrol = _attributeInspector.CreateEmbeddableControl(); // get viewmodel and view for the inspector control InspectorViewModel = icontrol.Item1; InspectorView = icontrol.Item2; }
protected override async Task OnToolActivateAsync(bool active) { // get the Precincts feature layer in the active map _pointLayer = ActiveMapView.Map.GetLayersAsFlattenedList().OfType <FeatureLayer>(). Where(lyr => lyr.Name == "Police Stations").FirstOrDefault(); if (_pointLayer == null) { return; } // build the attribute dictionaries _attributesValid = new Dictionary <string, bool>(); _attributes = new Dictionary <string, object>(); // get the embedded control if (_attributeVM == null) { _attributeVM = this.EmbeddableControl as AttributeControlViewModel; } // these are the fields that we will collect values from the user var fieldNames = new List <string>() { "Precinct", "Address" }; // set up the inspector var inspector = new Inspector(); foreach (var fieldName in fieldNames) { // add the attribute ArcGIS.Desktop.Editing.Attributes.Attribute attr = await inspector.AddAttributeAsync(_pointLayer, fieldName, false); // set the validity to true _attributesValid.Add(fieldName, true); // add some validation - in this example we will make each field mandatory attr.AddValidate(() => { var errors = new List <ArcGIS.Desktop.Editing.Attributes.Attribute.ValidationError>(); if (string.IsNullOrWhiteSpace(attr.CurrentValue.ToString())) { // add an error errors.Add(ArcGIS.Desktop.Editing.Attributes.Attribute.ValidationError.Create("Value is mandatory", ArcGIS.Desktop.Editing.Attributes.Severity.High)); // set the validity to false _attributesValid[fieldName] = false; } else { // store the value if (!_attributes.ContainsKey(fieldName)) { _attributes.Add(fieldName, attr.CurrentValue); } else { _attributes[fieldName] = attr.CurrentValue; } // set the validity to true _attributesValid[fieldName] = true; } return(errors); }); } // create the embedded control and assign the view/viewmodel pair var tuple = inspector.CreateEmbeddableControl(); _attributeVM.InspectorViewModel = tuple.Item1; _attributeVM.InspectorView = tuple.Item2; }