add accuracy paramter and save command
This commit is contained in:
@@ -171,11 +171,18 @@ namespace CampusAppWP8
|
||||
|
||||
if (Settings.AppSetting.GeoWatchEnable)
|
||||
{
|
||||
Thread thread = new Thread(new ThreadStart(Utilities.DetermineAndStoreCurrentPositionForce));
|
||||
Thread thread = new Thread(new ThreadStart(this.PositionThread));
|
||||
thread.Start();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Position thread. </summary>
|
||||
/// <remarks> Stubbfel, 18.11.2013. </remarks>
|
||||
private void PositionThread()
|
||||
{
|
||||
Utilities.DetermineAndStoreCurrentPositionForce();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Load the usersettings from the store
|
||||
/// </summary>
|
||||
|
||||
@@ -307,7 +307,7 @@ namespace CampusAppWP8.Pages
|
||||
if (result == MessageBoxResult.OK)
|
||||
{
|
||||
Settings.AppSetting.GeoWatchEnable = true;
|
||||
Thread thread = new Thread(new ThreadStart(Utilities.DetermineAndStoreCurrentPosition));
|
||||
Thread thread = new Thread(new ThreadStart(this.PositionThread));
|
||||
thread.Start();
|
||||
}
|
||||
else
|
||||
@@ -316,6 +316,13 @@ namespace CampusAppWP8.Pages
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Position thread. </summary>
|
||||
/// <remarks> Stubbfel, 18.11.2013. </remarks>
|
||||
private void PositionThread()
|
||||
{
|
||||
Utilities.DetermineAndStoreCurrentPosition();
|
||||
}
|
||||
|
||||
/// <summary> Event handler. Called by PintoStart for click events. </summary>
|
||||
/// <remarks> Stubbfel, 15.10.2013. </remarks>
|
||||
/// <param name="sender"> Caller of the function. </param>
|
||||
|
||||
@@ -63,8 +63,11 @@ namespace CampusAppWP8.Utility
|
||||
|
||||
if ((intVal >= 0) && (intParam >= 0))
|
||||
{
|
||||
PriceMealModel model = this.priceFeed.Model.GetCanteen(intParam).GetPriceMealModel(intVal);
|
||||
retValue = AppResources.Students + ": " + model.PriceStudentStr + " € " + AppResources.Employees + ": " + model.PriceEmployeeStr + " € " + AppResources.Guests + ": " + model.PriceGuestStr + " €";
|
||||
if (this.priceFeed != null && this.priceFeed.Model != null)
|
||||
{
|
||||
PriceMealModel model = this.priceFeed.Model.GetCanteen(intParam).GetPriceMealModel(intVal);
|
||||
retValue = AppResources.Students + ": " + model.PriceStudentStr + " € " + AppResources.Employees + ": " + model.PriceEmployeeStr + " € " + AppResources.Guests + ": " + model.PriceGuestStr + " €";
|
||||
}
|
||||
}
|
||||
|
||||
return retValue;
|
||||
@@ -85,6 +88,7 @@ namespace CampusAppWP8.Utility
|
||||
/// <remarks> Fiedler, 14.11.2013. </remarks>
|
||||
private void PriceFeedIsReady()
|
||||
{
|
||||
this.priceFeed.SaveData();
|
||||
}
|
||||
|
||||
/// <summary> Price feed is failed. </summary>
|
||||
|
||||
@@ -228,14 +228,14 @@ namespace CampusAppWP8.Utility
|
||||
/// <summary> Method determine the current position of the phone. </summary>
|
||||
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
||||
/// <returns> the position of the phone. </returns>
|
||||
public static GeoPosition<GeoCoordinate> DetermineCurrentPosition()
|
||||
public static GeoPosition<GeoCoordinate> DetermineCurrentPosition(GeoPositionAccuracy accuracy = GeoPositionAccuracy.High)
|
||||
{
|
||||
if (!Settings.AppSetting.GeoWatchEnable)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
|
||||
GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(accuracy);
|
||||
bool success = watcher.TryStart(false, TimeSpan.FromMilliseconds(10000));
|
||||
GeoPosition<GeoCoordinate> geoposition = null;
|
||||
if (success)
|
||||
@@ -263,9 +263,9 @@ namespace CampusAppWP8.Utility
|
||||
|
||||
/// <summary> Method determine and store the current position of the phone. </summary>
|
||||
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
||||
public static void DetermineAndStoreCurrentPositionForce()
|
||||
public static void DetermineAndStoreCurrentPositionForce(GeoPositionAccuracy accuracy = GeoPositionAccuracy.High)
|
||||
{
|
||||
GeoPosition<GeoCoordinate> geoposition = Utilities.DetermineCurrentPosition();
|
||||
GeoPosition<GeoCoordinate> geoposition = Utilities.DetermineCurrentPosition(accuracy);
|
||||
|
||||
if (geoposition != null)
|
||||
{
|
||||
@@ -285,19 +285,19 @@ namespace CampusAppWP8.Utility
|
||||
/// Method determine and store the current position of the phone, in 15 min interval.
|
||||
/// </summary>
|
||||
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
||||
public static void DetermineAndStoreCurrentPosition()
|
||||
public static void DetermineAndStoreCurrentPosition(GeoPositionAccuracy accuracy = GeoPositionAccuracy.High)
|
||||
{
|
||||
GeoMapPoint currentPoint = App.LoadFromAppState<GeoMapPoint>(Constants.GeoWatch_CurrentPositionPoint);
|
||||
if (currentPoint == null)
|
||||
{
|
||||
Utilities.DetermineAndStoreCurrentPositionForce();
|
||||
Utilities.DetermineAndStoreCurrentPositionForce(accuracy);
|
||||
}
|
||||
else
|
||||
{
|
||||
DateTime expired = new DateTime(currentPoint.Timestamp).AddMinutes(15);
|
||||
if (DateTime.Now.Ticks > expired.Ticks)
|
||||
{
|
||||
Utilities.DetermineAndStoreCurrentPositionForce();
|
||||
Utilities.DetermineAndStoreCurrentPositionForce(accuracy);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -378,16 +378,25 @@ namespace CampusAppWP8.Utility
|
||||
/// <summary> Gets the determined campus. </summary>
|
||||
/// <remarks> Stubbfel, 14.10.2013. </remarks>
|
||||
/// <returns> The Campus. </returns>
|
||||
public static Campus DetermineCampus()
|
||||
public static Campus DetermineCampus(GeoPositionAccuracy accuracy = GeoPositionAccuracy.Default)
|
||||
{
|
||||
Campus result = Campus.UserSettingCampus;
|
||||
|
||||
Utilities.DetermineAndStoreCurrentPosition();
|
||||
|
||||
Utilities.DetermineAndStoreCurrentPosition(accuracy);
|
||||
|
||||
MapPoint currentPoint = App.LoadFromAppState<GeoMapPoint>("CurrentGeoPoint");
|
||||
if (currentPoint == null)
|
||||
{
|
||||
return result;
|
||||
if (accuracy.Equals(GeoPositionAccuracy.High))
|
||||
{
|
||||
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return Utilities.DetermineCampus(GeoPositionAccuracy.High);
|
||||
}
|
||||
}
|
||||
|
||||
MapPoint tmpCampus = CampusMapPoints.NorthCB;
|
||||
|
||||
Reference in New Issue
Block a user