Exemplo n.º 1
0
        private void ShapefileConverter_ImportCompleted(object sender, AsyncCompletedEventArgs e)
        {
            var shapePoints        = GeoRegions.WorldFullRegion.ToPoints();
            var shapeOceansElement = new SelectableShapeElement
            {
                ShapeName  = "Other",
                ShapeLabel = "Oceans",
                IsSelected = true
            };

            shapeOceansElement.Points = new List <List <Point> > {
                shapePoints
            };
            this.RegionsViewModel.SelectableShapeElements.Add(shapeOceansElement);

            var shapefile = (ShapefileConverter)sender;

            foreach (var record in shapefile)
            {
                var shapeItem = new SelectableShapeElement();
                if (record.Fields != null)
                {
                    var regionName = record.Fields["REGION"] as string;
                    if (regionName == "NorthAfrica")
                    {
                        regionName = "Africa";
                    }
                    if (regionName == "Sub Saharan Africa")
                    {
                        regionName = "Africa";
                    }
                    if (regionName == "Pacific")
                    {
                        regionName = "Other";                          // "Other";
                    }
                    if (regionName == "Caribbean")
                    {
                        regionName = "North America";
                    }
                    if (regionName == "Latin America")
                    {
                        regionName = "South America";
                    }
                    if (regionName == null)
                    {
                        return;
                    }

                    shapeItem.Points     = record.Points;
                    shapeItem.Fields     = record.Fields;
                    shapeItem.ShapeLabel = regionName == "Other" ? "Oceans" : regionName;
                    shapeItem.ShapeName  = regionName;
                    shapeItem.IsSelected = IsSelectedRegion(shapeItem.ShapeName);

                    // add loaded shape records as Selectable Shape Elements to the view model
                    this.RegionsViewModel.SelectableShapeElements.Add(shapeItem);
                }
            }
            UpdateRegionFilter();
        }
Exemplo n.º 2
0
        private void OnShapeElementClicked(SelectableShapeElement shapeElement)
        {
            var isSelected = !IsSelectedRegion(shapeElement.ShapeName);

            if (_mvm != null)
            {
                foreach (var region in _mvm.Regions)
                {
                    if (region.Name == shapeElement.ShapeName)
                    {
                        region.IsSelected = isSelected;
                        //region.IsSelected = !region.IsSelected;
                    }
                }
            }
            if (_tvm != null)
            {
                foreach (var region in _tvm.Regions)
                {
                    if (region.Name == shapeElement.ShapeName)
                    {
                        region.IsSelected = isSelected;
                        //region.IsSelected = !region.IsSelected;
                    }
                }
            }
            UpdateRegionFilter();
        }
Exemplo n.º 3
0
 public void RemoveSelectedShapeElement(SelectableShapeElement selectedElement)
 {
     this.SelectedShapeElements.Remove(selectedElement);
 }
Exemplo n.º 4
0
 public void AddSelectedShapeElement(SelectableShapeElement element)
 {
     this.SelectedShapeElements.Add(element);
 }