Mini Kabibi Habibi

Current Path : C:/Users/Public/Documents/DXperience 13.1 Demos/WPF/CS/MapDemo.Wpf/Modules/
Upload File :
Current File : C:/Users/Public/Documents/DXperience 13.1 Demos/WPF/CS/MapDemo.Wpf/Modules/DataBinding.xaml.cs

using System;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Xml.Linq;
using DevExpress.Xpf.Map;

namespace MapDemo {
    public class ShipInfo {
        public ShipInfo(double latitude, double longitude, string name, string description, int year) {
            this.Location = new GeoPoint(latitude, longitude);
            this.Name = name;
            this.Year = year;
            this.Description = description;
        }
        public GeoPoint Location { get; private set; }
        public string Name { get; private set; }
        public int Year { get; private set; }
        public string Description { get; private set; }
        public string Header { get { return Name + " (" + Year + ")"; } }
    }

    public partial class DataBinding : MapDemoModule {
        public ObservableCollection<ShipInfo> Ships { get; set; }

        public DataBinding() {
            InitializeComponent();
            infoGrid.DataContext = this;
            Ships = new ObservableCollection<ShipInfo>();
            LoadDataFromXML();
        }

        void LoadDataFromXML() {
            XDocument document = DataLoader.LoadXmlFromResources("/Data/Ships.xml");
            if (document != null) {
                foreach (XElement element in document.Element("Ships").Elements()) {
                    ShipInfo shipInfo = new ShipInfo(Convert.ToDouble(element.Element("Latitude").Value, CultureInfo.InvariantCulture),
                        Convert.ToDouble(element.Element("Longitude").Value, CultureInfo.InvariantCulture),
                        element.Element("Name").Value,
                        element.Element("Description").Value,
                        Convert.ToInt16(element.Element("Year").Value));
                    Ships.Add(shipInfo);
                }
            }
        }
    }
}