|
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.Device.Location;
using System.ComponentModel;
using BikeInCity.Utils;
namespace BikeInCity.Model
{
public class BikeSituation : INotifyPropertyChanged
{
#region private fields
private ObservableCollection<BikeStation> _arrivalStations;
private ObservableCollection<BikeStation> _departureStations;
private BikeCoordinate _departure;
private BikeCoordinate _arrival;
private BikeRoute _currentRoute;
private BikeStation _currentStation;
private double _zoom;
#endregion
#region public properties
/// <summary>
/// Collection of stations near the arrival place
/// </summary>
public ObservableCollection<BikeStation> ArrivalStations
{
get
{
if (_arrivalStations == null)
{
_arrivalStations = new ObservableCollection<BikeStation>();
}
return _arrivalStations;
}
set
{
_arrivalStations = value;
OnPropertyChanged("ArrivalStations");
}
}
/// <summary>
/// Collection of stations near the departure place
/// </summary>
public ObservableCollection<BikeStation> DepartureStations
{
get
{
if (_departureStations == null)
{
_departureStations = new ObservableCollection<BikeStation>();
}
return _departureStations;
}
set
{
_departureStations = value;
OnPropertyChanged("DepartureStations");
}
}
/// <summary>
/// Location of the arival place. We have to ignore it because of the serialization problems of GeoCoordinate class.
/// </summary>
public BikeCoordinate Departure
{
get
{
return _departure;
}
set
{
_departure = value;
OnPropertyChanged("Departure");
}
}
/// <summary>
/// Location of the arival place.
/// </summary>
public BikeCoordinate Arrival
{
get
{
return _arrival;
}
set
{
_arrival = value;
OnPropertyChanged("Arrival");
}
}
/// <summary>
/// Current selected statio
/// </summary>
public BikeStation CurrentStation
{
get { return _currentStation; }
set
{
if (value != _currentStation)
{
_currentStation = value;
OnPropertyChanged("CurrentStation");
}
}
}
/// <summary>
/// Selected route
/// </summary>
public BikeRoute CurrentRoute
{
get
{
return _currentRoute;
}
set
{
if (_currentRoute != value)
{
_currentRoute = value;
OnPropertyChanged("CurrentRoute");
}
}
}
/// <summary>
/// Current zoom
/// </summary>
public double Zoom
{
get { return _zoom; }
set
{
var coercedZoom = Math.Max(BikeConst.MinZoomLevel, Math.Min(BikeConst.MaxZoomLevel, value));
if (_zoom != coercedZoom)
{
_zoom = value;
OnPropertyChanged("Zoom");
}
}
}
#endregion
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
protected virtual void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = this.PropertyChanged;
if (handler != null)
{
var e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
#endregion
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.