diff --git a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs
index 337b65d8..cf2c0e0a 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Exams/Exams.xaml.cs
@@ -16,6 +16,8 @@ namespace CampusAppWP8.Pages.Exams
using CampusAppWP8.Utility;
using CampusAppWP8.Utility.Lui.MessageBoxes;
using Microsoft.Phone.Controls;
+ using System.Threading;
+ using System;
/// class of ExamsPage.
/// Stubbfel, 02.09.2013.
@@ -41,7 +43,6 @@ namespace CampusAppWP8.Pages.Exams
this.BachelorItem.Header = CampusAppWPortalLib8.Resources.AppResources.Degree_Bachelor;
this.MasterItem.Header = CampusAppWPortalLib8.Resources.AppResources.Degree_Master;
this.DiplomItem.Header = CampusAppWPortalLib8.Resources.AppResources.Degree_Diploma;
- this.DefHeader.ProgressVisibility = Visibility.Visible;
this.InitializeFeed();
}
@@ -63,7 +64,10 @@ namespace CampusAppWP8.Pages.Exams
this.InitializeFeed();
}
- this.feed.LoadData(Utilities.GetLoadModus());
+ this.DefHeader.ProgressVisibility = Visibility.Visible;
+ Thread thread = new Thread(new ThreadStart(this.LoadingFeed));
+ thread.Start();
+
}
///
@@ -88,6 +92,14 @@ namespace CampusAppWP8.Pages.Exams
#region private
+ /// Loading feed.
+ /// Stubbfel, 14.10.2013.
+ private void LoadingFeed()
+ {
+ this.feed.LoadData(Utilities.GetLoadModus());
+ }
+
+
/// Method initialize the Feed.
/// Stubbfel, 02.09.2013.
private void InitializeFeed()
@@ -102,8 +114,14 @@ namespace CampusAppWP8.Pages.Exams
/// Stubbfel, 02.09.2013.
private void FeedIsReady()
{
- this.SetupExamList();
- this.DefHeader.ProgressVisibility = Visibility.Collapsed;
+ if (this.Dispatcher != null)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() => this.SetupExamList()));
+ }
+ else
+ {
+ this.SetupExamList();
+ }
}
/// Executes the PDF reader operation.
@@ -137,6 +155,7 @@ namespace CampusAppWP8.Pages.Exams
this.MasterPanel.ItemsSource = masterList;
this.DiplomaPanel.ItemsSource = diplomaList;
this.ExamPivot.SelectedIndex = this.CalcSelectedIndex();
+ this.DefHeader.ProgressVisibility = Visibility.Collapsed;
}
/// Calculates the selected index.
@@ -173,7 +192,14 @@ namespace CampusAppWP8.Pages.Exams
/// Stubbfel, 02.09.2013.
private void FeedIsFailWeb()
{
- MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb);
+ if (this.Dispatcher != null)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() => MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb)));
+ }
+ else
+ {
+ MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb);
+ }
this.feed.ForceReadFile();
}
@@ -181,8 +207,16 @@ namespace CampusAppWP8.Pages.Exams
/// Stubbfel, 02.09.2013.
private void FeedIsFailFile()
{
- MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile);
- this.DefHeader.ProgressVisibility = Visibility.Collapsed;
+ if (this.Dispatcher != null)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() => MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile)));
+ this.Dispatcher.BeginInvoke(new Action(() => this.DefHeader.ProgressVisibility = Visibility.Collapsed));
+ }
+ else
+ {
+ MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile);
+ this.DefHeader.ProgressVisibility = Visibility.Collapsed;
+ }
}
/// Event handler. Called by Button for click events.
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
index 2f0ddf64..0ee00176 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
@@ -19,6 +19,7 @@ namespace CampusAppWP8.Pages.Mensa
using CampusAppWPortalLib8.Model.Mensa;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
+ using CampusAppWPortalLib8.Model.Settings;
///
/// Class for the MensaPage
@@ -50,7 +51,7 @@ namespace CampusAppWP8.Pages.Mensa
///
/// API for Localization
///
- private CampusSpsApi campusApi;
+ // private CampusSpsApi campusApi;
///
/// Flag for forcing webLoad
@@ -129,7 +130,7 @@ namespace CampusAppWP8.Pages.Mensa
///
/// Method will be execute if the SPSAPI is ready
///
- private void SpsApiIsReady()
+ /*private void SpsApiIsReady()
{
if (this.Dispatcher != null)
{
@@ -139,30 +140,56 @@ namespace CampusAppWP8.Pages.Mensa
{
this.InitializeFeed(this.campusApi.GetCampus());
}
- }
+ }*/
///
/// Method will be execute if the SPSAPI is failed
///
- private void SpsApiIsFail()
+ /*private void SpsApiIsFail()
{
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorCampusLoc)));
this.Dispatcher.BeginInvoke(new Action(() => this.InitializeFeed(Settings.UserProfil.DefaultCampus)));
}
- }
+ }*/
///
/// Method determine campus and load data from correct feed
///
private void DeterminCurrentCampusAndLoadFeed()
{
- this.campusApi = new CampusSpsApi();
+ Campus mensaCampus = Utilities.DetermineCampus();
+
+ if (this.Dispatcher != null)
+ {
+ if (mensaCampus == Campus.UserSettingCampus)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() => this.InitializeFeed(Settings.UserProfil.DefaultCampus)));
+ }
+ else
+ {
+ this.Dispatcher.BeginInvoke(new Action(() => this.InitializeFeed(mensaCampus)));
+ }
+
+ }
+ else
+ {
+ if (mensaCampus == Campus.UserSettingCampus)
+ {
+ this.InitializeFeed(Settings.UserProfil.DefaultCampus);
+ }
+ else
+ {
+ this.InitializeFeed(mensaCampus);
+ }
+ }
+
+ /* this.campusApi = new CampusSpsApi();
this.campusApi.OnLoaded += new SpsApi.OnIO(this.SpsApiIsReady);
this.campusApi.OnFailedLoad += new SpsApi.OnFailed(this.SpsApiIsFail);
this.campusApi.SetupCurrentCampusRequest();
- this.campusApi.LoadData();
+ this.campusApi.LoadData();*/
}
///
@@ -193,7 +220,7 @@ namespace CampusAppWP8.Pages.Mensa
///
private void InitializeFeed()
{
- if (Settings.AppSetting.GeoWatchEnable && Settings.AppSetting.UniNetwork)
+ if (Settings.AppSetting.GeoWatchEnable)
{
Thread thread = new Thread(new ThreadStart(this.DeterminCurrentCampusAndLoadFeed));
thread.Start();
@@ -382,8 +409,10 @@ namespace CampusAppWP8.Pages.Mensa
}
}
- #endregion
-
+ /// Event handler. Called by MenuItem for click events.
+ /// Stubbfel, 14.10.2013.
+ /// button object.
+ /// Routed event information.
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
FrameworkElement frameelement = sender as FrameworkElement;
@@ -396,5 +425,7 @@ namespace CampusAppWP8.Pages.Mensa
}
#endregion
+
+ #endregion
}
}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
index 5982d25f..da03d882 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs
@@ -1,36 +1,49 @@
-//-----------------------------------------------------------------------------
+//-----------------------------------------------------------------------
//
-// Company copyright tag.
+// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
//
-// fiedlchr
-// 16.07.2013
-//-----------------------------------------------------------------------------
+// Stubbfel
+// 14.10.2013
+// Implements the utilities class
+//-----------------------------------------------------------------------
namespace CampusAppWP8.Utility
{
using System;
using System.Collections.Generic;
using System.Device.Location;
using System.Globalization;
- using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using CampusAppWP8.Resources;
- using Microsoft.Phone.Net.NetworkInformation;
- using CampusAppWPortalLib8.Utility;
using CampusAppWPortalLib8.Model;
- using Microsoft.Phone.Shell;
+ using CampusAppWPortalLib8.Model.Settings;
+ using CampusAppWPortalLib8.Utility;
+ using Microsoft.Phone.Net.NetworkInformation;
- ///
- /// Collection of utility functions.
- ///
+ /// Collection of utility functions.
+ /// Stubbfel, 14.10.2013.
public static class Utilities
{
+ #region member
+
+ /// The north campus of cottbus.
+ private static GeoCoordinate northCB = new GeoCoordinate(51.77670359509875,14.293908825617);
+
+ /// The middle campus of cottbus.
+ private static GeoCoordinate midCB = new GeoCoordinate(51.76737987049448,14.324056352976152);
+
+ /// The south campus of cottbus.
+ private static GeoCoordinate southCB = new GeoCoordinate(51.72668339740452,14.319497377197282);
+
+ /// The middle campus of senftenberg.
+ private static GeoCoordinate midSFB = new GeoCoordinate(51.522217168257356,13.986618441187698);
+
+ #endregion
#region Enums
- ///
- /// Comparison types.
- ///
+ /// Comparison types.
+ /// Stubbfel, 14.10.2013.
public enum DifferenceType
{
///
@@ -64,18 +77,18 @@ namespace CampusAppWP8.Utility
#region Method
///
- /// Compares the difference between a specified DateTime and Now
- /// and the specified time difference (in Days).
- ///
- /// When type is DifferenceType.Less, the timespan between Now and date
- /// is 5.0 (days) and totalDiff is 7.0, the function will return true,
- /// because the timespan is Less then 7.0 .
- ///
+ /// Compares the difference between a specified DateTime and Now and the specified time
+ /// difference (in Days).
///
- /// comparison type
- /// date to check
- /// difference to check
- /// true, if the comparison condition do not fail
+ /// Stubbfel, 14.10.2013.
+ /// comparison type.
+ /// date to check.
+ /// difference to check.
+ /// true, if the comparison condition do not fail.
+ ///
+ /// When type is DifferenceType.Less, the timespan between Now and date is 5.0 (days) and
+ /// totalDiff is 7.0, the function will return true, because the timespan is Less then 7.0 .
+ ///
public static bool DayDifference(DifferenceType type, DateTime date, double totalDiff)
{
bool retValue = false;
@@ -110,11 +123,12 @@ namespace CampusAppWP8.Utility
}
///
- /// Return a list of child UIElements of the root object with the specified element name.
+ /// Return a list of child UIElements of the root object with the specified element name.
///
- /// root object
- /// name of the element(s)
- /// list of elements
+ /// Stubbfel, 14.10.2013.
+ /// root object.
+ /// name of the element(s)
+ /// list of elements.
public static List GetChild(DependencyObject rootObj, string elemName)
{
List retValue = new List();
@@ -136,14 +150,16 @@ namespace CampusAppWP8.Utility
return retValue;
}
- ///
- /// Return the element.
- ///
- ///
- ///
- ///
- ///
- ///
+ /// Return the element.
+ /// Stubbfel, 14.10.2013.
+ ///
+ /// Thrown when the index is outside the required range.
+ ///
+ /// .
+ /// .
+ /// .
+ /// (Optional)
+ /// The element.
public static FrameworkElement GetElement(DependencyObject rootObj, string parentGridName, string elemName, int index = 0)
{
List l = Utilities.GetChild(rootObj, parentGridName);
@@ -168,13 +184,16 @@ namespace CampusAppWP8.Utility
}
///
- /// Search for a UIElement with the specified name in the parent Grid and set its visibility.
+ /// Search for a UIElement with the specified name in the parent Grid and set its visibility.
///
- /// root object
- /// name of the parent grid
- /// name of the UIElement
- /// new visibility property state
- /// index of the element in the parent child list
+ /// Stubbfel, 14.10.2013.
+ /// root object.
+ /// name of the parent grid.
+ /// name of the UIElement.
+ /// new visibility property state.
+ ///
+ /// (Optional) index of the element in the parent child list.
+ ///
public static void SetElementVisibility(DependencyObject rootObj, string parentGridName, string elemName, Visibility vis, int index = 0)
{
FrameworkElement elem = GetElement(rootObj, parentGridName, elemName, index);
@@ -186,18 +205,25 @@ namespace CampusAppWP8.Utility
}
///
- /// Return the visibility property of a UIElement which is a child object of the specified parent grid element.
+ /// Return the visibility property of a UIElement which is a child object of the specified
+ /// parent grid element.
///
- /// root object
- /// name of the parent grid
- /// name of the element
- /// index of the element in the child list of the parent
- /// visibility state
+ /// Stubbfel, 14.10.2013.
+ ///
+ /// Thrown when the requested operation is unimplemented.
+ ///
+ /// root object.
+ /// name of the parent grid.
+ /// name of the element.
+ ///
+ /// (Optional) index of the element in the child list of the parent.
+ ///
+ /// visibility state.
public static Visibility GetElementVisibility(DependencyObject rootObj, string parentGridName, string elemName, int index = 0)
{
Visibility retValue;
FrameworkElement elem = GetElement(rootObj, parentGridName, elemName, index);
-
+
if (elem != null)
{
retValue = elem.Visibility;
@@ -210,10 +236,9 @@ namespace CampusAppWP8.Utility
return retValue;
}
- ///
- /// Method determine the current position of the phone
- ///
- /// the position of the phone
+ /// Method determine the current position of the phone.
+ /// Stubbfel, 14.10.2013.
+ /// the position of the phone.
public static GeoPosition DetermineCurrentPosition()
{
if (!Settings.AppSetting.GeoWatchEnable)
@@ -240,19 +265,18 @@ namespace CampusAppWP8.Utility
return geoposition;
}
- ///
- /// Method set current positon to Zero
- ///
+ /// Method set current positon to Zero.
+ /// Stubbfel, 14.10.2013.
public static void SetGeoPositionToZero()
{
- string time = DateTime.Now.Ticks.ToString();
+ string time = DateTime.Now.Ticks.ToString();
App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Lat, "0");
App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Long, "0");
App.SaveToAppState(Constants.GeoWatch_CurrentPosition_Time, time);
}
- ///
- /// Method determine and store the current position of the phone
- ///
+
+ /// Method determine and store the current position of the phone.
+ /// Stubbfel, 14.10.2013.
public static void DetermineAndStoreCurrentPositionForce()
{
GeoPosition geoposition = Utilities.DetermineCurrentPosition();
@@ -276,8 +300,9 @@ namespace CampusAppWP8.Utility
}
///
- /// Method determine and store the current position of the phone, in 15 min interval
+ /// Method determine and store the current position of the phone, in 15 min interval.
///
+ /// Stubbfel, 14.10.2013.
public static void DetermineAndStoreCurrentPosition()
{
string lat = App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Lat);
@@ -303,9 +328,12 @@ namespace CampusAppWP8.Utility
}
}
- /// Query if the phone is in the uni network. Method compares only Network name and Description!
- /// Stubbfel, 26.08.2013.
- /// true if uni network is available, false if not.
+ ///
+ /// Query if the phone is in the uni network. Method compares only Network name and
+ /// Description!
+ ///
+ /// Stubbfel, 26.08.2013.
+ /// true if uni network is available, false if not.
public static bool IsUniNetworkAvailable()
{
NetworkInterfaceList networkInterfaceList = new NetworkInterfaceList();
@@ -324,9 +352,9 @@ namespace CampusAppWP8.Utility
return false;
}
- /// Queries if a wifi is available.
- /// Stubbfel, 26.08.2013.
- /// true if a wifi is available, false if not.
+ /// Queries if a wifi is available.
+ /// Stubbfel, 26.08.2013.
+ /// true if a wifi is available, false if not.
public static bool IsWifiAvailable()
{
NetworkInterfaceList networkInterfaceList = new NetworkInterfaceList();
@@ -343,10 +371,10 @@ namespace CampusAppWP8.Utility
return false;
}
- /// Gets load modus. Is check if the only Wifi option is active
- /// Stubbfel, 27.08.2013.
- /// Generic type parameter.
- /// The load modus< t>
+ /// Gets load modus. Is check if the only Wifi option is active.
+ /// Stubbfel, 27.08.2013.
+ /// Generic type parameter.
+ /// The load modus< t>
public static ForceType GetLoadModus()
{
if (Settings.AppSetting.OnlyWifi && !Settings.AppSetting.WifiEnable)
@@ -359,7 +387,11 @@ namespace CampusAppWP8.Utility
}
}
- public static bool IsRoomId(string placeId)
+ /// Query if 'placeId' is room identifier.
+ /// Stubbfel, 14.10.2013.
+ /// Identifier for the place.
+ /// true if room identifier, false if not.
+ public static bool IsRoomId(string placeId)
{
if (Wp8StringManager.IsDigitsOnly(placeId) && placeId.Length > 7)
{
@@ -368,6 +400,71 @@ namespace CampusAppWP8.Utility
return false;
}
+ /// Gets the determined campus.
+ /// Stubbfel, 14.10.2013.
+ /// The Campus.
+ public static Campus DetermineCampus()
+ {
+ Campus result = Campus.UserSettingCampus;
+
+ Utilities.DetermineAndStoreCurrentPosition();
+ double lat;
+ double log;
+ if (!double.TryParse(App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Lat), NumberStyles.Number, CultureInfo.InvariantCulture, out lat)
+ || !double.TryParse(App.LoadFromAppState(Constants.GeoWatch_CurrentPosition_Long), NumberStyles.Number, CultureInfo.InvariantCulture, out log))
+ {
+ return result;
+ }
+
+ Point currentPoint = new Point(log, lat);
+
+
+ double minDistance = Utilities.CalcDistance(currentPoint, new Point(Utilities.northCB.Longitude, Utilities.northCB.Latitude));
+
+ if (minDistance < 0.01)
+ {
+ result = Campus.CB_NORTH;
+ }
+ double tmpDistance = Utilities.CalcDistance(currentPoint, new Point(Utilities.midCB.Longitude, Utilities.midCB.Latitude));
+
+ if (tmpDistance < 0.01 && tmpDistance < minDistance)
+ {
+ minDistance = tmpDistance;
+ result = Campus.CB_MAIN;
+ }
+
+ tmpDistance = Utilities.CalcDistance(currentPoint, new Point(Utilities.southCB.Longitude, Utilities.southCB.Latitude));
+
+ if (tmpDistance < 0.01 && tmpDistance < minDistance)
+ {
+ minDistance = tmpDistance;
+ result = Campus.CB_SOUTH;
+ }
+
+ tmpDistance = Utilities.CalcDistance(currentPoint, new Point(Utilities.midSFB.Longitude, Utilities.midSFB.Latitude));
+
+ if (tmpDistance < 0.01 && tmpDistance < minDistance)
+ {
+ minDistance = tmpDistance;
+ result = Campus.SFB_MAIN;
+ }
+
+ return result;
+ }
+
+ /// Calculates the distance.
+ /// Stubbfel, 14.10.2013.
+ /// the source point.
+ /// the destination Point.
+ /// The calculated distance.
+ public static double CalcDistance(Point src, Point dst)
+ {
+ double xPow = Math.Pow(dst.X - src.X, 2);
+ double yPow = Math.Pow(dst.Y - src.Y, 2);
+ double result = Math.Sqrt(xPow + yPow);
+ return Math.Sqrt(Math.Pow(dst.X - src.X, 2) + Math.Pow(dst.Y - src.Y, 2));
+ }
+
#endregion
}
}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Settings/CampusTypes.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Settings/CampusTypes.cs
index 950f2490..dee8c063 100644
--- a/CampusAppWP8/CampusAppWPortalLib8/Model/Settings/CampusTypes.cs
+++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Settings/CampusTypes.cs
@@ -11,6 +11,8 @@ namespace CampusAppWPortalLib8.Model.Settings
///
public enum Campus
{
+ /// An enum constant representing the user setting campus option.
+ UserSettingCampus = 0,
///
/// Cottbus -> MainCampus
///