public FeatureGraphic(FeatureViewModel feature) { ViewModel = feature; if (feature.Geography != null) { this.Geometry = Mercator.FromGeographic(GeometryFromWKT.Parse(feature.Geography.Geography.WellKnownText)); } PropertyChanged += (sender, args) => { if (args.PropertyName == "Geometry") { if (Geometry != null) try { if (ViewModel.Geography == null) { ViewModel.Geography = new DbGeography() { Geography = new DbGeographyWellKnownValue() }; } ViewModel.Geography.Geography.CoordinateSystemId = 4326; ViewModel.Geography.Geography.WellKnownText = GeometryToWKT.Write(Mercator.ToGeographic(this.Geometry)); } catch (Exception) { } } }; }
public void MouseDown(IFeatureLayerViewModel sender, GraphicMouseButtonEventArgs e) { if (sender == null) { return; } var graphic = e.Graphic as FeatureGraphic; if (graphic == null) { return; } var vm = graphic.ViewModel; if (SelectedFeature != vm) { CancelActiveEdit(); SelectedFeature = vm; SelectedLayer = sender; vm.Graphic.Select(); GraphicEditor.StartEditEx(SelectedFeature.Graphic); ObjectEditor.Edit(SelectedFeature); } }
private void CleanUp() { SelectedFeature = null; SelectedLayer = null; }
public void Add(IFeatureLayerViewModel featureLayer) { var model = featureLayer as IFeatureLayerViewModel; if (model != null) { var view = model.GetView(); var layer = view as GraphicsLayer; if (layer != null) { CancelActiveEdit(); FeatureViewModel viewModel = model.NewFeature(); ObjectEditor.Edit(viewModel); GraphicEditor.Add(layer, viewModel.Graphic); SelectedFeature = viewModel; SelectedLayer = model; } } }