diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
index c4b29600..43b27b8b 100644
--- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
+++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
@@ -102,6 +102,7 @@
App.xaml
+
@@ -255,6 +256,7 @@
WeekViewDay.xaml
+
NFC.xaml
diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/PriceFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/PriceFeed.cs
new file mode 100644
index 00000000..a5380621
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/PriceFeed.cs
@@ -0,0 +1,82 @@
+//-----------------------------------------------------------------------
+//
+// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
+//
+// Fiedler
+// 13.11.2013
+// Implements the price feed class
+//-----------------------------------------------------------------------
+namespace CampusAppWP8.Feed.Mensa
+{
+ using System;
+ using System.IO;
+ using CampusAppWP8.Model;
+ using CampusAppWP8.Resources;
+ using CampusAppWPortalLib8.Model.Mensa;
+ using CampusAppWPortalLib8.Model;
+
+ /// A price feed.
+ /// Fiedler, 13.11.2013.
+ ///
+ public class PriceFeed : XmlModel
+ {
+ /// Initializes a new instance of the PriceFeed class.
+ /// Fiedler, 13.11.2013.
+ public PriceFeed()
+ : base(ModelType.FileAndFeed, Constants.FileMensaPrice, Constants.UrlMensaPrice)
+ {
+ this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate);
+ this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
+ this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate);
+ }
+
+ /// Check is model up to date.
+ /// Fiedler, 13.11.2013.
+ /// The model.
+ /// true if it succeeds, false if it fails.
+ private bool CheckIsModelUpToDate(PriceModel model)
+ {
+ bool retValue = true;
+
+ if (model == null)
+ {
+ retValue = false;
+ }
+
+ return retValue;
+ }
+
+ /// Check is file up to date.
+ /// Fiedler, 13.11.2013.
+ /// The model.
+ /// Information describing the file.
+ /// true if it succeeds, false if it fails.
+ private bool CheckIsFileUpToDate(PriceModel model, FileInfo fileInfo)
+ {
+ if (fileInfo == null || !fileInfo.Exists || fileInfo.Length < 1)
+ {
+ return false;
+ }
+
+ return this.CheckIsUpToDate(fileInfo.LastWriteTime);
+ }
+
+ /// Check is up to date.
+ /// Fiedler, 13.11.2013.
+ /// The last modified Date/Time.
+ /// true if it succeeds, false if it fails.
+ private bool CheckIsUpToDate(DateTime lastModified)
+ {
+ bool retValue = false;
+ TimeSpan diff = DateTime.Now.Subtract(lastModified);
+
+
+ if (diff.TotalDays < 7)
+ {
+ retValue = true;
+ }
+
+ return retValue;
+ }
+ }
+}
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml
index 6377d8db..ac82d84d 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml
@@ -10,12 +10,19 @@
xmlns:header="clr-namespace:CampusAppWP8.Utility.Lui.Header"
xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
xmlns:page="clr-namespace:CampusAppWP8.Utility.Lui.Page"
+ xmlns:utility="clr-namespace:CampusAppWP8.Utility"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
- shell:SystemTray.IsVisible="True">
+ shell:SystemTray.IsVisible="True"
+ x:Name="root">
+
+
+
+
+
@@ -44,18 +51,27 @@
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
index 376a77a4..73cd21d2 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs
@@ -48,6 +48,8 @@ namespace CampusAppWP8.Pages.Mensa
/// Flag for forcing webLoad.
private bool forceLoad = false;
+ public int LocationID { get; set; }
+
#endregion
#region Constructor
@@ -56,6 +58,8 @@ namespace CampusAppWP8.Pages.Mensa
/// Stubbfel, 15.10.2013.
public MensaPage()
{
+ this.LocationID = 0;
+
this.InitializeComponent();
ApplicationBarMenuItem menuItem1 = ApplicationBar.MenuItems[0] as ApplicationBarMenuItem;
ApplicationBarMenuItem menuItem2 = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem;
@@ -341,6 +345,7 @@ namespace CampusAppWP8.Pages.Mensa
/// Event information.
private void ApplicationBarMenuItem_Click(object sender, EventArgs e)
{
+ this.LocationID = 0;
this.DefHeader.ProgressVisibility = Visibility.Visible;
this.InitializeFeed(CampusAppWPortalLib8.Model.Settings.Campus.CB_MAIN);
}
@@ -351,6 +356,7 @@ namespace CampusAppWP8.Pages.Mensa
/// Event information.
private void ApplicationBarMenuItem2_Click(object sender, EventArgs e)
{
+ this.LocationID = 1;
this.DefHeader.ProgressVisibility = Visibility.Visible;
this.InitializeFeed(CampusAppWPortalLib8.Model.Settings.Campus.CB_SOUTH);
}
@@ -361,6 +367,7 @@ namespace CampusAppWP8.Pages.Mensa
/// Event information.
private void ApplicationBarMenuItem3_Click(object sender, EventArgs e)
{
+ this.LocationID = 2;
this.DefHeader.ProgressVisibility = Visibility.Visible;
this.InitializeFeed(CampusAppWPortalLib8.Model.Settings.Campus.SFB_MAIN);
}
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
index 74dd8ca7..4470f195 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
+++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx
@@ -594,4 +594,10 @@
CurrentPositionPoint
+
+ mensaprice.xml
+
+
+ http://www.tu-cottbus.de/campusapp-data/canteens.php?v=1
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs
index f290ade3..372a03ba 100644
--- a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs
+++ b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs
@@ -375,6 +375,15 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die mensaprice.xml ähnelt.
+ ///
+ public static string FileMensaPrice {
+ get {
+ return ResourceManager.GetString("FileMensaPrice", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die NewsFeed.xml ähnelt.
///
@@ -1356,6 +1365,15 @@ namespace CampusAppWP8.Resources {
}
}
+ ///
+ /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/canteens.php?v=1 ähnelt.
+ ///
+ public static string UrlMensaPrice {
+ get {
+ return ResourceManager.GetString("UrlMensaPrice", resourceCulture);
+ }
+ }
+
///
/// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/openinghours.php?v=2 ähnelt.
///
diff --git a/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs
index 4c57f4e7..07a8dd99 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs
@@ -26,8 +26,8 @@ namespace CampusAppWP8.Utility
public IdToPlaceConverter()
{
this.placeFile = new PlacesFile();
- this.placeFile.OnLoaded += new PlacesFile.OnIO(this.PlaceFileIsReady);
- this.placeFile.OnFailedLoad += new PlacesFile.OnFailed(this.PlaceFileIsFailed);
+ this.placeFile.OnLoaded += this.PlaceFileIsReady;
+ this.placeFile.OnFailedLoad += this.PlaceFileIsFailed;
this.placeFile.LoadData();
}
diff --git a/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs
new file mode 100644
index 00000000..5adfdb57
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs
@@ -0,0 +1,46 @@
+namespace CampusAppWP8.Utility
+{
+ using System;
+ using System.Windows.Data;
+ using CampusAppWP8.Feed.Mensa;
+ using CampusAppWPortalLib8.Model.GeoDb;
+
+ public sealed class MealIdToPriceConverter : IValueConverter
+ {
+ private PriceFeed priceFeed = null;
+
+ public MealIdToPriceConverter()
+ {
+ this.priceFeed = new PriceFeed();
+ this.priceFeed.OnLoaded += this.PriceFeedIsReady;
+ this.priceFeed.OnFailedLoad += this.PriceFeedIsFailed;
+ this.priceFeed.LoadData();
+ }
+
+
+ public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo language)
+ {
+ string retValue = string.Empty;
+
+ if ((parameter is int) && (value is int))
+ {
+ retValue = this.priceFeed.Model.GetCanteen((int)value).GetPriceMealModel((int)parameter).PriceString();
+ }
+
+ return retValue;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo language)
+ {
+ return null;
+ }
+
+ private void PriceFeedIsReady()
+ {
+ }
+
+ private void PriceFeedIsFailed()
+ {
+ }
+ }
+}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj
index 4826570b..addae01f 100644
--- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj
+++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj
@@ -62,6 +62,9 @@
+
+
+
diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceCanteenModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceCanteenModel.cs
new file mode 100644
index 00000000..26d6c5c3
--- /dev/null
+++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceCanteenModel.cs
@@ -0,0 +1,185 @@
+//-----------------------------------------------------------------------
+//
+// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
+//
+// Fiedler
+// 13.11.2013
+// Implements the price canteen model class
+//-----------------------------------------------------------------------
+namespace CampusAppWPortalLib8.Model.Mensa
+{
+ using System.Collections.ObjectModel;
+ using System.Xml.Serialization;
+ using CampusAppWPortalLib8.Model.Utility;
+
+ /// A data Model for the price canteen.
+ /// Fiedler, 13.11.2013.
+ public class PriceCanteenModel
+ {
+ /// The identifier.
+ private int id = -1;
+ /// The name de.
+ private string name_de = string.Empty;
+ /// URL of the name.
+ private string name_url = string.Empty;
+ /// The position.
+ private MapPoint pos = null;
+ /// List of prices.
+ private ObservableCollection priceList = null;
+
+ /// Initializes a new instance of the PriceCanteenModel class.
+ /// Fiedler, 13.11.2013.
+ public PriceCanteenModel()
+ {
+ this.pos = new MapPoint(-1, -1);
+ this.priceList = new ObservableCollection();
+ }
+
+ /// Gets or sets the identifier.
+ /// The identifier.
+ [XmlAttribute("id")]
+ public string IdStr
+ {
+ get
+ {
+ return string.Empty + this.id;
+ }
+
+ set
+ {
+ this.id = int.Parse(value);
+ }
+ }
+
+ /// Gets or sets the identifier.
+ /// The identifier.
+ [XmlIgnore]
+ public int Id
+ {
+ get
+ {
+ return this.id;
+ }
+
+ set
+ {
+ this.id = value;
+ }
+ }
+
+ /// Gets or sets the name.
+ /// The name.
+ [XmlAttribute("name_de")]
+ public string Name
+ {
+ get
+ {
+ return this.name_de;
+ }
+
+ set
+ {
+ this.name_de = value;
+ }
+ }
+
+ /// Gets or sets URL of the document.
+ /// The URL.
+ [XmlAttribute("name_url")]
+ public string Url
+ {
+ get
+ {
+ return this.name_url;
+ }
+
+ set
+ {
+ this.name_url = value;
+ }
+ }
+
+ /// Gets or sets the x coordinate.
+ /// The x coordinate.
+ [XmlAttribute("x")]
+ public string X
+ {
+ get
+ {
+ return string.Empty + this.pos.X;
+ }
+
+ set
+ {
+ this.pos.X = double.Parse(value);
+ }
+ }
+
+ /// Gets or sets the y coordinate.
+ /// The y coordinate.
+ [XmlAttribute("y")]
+ public string Y
+ {
+ get
+ {
+ return string.Empty + this.pos.Y;
+ }
+
+ set
+ {
+ this.pos.Y = double.Parse(value);
+ }
+ }
+
+ /// Gets or sets the position.
+ /// The position.
+ [XmlIgnore]
+ public MapPoint Position
+ {
+ get
+ {
+ return this.pos;
+ }
+
+ set
+ {
+ this.pos = value;
+ }
+ }
+
+ /// Gets or sets the prices.
+ /// The prices.
+ [XmlElement("price")]
+ public ObservableCollection Prices
+ {
+ get
+ {
+ return this.priceList;
+ }
+
+ set
+ {
+ this.priceList = value;
+ }
+ }
+
+ /// Gets price meal model.
+ /// Fiedler, 13.11.2013.
+ /// Identifier for the meal.
+ /// The price meal model.
+ public PriceMealModel GetPriceMealModel(int meal_id)
+ {
+ PriceMealModel retValue = null;
+
+ for (int i = 0; i < this.priceList.Count; i++)
+ {
+ if (this.priceList[i].MealID.Equals(meal_id))
+ {
+ retValue = this.priceList[i];
+ }
+ }
+
+ return retValue;
+ }
+ }
+}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs
new file mode 100644
index 00000000..ff3a2526
--- /dev/null
+++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs
@@ -0,0 +1,172 @@
+//-----------------------------------------------------------------------
+//
+// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
+//
+// Fiedler
+// 13.11.2013
+// Implements the price meal model class
+//-----------------------------------------------------------------------
+namespace CampusAppWPortalLib8.Model.Mensa
+{
+ using System.Xml.Serialization;
+
+ /// A data Model for the price meal.
+ /// Fiedler, 13.11.2013.
+ public class PriceMealModel
+ {
+ /// Identifier for the meal.
+ private int meal_id = -1;
+ /// The price student.
+ private double priceStudent = 0;
+ /// The price employee.
+ private double priceEmployee = 0;
+ /// The price guest.
+ private double priceGuest = 0;
+
+ /// Initializes a new instance of the PriceMealModel class.
+ /// Fiedler, 13.11.2013.
+ public PriceMealModel()
+ {
+ }
+
+ /// Gets or sets the identifier of the meal.
+ /// The identifier of the meal.
+ [XmlAttribute("meal_id")]
+ public string MealIDStr
+ {
+ get
+ {
+ return string.Empty + this.meal_id;
+ }
+
+ set
+ {
+ this.meal_id = int.Parse(value);
+ }
+ }
+
+ /// Gets or sets the identifier of the meal.
+ /// The identifier of the meal.
+ [XmlIgnore]
+ public int MealID
+ {
+ get
+ {
+ return this.meal_id;
+ }
+
+ set
+ {
+ this.meal_id = value;
+ }
+ }
+
+ /// Gets or sets the price student.
+ /// The price student.
+ [XmlAttribute("s")]
+ public string PriceStudentStr
+ {
+ get
+ {
+ return string.Format("{0:0.00}", this.priceStudent);
+ }
+
+ set
+ {
+ this.priceStudent = double.Parse(value);
+ }
+ }
+
+ /// Gets or sets the price student.
+ /// The price student.
+ [XmlIgnore]
+ public double PriceStudent
+ {
+ get
+ {
+ return this.priceStudent;
+ }
+
+ set
+ {
+ this.priceStudent = value;
+ }
+ }
+
+ /// Gets or sets the price employee.
+ /// The price employee.
+ [XmlAttribute("e")]
+ public string PriceEmployeeStr
+ {
+ get
+ {
+ return string.Format("{0:00.0}", this.priceEmployee);
+ }
+
+ set
+ {
+ this.priceEmployee = double.Parse(value);
+ }
+ }
+
+ /// Gets or sets the price employee.
+ /// The price employee.
+ [XmlIgnore]
+ public double PriceEmployee
+ {
+ get
+ {
+ return this.priceEmployee;
+ }
+
+ set
+ {
+ this.priceEmployee = value;
+ }
+ }
+
+ /// Gets or sets the price guest.
+ /// The price guest.
+ [XmlAttribute("g")]
+ public string PriceGuestStr
+ {
+ get
+ {
+ return string.Format("{0:00.0}", this.priceGuest);
+ }
+
+ set
+ {
+ this.priceGuest = double.Parse(value);
+ }
+ }
+
+ /// Gets or sets the price guest.
+ /// The price guest.
+ [XmlIgnore]
+ public double PriceGuest
+ {
+ get
+ {
+ return this.priceGuest;
+ }
+
+ set
+ {
+ this.priceGuest = value;
+ }
+ }
+
+ /// Gets the price string.
+ /// Fiedler, 13.11.2013.
+ /// A string.
+ public string PriceString()
+ {
+ string retValue = string.Empty;
+
+ retValue = "S: " + this.PriceGuestStr + " A: " + this.PriceEmployeeStr + " G: " + this.PriceGuestStr;
+
+ return retValue;
+ }
+ }
+}
diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs
new file mode 100644
index 00000000..ff66b109
--- /dev/null
+++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs
@@ -0,0 +1,64 @@
+//-----------------------------------------------------------------------
+//
+// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
+//
+// Fiedler
+// 13.11.2013
+// Implements the price model class
+//-----------------------------------------------------------------------
+namespace CampusAppWPortalLib8.Model.Mensa
+{
+ using System.Collections.ObjectModel;
+ using System.Xml.Serialization;
+
+ /// A data Model for the price.
+ /// Fiedler, 13.11.2013.
+ [XmlRoot("Canteens")]
+ public class PriceModel
+ {
+ /// The canteens.
+ private ObservableCollection canteens = null;
+
+ /// Initializes a new instance of the PriceModel class.
+ /// Fiedler, 13.11.2013.
+ public PriceModel()
+ {
+ this.canteens = new ObservableCollection();
+ }
+
+ /// Gets or sets the canteens.
+ /// The canteens.
+ [XmlElement("Canteen")]
+ public ObservableCollection Canteens
+ {
+ get
+ {
+ return this.canteens;
+ }
+
+ set
+ {
+ this.canteens = value;
+ }
+ }
+
+ /// Gets a canteen.
+ /// Fiedler, 13.11.2013.
+ /// The identifier.
+ /// The canteen.
+ public PriceCanteenModel GetCanteen(int id)
+ {
+ PriceCanteenModel retValue = null;
+
+ for (int i = 0; i < this.canteens.Count; i++)
+ {
+ if (this.canteens[i].Id.Equals(id))
+ {
+ retValue = this.canteens[i];
+ }
+ }
+
+ return retValue;
+ }
+ }
+}
\ No newline at end of file