1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Maps.MapControl.WPF;
using System.ComponentModel;
using System.Collections.ObjectModel;
namespace WPFTestApplication
{
class CustLocation:Location, INotifyPropertyChanged
{
private string cityName;
public string CityName
{
get { return cityName; }
set {
cityName = value; RaisePropertyChanged("CityName");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(string propName)
{
PropertyChangedEventHandler h = PropertyChanged;
if (h != null)
h(this, new PropertyChangedEventArgs(propName));
}
}
public class Area : INotifyPropertyChanged
{
public Area()
{
this.NameArea = string.Empty;
this.Locations = new LocationCollection();
}
private string nameArea;
public string NameArea
{
get { return nameArea; }
set {
nameArea = value; RaisePropertyChanged("NameArea");
}
}
private LocationCollection locations;
public LocationCollection Locations
{
get { return locations; }
set
{
locations = value; RaisePropertyChanged("Locations");
}
}
public event PropertyChangedEventHandler PropertyChanged;
private void RaisePropertyChanged(string propName)
{
PropertyChangedEventHandler h = PropertyChanged;
if (h != null)
h(this, new PropertyChangedEventArgs(propName));
}
}
public class Areas :ObservableCollection<Area>
{
private Area a;
public Areas()
{
LoadAreas();
}
private void LoadAreas()
{
a = new Area();
a.NameArea = "Cne-Mila-Eulma";
a.Locations = new LocationCollection(){
new CustLocation() { CityName="City1", Latitude = 36.351716 , Longitude = 6.603069 },
new CustLocation() { CityName="City2",Latitude = 36.451020 , Longitude = 6.264303 },
new CustLocation() { CityName="City3",Latitude = 36.151480, Longitude = 5.683351 }
};
this.Add(a);
a = new Area();
a.NameArea = "Setif-BBA-msila2";
a.Locations = new LocationCollection(){
new CustLocation() { CityName="City4", Latitude = 36.191113 , Longitude =5.414615 },
new CustLocation() { CityName="City5", Latitude = 36.072180 , Longitude = 4.758790 },
new CustLocation() { CityName="City6",Latitude = 35.703471 , Longitude = 4.547725 }
};
this.Add(a);
}
}
} |
Partager