Merge branch 'release/#231' into develmaster

This commit is contained in:
stubbfel
2013-10-14 17:52:31 +02:00
4 changed files with 255 additions and 91 deletions

View File

@@ -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;
/// <summary>class of ExamsPage.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
@@ -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<Model.Exams.ExamListWp8Model>());
this.DefHeader.ProgressVisibility = Visibility.Visible;
Thread thread = new Thread(new ThreadStart(this.LoadingFeed));
thread.Start();
}
/// <summary>
@@ -88,6 +92,14 @@ namespace CampusAppWP8.Pages.Exams
#region private
/// <summary> Loading feed. </summary>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
private void LoadingFeed()
{
this.feed.LoadData(Utilities.GetLoadModus<Model.Exams.ExamListWp8Model>());
}
/// <summary>Method initialize the Feed.</summary>
/// <remarks>Stubbfel, 02.09.2013.</remarks>
private void InitializeFeed()
@@ -102,8 +114,14 @@ namespace CampusAppWP8.Pages.Exams
/// <remarks>Stubbfel, 02.09.2013.</remarks>
private void FeedIsReady()
{
this.SetupExamList();
this.DefHeader.ProgressVisibility = Visibility.Collapsed;
if (this.Dispatcher != null)
{
this.Dispatcher.BeginInvoke(new Action(() => this.SetupExamList()));
}
else
{
this.SetupExamList();
}
}
/// <summary>Executes the PDF reader operation.</summary>
@@ -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;
}
/// <summary>Calculates the selected index.</summary>
@@ -173,7 +192,14 @@ namespace CampusAppWP8.Pages.Exams
/// <remarks>Stubbfel, 02.09.2013.</remarks>
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
/// <remarks>Stubbfel, 02.09.2013.</remarks>
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;
}
}
/// <summary>Event handler. Called by Button for click events.</summary>

View File

@@ -19,6 +19,7 @@ namespace CampusAppWP8.Pages.Mensa
using CampusAppWPortalLib8.Model.Mensa;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using CampusAppWPortalLib8.Model.Settings;
/// <summary>
/// Class for the MensaPage
@@ -50,7 +51,7 @@ namespace CampusAppWP8.Pages.Mensa
/// <summary>
/// API for Localization
/// </summary>
private CampusSpsApi campusApi;
// private CampusSpsApi campusApi;
/// <summary>
/// Flag for forcing webLoad
@@ -129,7 +130,7 @@ namespace CampusAppWP8.Pages.Mensa
/// <summary>
/// Method will be execute if the SPSAPI is ready
/// </summary>
private void SpsApiIsReady()
/*private void SpsApiIsReady()
{
if (this.Dispatcher != null)
{
@@ -139,30 +140,56 @@ namespace CampusAppWP8.Pages.Mensa
{
this.InitializeFeed(this.campusApi.GetCampus());
}
}
}*/
/// <summary>
/// Method will be execute if the SPSAPI is failed
/// </summary>
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)));
}
}
}*/
/// <summary>
/// Method determine campus and load data from correct feed
/// </summary>
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();*/
}
/// <summary>
@@ -193,7 +220,7 @@ namespace CampusAppWP8.Pages.Mensa
/// </summary>
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
/// <summary> Event handler. Called by MenuItem for click events. </summary>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
/// <param name="sender"> button object. </param>
/// <param name="e"> Routed event information. </param>
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
FrameworkElement frameelement = sender as FrameworkElement;
@@ -396,5 +425,7 @@ namespace CampusAppWP8.Pages.Mensa
}
#endregion
#endregion
}
}

View File

