Exemplo n.º 1
0
 public EditRegionViewModel(IEnumerable<Variety> varieties, Variety variety, GeographicRegion region)
 {
     _title = "Edit Region";
     _varieties = new ReadOnlyList<VarietyViewModel>(varieties.Select(v => new VarietyViewModel(v)).OrderBy(vm => vm.Name).ToArray());
     _selectedVariety = _varieties.First(vm => vm.DomainVariety == variety);
     _description = region.Description;
 }
Exemplo n.º 2
0
        private GeographicRegion LoadRegion(XElement polygon, string desc)
        {
            XElement coords = polygon.Elements(Kml + "outerBoundaryIs").Elements(Kml + "LinearRing").Elements(Kml + "coordinates").FirstOrDefault();
            if (coords == null || string.IsNullOrEmpty((string) coords))
                throw new ImportException(string.Format("A Polygon element does not contain coordinates. Line: {0}", ((IXmlLineInfo) polygon).LineNumber));

            var region = new GeographicRegion {Description = desc};
            string[] coordsArray = ((string) coords).Split().Where(coord => !string.IsNullOrEmpty(coord)).ToArray();
            for (int i = 0; i < coordsArray.Length - 1; i++)
            {
                string[] coordArray = coordsArray[i].Split(',');
                region.Coordinates.Add(new GeographicCoordinate(double.Parse(coordArray[1], CultureInfo.InvariantCulture), double.Parse(coordArray[0], CultureInfo.InvariantCulture)));
            }
            return region;
        }
Exemplo n.º 3
0
 private void AddNewRegion(IEnumerable<Tuple<double, double>> coordinates)
 {
     var vm = new EditRegionViewModel(_projectService.Project.Varieties);
     if (_dialogService.ShowModalDialog(this, vm) == true)
     {
         var region = new GeographicRegion(coordinates.Select(coord => new GeographicCoordinate(coord.Item1, coord.Item2))) {Description = vm.Description};
         vm.SelectedVariety.DomainVariety.Regions.Add(region);
         SelectedRegion = _varieties[vm.SelectedVariety.DomainVariety].Regions.Single(r => r.DomainRegion == region);
         Messenger.Default.Send(new DomainModelChangedMessage(false));
     }
 }