From 96075183185731ec2296f928b4ad83a3bfe09bd3 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Wed, 13 Nov 2013 17:40:10 +0100 Subject: [PATCH 1/2] end of day commit --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 2 + .../CampusAppWP8/Feed/Mensa/PriceFeed.cs | 82 ++++++++ .../CampusAppWP8/Pages/Mensa/MensaPage.xaml | 40 ++-- .../Pages/Mensa/MensaPage.xaml.cs | 7 + .../CampusAppWP8/Resources/Constants.resx | 6 + .../Resources/Constants1.Designer.cs | 18 ++ .../Utility/IdToPlaceConverter.cs | 4 +- .../Utility/MealIdToPriceConverter.cs | 46 +++++ .../CampusAppWPortalLib8.csproj | 3 + .../Model/Mensa/PriceCanteenModel.cs | 185 ++++++++++++++++++ .../Model/Mensa/PriceMealModel.cs | 172 ++++++++++++++++ .../Model/Mensa/PriceModel.cs | 64 ++++++ 12 files changed, 615 insertions(+), 14 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/Feed/Mensa/PriceFeed.cs create mode 100644 CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceCanteenModel.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs 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 From 4ecc87f8636e9f6f1c99f7f9be308a35598faf6c Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Thu, 14 Nov 2013 18:18:02 +0100 Subject: [PATCH 2/2] #204 --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 7 ++ .../CampusAppWP8/Pages/Mensa/MensaPage.xaml | 3 +- .../Pages/Mensa/MensaPage.xaml.cs | 20 +++- .../Resources/AppResources.Designer.cs | 27 ++++++ .../CampusAppWP8/Resources/AppResources.resx | 9 ++ .../Utility/Lui/MultiValueTextBlock.xaml | 18 ++++ .../Utility/Lui/MultiValueTextBlock.xaml.cs | 94 +++++++++++++++++++ .../Utility/MealIdToPriceConverter.cs | 62 ++++++++++-- .../Model/Mensa/PriceMealModel.cs | 19 ++-- .../Model/Mensa/PriceModel.cs | 5 +- 10 files changed, 242 insertions(+), 22 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml create mode 100644 CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 43b27b8b..698e02d7 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -249,6 +249,9 @@ WeekViewPivotHeader.xaml + + MultiValueTextBlock.xaml + WeekView.xaml @@ -532,6 +535,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml index ac82d84d..3b83b591 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml @@ -8,6 +8,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:lui="clr-namespace:CampusAppWP8.Utility.Lui.Button" xmlns:header="clr-namespace:CampusAppWP8.Utility.Lui.Header" + xmlns:lu="clr-namespace:CampusAppWP8.Utility.Lui" 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" @@ -71,7 +72,7 @@ - + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs index 73cd21d2..8952c549 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs @@ -48,7 +48,8 @@ namespace CampusAppWP8.Pages.Mensa /// Flag for forcing webLoad. private bool forceLoad = false; - public int LocationID { get; set; } + /// Identifier for the location. + public int locationID = -1; #endregion @@ -58,7 +59,7 @@ namespace CampusAppWP8.Pages.Mensa /// Stubbfel, 15.10.2013. public MensaPage() { - this.LocationID = 0; + this.locationID = 0; this.InitializeComponent(); ApplicationBarMenuItem menuItem1 = ApplicationBar.MenuItems[0] as ApplicationBarMenuItem; @@ -85,6 +86,21 @@ namespace CampusAppWP8.Pages.Mensa #endregion + /// Gets or sets the identifier of the location. + /// The identifier of the location. + public int LocationID + { + get + { + return this.locationID; + } + + set + { + this.locationID = value; + } + } + #region Method #region protected diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index dffe834c..5ab45237 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -375,6 +375,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Angestellte ähnelt. + /// + public static string Employees { + get { + return ResourceManager.GetString("Employees", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Events ähnelt. /// @@ -420,6 +429,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Gäste ähnelt. + /// + public static string Guests { + get { + return ResourceManager.GetString("Guests", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Hinweis ähnelt. /// @@ -1266,6 +1284,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Studenten ähnelt. + /// + public static string Students { + get { + return ResourceManager.GetString("Students", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die vorlesen ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 90588cd5..9297b6cd 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -596,4 +596,13 @@ Mi + + Angestellte + + + Gäste + + + Studenten + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml new file mode 100644 index 00000000..747b8420 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml @@ -0,0 +1,18 @@ + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml.cs new file mode 100644 index 00000000..4d050d77 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml.cs @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 14.11.2013 +// Implements the multi value text block.xaml class +//----------------------------------------------------------------------- +namespace CampusAppWP8.Utility.Lui +{ + using System.Windows; + using System.Windows.Controls; + using System.Windows.Data; + + /// A multi value text block. + /// Fiedler, 14.11.2013. + /// + public partial class MultiValueTextBlock : UserControl + { + /// The value 1 property. + public static readonly DependencyProperty Value_1_Property = DependencyProperty.Register("Value1", typeof(object), typeof(MultiValueTextBlock), new PropertyMetadata(null, MultiValueTextBlock.OnLoaded)); + /// The value 2 property. + public static readonly DependencyProperty Value_2_Property = DependencyProperty.Register("Value2", typeof(object), typeof(MultiValueTextBlock), new PropertyMetadata(null, MultiValueTextBlock.OnLoaded)); + + /// The converter property. + public static readonly DependencyProperty ConverterProperty = DependencyProperty.Register("Converter", typeof(IValueConverter), typeof(MultiValueTextBlock), new PropertyMetadata(null, MultiValueTextBlock.OnLoaded)); + + /// Initializes a new instance of the MultiValueTextBlock class. + /// Fiedler, 14.11.2013. + public MultiValueTextBlock() : base() + { + this.InitializeComponent(); + } + + /// Gets or sets the converter. + /// The converter. + public IValueConverter Converter + { + get + { + return (IValueConverter)this.GetValue(ConverterProperty); + } + + set + { + this.SetValue(ConverterProperty, value); + } + } + + /// Gets or sets the value 1. + /// The value 1. + public object Value1 + { + get + { + return this.GetValue(Value_1_Property); + } + + set + { + this.SetValue(Value_1_Property, value); + } + } + + /// Gets or sets the value 2. + /// The value 2. + public object Value2 + { + get + { + return this.GetValue(Value_2_Property); + } + + set + { + this.SetValue(Value_2_Property, value); + } + } + + /// Raises the dependency property changed event. + /// Fiedler, 14.11.2013. + /// The DependencyObject to process. + /// Event information to send to registered event handlers. + private static void OnLoaded(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + MultiValueTextBlock obj = d as MultiValueTextBlock; + + if ((obj.Value1 != null) && (obj.Value2 != null) && (obj.Converter != null)) + { + obj.TheText.Text = (string)obj.Converter.Convert(obj.Value1, typeof(string), obj.Value2, System.Globalization.CultureInfo.CurrentCulture); + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs index 5adfdb57..dad09bf1 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs @@ -1,14 +1,29 @@ -namespace CampusAppWP8.Utility +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 14.11.2013 +// Implements the meal identifier to price converter class +//----------------------------------------------------------------------- +namespace CampusAppWP8.Utility { using System; using System.Windows.Data; using CampusAppWP8.Feed.Mensa; - using CampusAppWPortalLib8.Model.GeoDb; + using CampusAppWP8.Resources; + using CampusAppWPortalLib8.Model.Mensa; + /// A meal identifier to price converter. + /// Fiedler, 14.11.2013. + /// public sealed class MealIdToPriceConverter : IValueConverter { + /// The price feed. private PriceFeed priceFeed = null; + /// Initializes a new instance of the MealIdToPriceConverter class. + /// Fiedler, 14.11.2013. public MealIdToPriceConverter() { this.priceFeed = new PriceFeed(); @@ -17,28 +32,63 @@ this.priceFeed.LoadData(); } - + /// + /// Ändert die Quelldaten vor der Übergabe an das Ziel zur Anzeige in der Benutzeroberfläche. + /// + /// Fiedler, 14.11.2013. + /// public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) { string retValue = string.Empty; - - if ((parameter is int) && (value is int)) + int intVal = -1; + int intParam = -1; + + if (value is int) { - retValue = this.priceFeed.Model.GetCanteen((int)value).GetPriceMealModel((int)parameter).PriceString(); + intVal = (int)value; + } + else if(value is string) + { + intVal = int.Parse((string)value); + } + + if (parameter is int) + { + intParam = (int)parameter; + } + else if (parameter is string) + { + intParam = int.Parse((string)parameter); + } + + 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 + " €"; } return retValue; } + /// + /// Ändert die Zieldaten vor der Übergabe an das Quellobjekt. Diese Methode wird nur in + /// -Bindungen aufgerufen. + /// + /// Fiedler, 14.11.2013. + /// public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) { return null; } + /// Price feed is ready. + /// Fiedler, 14.11.2013. private void PriceFeedIsReady() { } + /// Price feed is failed. + /// Fiedler, 14.11.2013. private void PriceFeedIsFailed() { } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs index ff3a2526..460322f6 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs @@ -68,7 +68,7 @@ namespace CampusAppWPortalLib8.Model.Mensa { get { - return string.Format("{0:0.00}", this.priceStudent); + return this.CurrencyString(this.priceStudent); } set @@ -100,7 +100,7 @@ namespace CampusAppWPortalLib8.Model.Mensa { get { - return string.Format("{0:00.0}", this.priceEmployee); + return this.CurrencyString(this.priceEmployee); } set @@ -132,7 +132,7 @@ namespace CampusAppWPortalLib8.Model.Mensa { get { - return string.Format("{0:00.0}", this.priceGuest); + return this.CurrencyString(this.priceGuest); } set @@ -157,16 +157,13 @@ namespace CampusAppWPortalLib8.Model.Mensa } } - /// Gets the price string. - /// Fiedler, 13.11.2013. + /// Currency string. + /// Fiedler, 14.11.2013. + /// The value. /// A string. - public string PriceString() + private string CurrencyString(double val) { - string retValue = string.Empty; - - retValue = "S: " + this.PriceGuestStr + " A: " + this.PriceEmployeeStr + " G: " + this.PriceGuestStr; - - return retValue; + return string.Format("{0:0.00}", val); } } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs index ff66b109..3a62b506 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs @@ -13,7 +13,7 @@ namespace CampusAppWPortalLib8.Model.Mensa /// A data Model for the price. /// Fiedler, 13.11.2013. - [XmlRoot("Canteens")] + [XmlRoot("root")] public class PriceModel { /// The canteens. @@ -28,7 +28,8 @@ namespace CampusAppWPortalLib8.Model.Mensa /// Gets or sets the canteens. /// The canteens. - [XmlElement("Canteen")] + [XmlArray("Canteens")] + [XmlArrayItem("Canteen")] public ObservableCollection Canteens { get