@@ -1,36 +1,49 @@
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------
// <copyright file="Utilities.cs" company="BTU/IIT">
// Company copyright tag.
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
// </copyright>
// <author>fiedlchr</author>
// <sience>16.07.2013</sience>
//-----------------------------------------------------------------------------
// <author>Stubbfel</author>
// <date>14.10.2013</date>
// <summary>Implements the utilities class</summary>
//-----------------------------------------------------------------------
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;
/// <summary>
/// Collection of utility functions.
/// </summary>
/// <summary> Collection of utility functions. </summary>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
public static class Utilities
{
#region member
/// <summary> The north campus of cottbus. </summary>
private static GeoCoordinate northCB = new GeoCoordinate(51.77670359509875,14.293908825617);
/// <summary> The middle campus of cottbus. </summary>
private static GeoCoordinate midCB = new GeoCoordinate(51.76737987049448,14.324056352976152);
/// <summary> The south campus of cottbus. </summary>
private static GeoCoordinate southCB = new GeoCoordinate(51.72668339740452,14.319497377197282);
/// <summary> The middle campus of senftenberg. </summary>
private static GeoCoordinate midSFB = new GeoCoordinate(51.522217168257356,13.986618441187698);
#endregion
#region Enums
/// <summary>
/// Comparison types.
/// </summary>
/// <summary> Comparison types. </summary>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
public enum DifferenceType
{
/// <summary>
@@ -64,18 +77,18 @@ namespace CampusAppWP8.Utility
#region Method
/// <summary>
/// Compares the difference between a specified DateTime and Now
/// and the specified time difference (in Days).
/// <example>
/// 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 .
/// </example>
/// Compares the difference between a specified DateTime and Now and the specified time
/// difference (in Days).
/// </summary>
/// <param name="type">comparison type</param>
/// <param name="date">date to check</param>
/// <param name="totalDiff">difference to check</param>
/// <returns>true, if the comparison condition do not fail</returns>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
/// <param name="type"> comparison type. </param>
/// <param name="date"> date to check. </param>
/// <param name="totalDiff"> difference to check. </param>
/// <returns> true, if the comparison condition do not fail. </returns>
/// <example>
/// 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 .
/// </example>
public static bool DayDifference(DifferenceType type, DateTime date, double totalDiff)
{
bool retValue = false;
@@ -110,11 +123,12 @@ namespace CampusAppWP8.Utility
}
/// <summary>
/// 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.
/// </summary>
/// <param name="rootObj">root object</param>
/// <param name="elemName">name of the element(s)</param>
/// <returns>list of elements</returns>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
/// <param name="rootObj"> root object. </param>
/// <param name="elemName"> name of the element(s) </param>
/// <returns> list of elements. </returns>
public static List<DependencyObject> GetChild(DependencyObject rootObj, string elemName)
{
List<DependencyObject> retValue = new List<DependencyObject>();
@@ -136,14 +150,16 @@ namespace CampusAppWP8.Utility
return retValue;
}
/// <summary>
/// Return the element.
/// </summary>
/// <param name="rootObj"></param>
/// <param name="parentGridName"></param>
/// <param name="elemName"></param>
/// <param name="index"></param>
/// <returns></returns>
/// <summary> Return the element. </summary>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
/// <exception cref="IndexOutOfRangeException">
/// Thrown when the index is outside the required range.
/// </exception>
/// <param name="rootObj"> . </param>
/// <param name="parentGridName"> . </param>
/// <param name="elemName"> . </param>
/// <param name="index"> (Optional) </param>
/// <returns> The element. </returns>
public static FrameworkElement GetElement(DependencyObject rootObj, string parentGridName, string elemName, int index = 0)
{
List<DependencyObject> l = Utilities.GetChild(rootObj, parentGridName);
@@ -168,13 +184,16 @@ namespace CampusAppWP8.Utility
}
/// <summary>
/// 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.
/// </summary>
/// <param name="rootObj">root object</param>
/// <param name="parentGridName">name of the parent grid</param>
/// <param name="elemName">name of the UIElement</param>
/// <param name="vis">new visibility property state</param>
/// <param name="index">index of the element in the parent child list</param>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
/// <param name="rootObj"> root object. </param>
/// <param name="parentGridName"> name of the parent grid. </param>
/// <param name="elemName"> name of the UIElement. </param>
/// <param name="vis"> new visibility property state. </param>
/// <param name="index">
/// (Optional) index of the element in the parent child list.
/// </param>
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
}
/// <summary>
/// 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.
/// </summary>
/// <param name="rootObj">root object</param>
/// <param name="parentGridName">name of the parent grid</param>
/// <param name="elemName">name of the element</param>
/// <param name="index">index of the element in the child list of the parent</param>
/// <returns>visibility state</returns>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
/// <exception cref="NotImplementedException">
/// Thrown when the requested operation is unimplemented.
/// </exception>
/// <param name="rootObj"> root object. </param>
/// <param name="parentGridName"> name of the parent grid. </param>
/// <param name="elemName"> name of the element. </param>
/// <param name="index">
/// (Optional) index of the element in the child list of the parent.
/// </param>
/// <returns> visibility state. </returns>
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;
}
/// <summary>
/// Method determine the current position of the phone
/// </summary>
/// <returns>the position of the phone</returns>
/// <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()
{
if (!Settings.AppSetting.GeoWatchEnable)
@@ -240,19 +265,18 @@ namespace CampusAppWP8.Utility
return geoposition;
}
/// <summary>
/// Method set current positon to Zero
/// </summary>
/// <summary> Method set current positon to Zero. </summary>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
public static void SetGeoPositionToZero()
{
string time = DateTime.Now.Ticks.ToString();
string time = DateTime.Now.Ticks.ToString();
App.SaveToAppState<string>(Constants.GeoWatch_CurrentPosition_Lat, "0");
App.SaveToAppState<string>(Constants.GeoWatch_CurrentPosition_Long, "0");
App.SaveToAppState<string>(Constants.GeoWatch_CurrentPosition_Time, time);
}
/// <summary>
/// Method determine and store the current position of the phone
/// </summary>
/// <summary> Method determine and store the current position of the phone. </summary>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
public static void DetermineAndStoreCurrentPositionForce()
{
GeoPosition<GeoCoordinate> geoposition = Utilities.DetermineCurrentPosition();
@@ -276,8 +300,9 @@ namespace CampusAppWP8.Utility
}
/// <summary>
/// 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.
/// </summary>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
public static void DetermineAndStoreCurrentPosition()
{
string lat = App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Lat);
@@ -303,9 +328,12 @@ namespace CampusAppWP8.Utility
}
}
/// <summary>Query if the phone is in the uni network. Method compares only Network name and Description!</summary>
/// <remarks>Stubbfel, 26.08.2013.</remarks>
/// <returns>true if uni network is available, false if not.</returns>
/// <summary>
/// Query if the phone is in the uni network. Method compares only Network name and
/// Description!
/// </summary>
/// <remarks> Stubbfel, 26.08.2013. </remarks>
/// <returns> true if uni network is available, false if not. </returns>
public static bool IsUniNetworkAvailable()
{
NetworkInterfaceList networkInterfaceList = new NetworkInterfaceList();
@@ -324,9 +352,9 @@ namespace CampusAppWP8.Utility
return false;
}
/// <summary>Queries if a wifi is available.</summary>
/// <remarks>Stubbfel, 26.08.2013.</remarks>
/// <returns>true if a wifi is available, false if not.</returns>
/// <summary> Queries if a wifi is available. </summary>
/// <remarks> Stubbfel, 26.08.2013. </remarks>
/// <returns> true if a wifi is available, false if not. </returns>
public static bool IsWifiAvailable()
{
NetworkInterfaceList networkInterfaceList = new NetworkInterfaceList();
@@ -343,10 +371,10 @@ namespace CampusAppWP8.Utility
return false;
}
/// <summary>Gets load modus. Is check if the only Wifi option is active</summary>
/// <remarks>Stubbfel, 27.08.2013.</remarks>
/// <typeparam name="T">Generic type parameter.</typeparam>
/// <returns>The load modus&lt; t&gt;</returns>
/// <summary> Gets load modus. Is check if the only Wifi option is active. </summary>
/// <remarks> Stubbfel, 27.08.2013. </remarks>
/// <typeparam name="T"> Generic type parameter. </typeparam>
/// <returns> The load modus&lt; t&gt; </returns>
public static ForceType GetLoadModus<T>()
{
if (Settings.AppSetting.OnlyWifi && !Settings.AppSetting.WifiEnable)
@@ -359,7 +387,11 @@ namespace CampusAppWP8.Utility
}
}
public static bool IsRoomId(string placeId)
/// <summary> Query if 'placeId' is room identifier. </summary>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
/// <param name="placeId"> Identifier for the place. </param>
/// <returns> true if room identifier, false if not. </returns>
public static bool IsRoomId(string placeId)
{
if (Wp8StringManager.IsDigitsOnly(placeId) && placeId.Length > 7)
{
@@ -368,6 +400,71 @@ namespace CampusAppWP8.Utility
return false;
}
/// <summary> Gets the determined campus. </summary>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
/// <returns> The Campus. </returns>
public static Campus DetermineCampus()
{
Campus result = Campus.UserSettingCampus;
Utilities.DetermineAndStoreCurrentPosition();
double lat;
double log;
if (!double.TryParse(App.LoadFromAppState<string>(Constants.GeoWatch_CurrentPosition_Lat), NumberStyles.Number, CultureInfo.InvariantCulture, out lat)
|| !double.TryParse(App.LoadFromAppState<string>(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;
}
/// <summary> Calculates the distance. </summary>
/// <remarks> Stubbfel, 14.10.2013. </remarks>
/// <param name="src"> the source point. </param>
/// <param name="dst"> the destination Point. </param>
/// <returns> The calculated distance. </returns>
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
}
}

View File

@@ -11,6 +11,8 @@ namespace CampusAppWPortalLib8.Model.Settings
/// </summary>
public enum Campus
{
/// <summary> An enum constant representing the user setting campus option. </summary>
UserSettingCampus = 0,
/// <summary>
/// Cottbus -> MainCampus
/// </summary>