From fa5d2e17e5c7bac0cfe502cb3d1c843cdf585cf7 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Wed, 13 Nov 2013 13:46:53 +0100 Subject: [PATCH] #269 done --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 3 +- .../Feed/Openinghours/OpeninghoursFeed.cs | 10 +- .../OpeninghoursInstitutionWp8Model.cs | 156 --------- .../Openinghours/OpeninghoursWp8Model.cs | 20 -- .../Pages/Openinghours/OpeninghoursPage.xaml | 211 ++++++------ .../Openinghours/OpeninghoursPage.xaml.cs | 84 +++-- .../CampusAppWP8/Resources/Constants.resx | 2 +- .../Resources/Constants1.Designer.cs | 2 +- .../Utility/IdToPlaceConverter.cs | 113 +++++++ .../CampusAppWPortalLib8.csproj | 2 + .../Model/Openinghours/OpenhoursDayModel.cs | 217 +++++++++++++ .../OpeninghoursInstitutionModel.cs | 300 +++++++++++++----- .../Openinghours/OpeninghoursLocationModel.cs | 62 ++++ .../Model/Openinghours/OpeninghoursModel.cs | 14 +- 14 files changed, 779 insertions(+), 417 deletions(-) delete mode 100644 CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursInstitutionWp8Model.cs delete mode 100644 CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursWp8Model.cs create mode 100644 CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpenhoursDayModel.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursLocationModel.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index bad54601..c4b29600 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -236,6 +236,7 @@ + @@ -281,8 +282,6 @@ - - CampusMapPage.xaml diff --git a/CampusAppWP8/CampusAppWP8/Feed/Openinghours/OpeninghoursFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Openinghours/OpeninghoursFeed.cs index 5c4c974d..7f331eef 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Openinghours/OpeninghoursFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Openinghours/OpeninghoursFeed.cs @@ -11,15 +11,15 @@ namespace CampusAppWP8.Feed.Openinghours using System; using System.IO; using CampusAppWP8.Model; - using CampusAppWP8.Model.Openinghours; using CampusAppWP8.Resources; using CampusAppWP8.Utility; using CampusAppWPortalLib8.Model; + using CampusAppWPortalLib8.Model.Openinghours; /// This Class is for MesaFeeds. /// fiedlchr, 14.10.2013. /// - public class OpeninghoursFeed : XmlModel + public class OpeninghoursFeed : XmlModel { #region Constructor @@ -41,7 +41,7 @@ namespace CampusAppWP8.Feed.Openinghours /// fiedlchr, 14.10.2013. /// reference of the FeedModel. /// true, if model is up-to-date, otherwise false. - private bool CheckIsModelUpToDate(OpeninghoursWp8Model model) + private bool CheckIsModelUpToDate(OpeninghoursModel model) { bool retValue = true; @@ -62,7 +62,7 @@ namespace CampusAppWP8.Feed.Openinghours /// reference of the FeedModel. /// info about the file. /// true, if file is up-to-date, otherwise false. - private bool CheckIsFileUpToDateOnLoad(OpeninghoursWp8Model model, FileInfo info) + private bool CheckIsFileUpToDateOnLoad(OpeninghoursModel model, FileInfo info) { bool retValue = true; @@ -82,7 +82,7 @@ namespace CampusAppWP8.Feed.Openinghours /// reference of the FeedModel. /// info about the file. /// true, if file is up-to-date, otherwise false. - private bool CheckIsFileUpToDateOnSave(OpeninghoursWp8Model model, FileInfo info) + private bool CheckIsFileUpToDateOnSave(OpeninghoursModel model, FileInfo info) { bool retValue = true; diff --git a/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursInstitutionWp8Model.cs b/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursInstitutionWp8Model.cs deleted file mode 100644 index 7c4cfb96..00000000 --- a/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursInstitutionWp8Model.cs +++ /dev/null @@ -1,156 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Company copyright tag. -// -// fiedlchr -// 24.06.2013 -//----------------------------------------------------------------------------- - -namespace CampusAppWP8.Model.Openinghours -{ - using System.Globalization; - using System.Windows; - using System.Xml.Serialization; - - /// - /// Model for menu - /// - public class OpeninghoursInstitutionWp8Model : CampusAppWPortalLib8.Model.Openinghours.OpeninghoursInstitutionModel - { - #region Property - - /// - /// Gets the visibility state of the monday TextBlock. - /// - public Visibility VisibleMonday - { - get - { - return ((this.Monday == string.Empty) || (this.Monday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the tuesday TextBlock. - /// - public Visibility VisibleTuesday - { - get - { - return ((this.Tuesday == string.Empty) || (this.Tuesday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the wednesday TextBlock. - /// - public Visibility VisibleWednesday - { - get - { - return ((this.Wednesday == string.Empty) || (this.Wednesday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the thursday TextBlock. - /// - public Visibility VisibleThursday - { - get - { - return ((this.Thursday == string.Empty) || (this.Thursday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the friday TextBlock. - /// - public Visibility VisibleFriday - { - get - { - return ((this.Friday == string.Empty) || (this.Friday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the saturday TextBlock. - /// - public Visibility VisibleSaturday - { - get - { - return ((this.Saturday == string.Empty) || (this.Saturday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the sunday TextBlock. - /// - public Visibility VisibleSunday - { - get - { - return ((this.Sunday == string.Empty) || (this.Sunday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the comment. - /// - public Visibility VisibleComment - { - get - { - return ((this.Comment == string.Empty) || (this.Comment.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the email address. - /// - public Visibility VisibleEMail - { - get - { - return ((this.EMail == string.Empty) || (this.EMail.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the phone number. - /// - public Visibility VisiblePhone - { - get - { - return ((this.Phone == string.Empty) || (this.Phone.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the room. - /// - public Visibility VisibleRoom - { - get - { - return ((this.Room == string.Empty) || (this.Room.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the building. - /// - public Visibility VisibleBuilding - { - get - { - return ((this.Building == string.Empty) || (this.Building.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursWp8Model.cs b/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursWp8Model.cs deleted file mode 100644 index 88b480bd..00000000 --- a/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursWp8Model.cs +++ /dev/null @@ -1,20 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Company copyright tag. -// -// fiedlchr -// 24.06.2013 -//----------------------------------------------------------------------------- - -namespace CampusAppWP8.Model.Openinghours -{ - using System.Xml.Serialization; - - /// - /// Model for opening hours. - /// - [XmlRoot("root")] - public class OpeninghoursWp8Model : CampusAppWPortalLib8.Model.Openinghours.OpeninghoursModel - { - } -} diff --git a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml index ca481e36..f5e7f4bf 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml @@ -9,6 +9,7 @@ xmlns:lui="clr-namespace:CampusAppWP8.Utility.Lui.Button" xmlns:header="clr-namespace:CampusAppWP8.Utility.Lui.Header" xmlns:page="clr-namespace:CampusAppWP8.Utility.Lui.Page" + xmlns:utility="clr-namespace:CampusAppWP8.Utility" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" @@ -16,6 +17,11 @@ mc:Ignorable="d" shell:SystemTray.IsVisible="True"> + + + + + @@ -27,105 +33,116 @@ - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs index e0d58228..1bc482eb 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs @@ -9,38 +9,34 @@ namespace CampusAppWP8.Pages.Openinghours { using System; using System.Windows; + using System.Windows.Controls; using System.Windows.Navigation; using CampusAppWP8.Feed.Openinghours; - using CampusAppWP8.Model.Openinghours; using CampusAppWP8.Resources; using CampusAppWP8.Utility; using CampusAppWP8.Utility.Lui.MessageBoxes; using CampusAppWP8.Utility.Lui.Page; + using CampusAppWPortalLib8.Model.Openinghours; - /// - /// Opening hours page. - /// + /// Opening hours page. + /// Fiedler, 13.11.2013. + /// public partial class OpeninghoursPage : PortraitLandscapePage { #region Members - /// - /// Opening hours feed object. - /// + /// Opening hours feed object. private OpeninghoursFeed feed = null; - /// - /// for checking if the instance is new or a tombstone. - /// + /// for checking if the instance is new or a tombstone. private bool isNewInstance = false; #endregion #region Constructor - /// - /// Initializes a new instance of the class. - /// + /// Initializes a new instance of the class. + /// Fiedler, 13.11.2013. public OpeninghoursPage() { this.InitializeComponent(); @@ -52,7 +48,7 @@ namespace CampusAppWP8.Pages.Openinghours this.feed.OnLoaded += new OpeninghoursFeed.OnIO(this.FeedIsReady); this.feed.OnFailedWeb += new OpeninghoursFeed.OnFailed(this.FeedIsFailedWeb); this.feed.OnFailedFile += new OpeninghoursFeed.OnFailed(this.FeedIsFailedFile); - this.feed.LoadData(Utilities.GetLoadModus()); + this.feed.LoadData(Utilities.GetLoadModus()); } this.isNewInstance = true; @@ -64,10 +60,9 @@ namespace CampusAppWP8.Pages.Openinghours #region protected - /// - /// Override the OnNavigatedTo method. - /// - /// Arguments of navigation + /// Override the OnNavigatedTo method. + /// Fiedler, 13.11.2013. + /// protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); @@ -76,9 +71,9 @@ namespace CampusAppWP8.Pages.Openinghours { if ((this.feed == null) || (this.feed.Model == null)) { - OpeninghoursWp8Model tempModel = null; + OpeninghoursModel tempModel = null; - if ((tempModel = App.LoadFromIsolatedStorage(Constants.IsolatedStorage_OpeninghoursModel)) != null) + if ((tempModel = App.LoadFromIsolatedStorage(Constants.IsolatedStorage_OpeninghoursModel)) != null) { this.feed.Model = tempModel; this.FeedIsReady(); @@ -89,20 +84,23 @@ namespace CampusAppWP8.Pages.Openinghours } } - /// - /// Override the OnNavigatedFrom method - /// - /// Arguments of navigation + /// Override the OnNavigatedFrom method. + /// Fiedler, 13.11.2013. + /// protected override void OnNavigatedFrom(NavigationEventArgs e) { this.feed.SaveData(); if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back) { - App.SaveToIsolatedStorage(Constants.IsolatedStorage_OpeninghoursModel, this.feed.Model); + App.SaveToIsolatedStorage(Constants.IsolatedStorage_OpeninghoursModel, this.feed.Model); } } + /// Raises the tap grid event. + /// Fiedler, 13.11.2013. + /// button object. + /// Event information to send to registered event handlers. private void OnTapGrid(object sender, EventArgs e) { @@ -113,55 +111,51 @@ namespace CampusAppWP8.Pages.Openinghours #region private - /// - /// Will be execute if the feed is ready. - /// + /// Will be execute if the feed is ready. + /// Fiedler, 13.11.2013. private void FeedIsReady() { - this.InstitutionPanel.ItemsSource = this.feed.Model.Institutions; + this.ThePivot.ItemsSource = this.feed.Model.Locations; this.DefHeader.ProgressVisibility = Visibility.Collapsed; this.feed.SaveData(); } /// - /// On clicking the update button in the ApplicationBar. - /// Force a data update from the web. + /// On clicking the update button in the ApplicationBar. Force a data update from the web. /// - /// button object - /// event args + /// Fiedler, 13.11.2013. + /// button object. + /// event args. private void OpenHoursForceUpdate_Click(object sender, EventArgs e) { this.DefHeader.ProgressVisibility = Visibility.Visible; this.feed.ForceWebUpdate(); } - /// - /// Method will be execute if the feed is failed - /// + /// Method will be execute if the feed is failed. + /// Fiedler, 13.11.2013. private void FeedIsFailedWeb() { MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb); this.feed.ForceReadFile(); } - /// - /// Method will be execute if the feed is failed - /// + /// Method will be execute if the feed is failed. + /// Fiedler, 13.11.2013. private void FeedIsFailedFile() { this.DefHeader.ProgressVisibility = Visibility.Collapsed; MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile); } - /// - /// Method will be execute if the selection is change in the listbox. - /// - /// listbox object. - /// event args. + /// Method will be execute if the selection is change in the listbox. + /// Fiedler, 13.11.2013. + /// listbox object. + /// event args. private void InstitutionPanel_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { - this.InstitutionPanel.SelectedIndex = -1; + (sender as ListBox).SelectedIndex = -1; } // private diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 1e7fbdef..74dd8ca7 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -247,7 +247,7 @@ OpeninghoursFeed.xml - http://www.tu-cottbus.de/campusapp-data/getdata.php?db=openinghours&app=2&appversion=1 + http://www.tu-cottbus.de/campusapp-data/openinghours.php?v=2 NewsFeed.xml diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs index 4aec5b6e..f290ade3 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs @@ -1357,7 +1357,7 @@ namespace CampusAppWP8.Resources { } /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/getdata.php?db=openinghours&app=2&appversion=1 ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/openinghours.php?v=2 ähnelt. /// public static string UrlOpeningHours_OpeningHours { get { diff --git a/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs new file mode 100644 index 00000000..4c57f4e7 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs @@ -0,0 +1,113 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 13.11.2013 +// Implements the identifier to place converter class +//----------------------------------------------------------------------- +namespace CampusAppWP8.Utility +{ + using System; + using System.Windows.Data; + using CampusAppWP8.File.Places; + using CampusAppWPortalLib8.Model.GeoDb; + + /// An identifier to place converter. + /// Fiedler, 13.11.2013. + /// + public sealed class IdToPlaceConverter : IValueConverter + { + /// The place file. + private PlacesFile placeFile = null; + + /// Initializes a new instance of the IdToPlaceConverter class. + /// Fiedler, 13.11.2013. + public IdToPlaceConverter() + { + this.placeFile = new PlacesFile(); + this.placeFile.OnLoaded += new PlacesFile.OnIO(this.PlaceFileIsReady); + this.placeFile.OnFailedLoad += new PlacesFile.OnFailed(this.PlaceFileIsFailed); + this.placeFile.LoadData(); + } + + /// + /// Ändert die Quelldaten vor der Übergabe an das Ziel zur Anzeige in der Benutzeroberfläche. + /// + /// Fiedler, 13.11.2013. + /// info string of the place. + /// + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) + { + string retValue = string.Empty; + string paramStr = "Name"; + + if (parameter is string) + { + paramStr = (string)parameter; + } + + if (value is string) + { + retValue = this.GetInfo((string)value, paramStr); + } + else if (value is int) + { + retValue = this.GetInfo(string.Empty + (int)value, paramStr); + } + + return retValue; + } + + /// + /// Ändert die Zieldaten vor der Übergabe an das Quellobjekt. Diese Methode wird nur in + /// -Bindungen aufgerufen. + /// + /// Fiedler, 13.11.2013. + /// null + /// + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) + { + object retValue = null; + + /* + if(targetType.Equals(typeof(int))) + { + retValue = new int(); + retValue = + } + */ + return retValue; + } + + /// Gets an information. + /// Fiedler, 13.11.2013. + /// Identifier for the place. + /// Information describing the search. + /// The information. + private string GetInfo(string placeID, string searchInfo) + { + string retValue = string.Empty; + + if (this.placeFile.Model != null) + { + PlaceModel model = this.placeFile.Model.GetPlaceById(placeID); + retValue = model.GetInformationsValue(searchInfo); + } + + return retValue; + } + + /// Place file is failed. + /// Fiedler, 13.11.2013. + private void PlaceFileIsFailed() + { + } + + /// Place file is ready. + /// Fiedler, 13.11.2013. + private void PlaceFileIsReady() + { + } + } +} diff --git a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj index ea952363..4826570b 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj +++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj @@ -63,7 +63,9 @@ + + diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpenhoursDayModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpenhoursDayModel.cs new file mode 100644 index 00000000..0718c121 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpenhoursDayModel.cs @@ -0,0 +1,217 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 12.11.2013 +// Implements the openhours day model class +//----------------------------------------------------------------------- +namespace CampusAppWPortalLib8.Model.Openinghours +{ + using System; + using System.Xml.Serialization; + + /// A data Model for the openinghours day. + /// Fiedler, 12.11.2013. + [XmlRoot("Open")] + public class OpeninghoursDayModel + { + /// The start. + private TimeSpan start; + /// The end. + private TimeSpan end; + /// The day. + private DayOfWeek day; + + /// Initializes a new instance of the OpeninghoursDayModel class. + /// Fiedler, 12.11.2013. + public OpeninghoursDayModel() + { + this.start = TimeSpan.Zero; + this.end = TimeSpan.Zero; + this.day = DayOfWeek.Sunday; + } + + /// Gets or sets the start. + /// The start. + [XmlAttribute("start")] + public string Start + { + get + { + return this.TimeSpanToString(this.start); + } + + set + { + this.start = this.StringToTimeSpan(value); + } + } + + /// Gets or sets the start. + /// The start. + [XmlIgnore] + public TimeSpan StartTS + { + get + { + return this.start; + } + + set + { + this.start = value; + } + } + + /// Gets or sets the end. + /// The end. + [XmlAttribute("end")] + public string End + { + get + { + return this.TimeSpanToString(this.end); + } + + set + { + this.end = this.StringToTimeSpan(value); + } + } + + /// Gets or sets the end. + /// The end. + [XmlIgnore] + public TimeSpan EndTS + { + get + { + return this.end; + } + + set + { + this.end = value; + } + } + + /// Gets or sets the day. + /// The day. + [XmlAttribute("day")] + public int Day + { + get + { + return this.DayOfWeekToInt(this.day); + } + + set + { + this.day = this.IntToDayOfWeek(value); + } + } + + /// Gets or sets the day. + /// The day. + [XmlIgnore] + public DayOfWeek DayDOW + { + get + { + return this.day; + } + + set + { + this.day = value; + } + } + + /// Gets the time string. + /// The time string. + [XmlIgnore] + public string TimeString + { + get + { + return this.TimeSpanToString(this.start) + " - " + this.TimeSpanToString(this.end); + } + } + + /// String to time span. + /// Fiedler, 12.11.2013. + /// The. + /// A TimeSpan. + private TimeSpan StringToTimeSpan(string str) + { + string[] split = str.Split(':'); + + return new TimeSpan( + int.Parse(split[0]), + (split.Length > 1) ? int.Parse(split[1]) : 0, + (split.Length > 2) ? int.Parse(split[2]) : 0); + } + + /// Time span to string. + /// Fiedler, 12.11.2013. + /// The span. + /// A string. + private string TimeSpanToString(TimeSpan span) + { + return string.Format("{0:hh\\:mm}", span); + } + + /// Int to day of week. + /// Fiedler, 12.11.2013. + /// + /// Thrown when the requested operation is not supported. + /// + /// The day nr. + /// A DayOfWeek. + private DayOfWeek IntToDayOfWeek(int dayNr) + { + DayOfWeek retValue = DayOfWeek.Sunday; + + switch(dayNr) + { + case 1: retValue = DayOfWeek.Monday; break; + case 2: retValue = DayOfWeek.Tuesday; break; + case 3: retValue = DayOfWeek.Wednesday; break; + case 4: retValue = DayOfWeek.Thursday; break; + case 5: retValue = DayOfWeek.Friday; break; + case 6: retValue = DayOfWeek.Saturday; break; + case 7: retValue = DayOfWeek.Sunday; break; + + default: + { + throw new NotSupportedException("day number is not supported (" + dayNr + ")"); + } + } + + return retValue; + } + + /// Day of week to int. + /// Fiedler, 12.11.2013. + /// The dow. + /// An int. + private int DayOfWeekToInt(DayOfWeek dow) + { + int retValue = -1; + + switch (dow) + { + case DayOfWeek.Monday: retValue = 1; break; + case DayOfWeek.Tuesday: retValue = 2; break; + case DayOfWeek.Wednesday: retValue = 3; break; + case DayOfWeek.Thursday: retValue = 4; break; + case DayOfWeek.Friday: retValue = 5; break; + case DayOfWeek.Saturday: retValue = 6; break; + case DayOfWeek.Sunday: retValue = 7; break; + } + + return retValue; + } + } +} diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursInstitutionModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursInstitutionModel.cs index 5a59452b..e2c4892d 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursInstitutionModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursInstitutionModel.cs @@ -8,6 +8,8 @@ //----------------------------------------------------------------------- namespace CampusAppWPortalLib8.Model.Openinghours { + using System; + using System.Collections.ObjectModel; using System.Globalization; using System.Windows; using System.Xml.Serialization; @@ -24,27 +26,6 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// English version of the institution title. private string titleEN = string.Empty; - /// Opening hours on monday. - private string dayMonday = string.Empty; - - /// Opening hours on tuesday. - private string dayTuesday = string.Empty; - - /// Opening hours on wednesday. - private string dayWednesday = string.Empty; - - /// Opening hours on thursday. - private string dayThursday = string.Empty; - - /// Opening hours on friday. - private string dayFriday = string.Empty; - - /// Opening hours on saturday. - private string daySaturday = string.Empty; - - /// Opening hours on sunday. - private string daySunday = string.Empty; - /// Email address of the institution. private string infoEmail = string.Empty; @@ -63,6 +44,9 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// English version of the comment. private string commentEN = string.Empty; + /// List of days. + private ObservableCollection dayList = null; + #endregion #region Constructor @@ -73,6 +57,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// Stubbfel, 15.10.2013. public OpeninghoursInstitutionModel() { + this.dayList = new ObservableCollection(); } #endregion @@ -111,115 +96,80 @@ namespace CampusAppWPortalLib8.Model.Openinghours } } - /// Gets or sets the open hours on monday. + /// Gets the open hours on monday. /// The monday. - [XmlAttribute("monday")] + [XmlIgnore] public string Monday { get { - return this.dayMonday; - } - - set - { - this.dayMonday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Monday); } } - /// Gets or sets the open hours on tuesday. + /// Gets the open hours on tuesday. /// The tuesday. - [XmlAttribute("tuesday")] + [XmlIgnore] public string Tuesday { get { - return this.dayTuesday; - } - - set - { - this.dayTuesday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Tuesday); } } - /// Gets or sets the open hours on wednesday. + /// Gets the open hours on wednesday. /// The wednesday. - [XmlAttribute("wednesday")] + [XmlIgnore] public string Wednesday { get { - return this.dayWednesday; - } - - set - { - this.dayWednesday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Wednesday); } } - /// Gets or sets the open hours on thursday. + /// Gets the open hours on thursday. /// The thursday. - [XmlAttribute("thursday")] + [XmlIgnore] public string Thursday { get { - return this.dayThursday; - } - - set - { - this.dayThursday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Thursday); } } - /// Gets or sets the open hours on friday. + /// Gets the open hours on friday. /// The friday. - [XmlAttribute("friday")] + [XmlIgnore] public string Friday { get { - return this.dayFriday; - } - - set - { - this.dayFriday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Friday); } } - /// Gets or sets the open hours on saturday. + /// Gets the open hours on saturday. /// The saturday. - [XmlAttribute("saturday")] + [XmlIgnore] public string Saturday { get { - return this.daySaturday; - } - - set - { - this.daySaturday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Saturday); } } - /// Gets or sets the open hours on sunday. + /// Gets the open hours on sunday. /// The sunday. - [XmlAttribute("sunday")] + [XmlIgnore] public string Sunday { get { - return this.daySunday; - } - - set - { - this.daySunday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Sunday); } } @@ -319,11 +269,28 @@ namespace CampusAppWPortalLib8.Model.Openinghours } } + /// Gets or sets the days. + /// The days. + [XmlElement("Open")] + public ObservableCollection Days + { + get + { + return this.dayList; + } + + set + { + this.dayList = value; + } + } + /// /// Gets the localized title. If the phone is set to german language, the german title will /// be returned otherwise the english title. /// /// The title. + [XmlIgnore] public string Title { get @@ -344,6 +311,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// will be returned otherwise the english comment. /// /// The comment. + [XmlIgnore] public string Comment { get @@ -363,6 +331,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// Gets a string containing the email address and the institution title separated by ':'. /// /// The e mail title. + [XmlIgnore] public string EMailTitle { get @@ -375,6 +344,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// Gets a string containing the phone number and the institution title separated by ':'. /// /// The phone title. + [XmlIgnore] public string PhoneTitle { get @@ -383,19 +353,183 @@ namespace CampusAppWPortalLib8.Model.Openinghours } } + /// Gets a value indicating whether the visible monday. + /// true if visible monday, false if not. + [XmlIgnore] + public bool VisibleMonday + { + get + { + return this.HasDay(DayOfWeek.Monday); + } + } + + /// Gets a value indicating whether the visible tuesday. + /// true if visible tuesday, false if not. + [XmlIgnore] + public bool VisibleTuesday + { + get + { + return this.HasDay(DayOfWeek.Tuesday); + } + } + + /// Gets a value indicating whether the visible wednesday. + /// true if visible wednesday, false if not. + [XmlIgnore] + public bool VisibleWednesday + { + get + { + return this.HasDay(DayOfWeek.Wednesday); + } + } + + /// Gets a value indicating whether the visible thursday. + /// true if visible thursday, false if not. + [XmlIgnore] + public bool VisibleThursday + { + get + { + return this.HasDay(DayOfWeek.Thursday); + } + } + + /// Gets a value indicating whether the visible friday. + /// true if visible friday, false if not. + [XmlIgnore] + public bool VisibleFriday + { + get + { + return this.HasDay(DayOfWeek.Friday); + } + } + + /// Gets a value indicating whether the visible saturday. + /// true if visible saturday, false if not. + [XmlIgnore] + public bool VisibleSaturday + { + get + { + return this.HasDay(DayOfWeek.Saturday); + } + } + + /// Gets a value indicating whether the visible sunday. + /// true if visible sunday, false if not. + [XmlIgnore] + public bool VisibleSunday + { + get + { + return this.HasDay(DayOfWeek.Sunday); + } + } + + /// Gets a value indicating whether the visible comment. + /// true if visible comment, false if not. + [XmlIgnore] + public bool VisibleComment + { + get + { + return !((this.Comment == string.Empty) || (this.Comment.Length == 0)); + } + } + + /// Gets a value indicating whether the visible mail. + /// true if visible mail, false if not. + [XmlIgnore] + public bool VisibleEMail + { + get + { + return !((this.EMail == string.Empty) || (this.EMail.Length == 0)); + } + } + + /// Gets a value indicating whether the visible phone. + /// true if visible phone, false if not. + [XmlIgnore] + public bool VisiblePhone + { + get + { + return !((this.Phone == string.Empty) || (this.Phone.Length == 0)); + } + } + + /// Gets a value indicating whether the visible room. + /// true if visible room, false if not. + [XmlIgnore] + public bool VisibleRoom + { + get + { + return !((this.Room == string.Empty) || (this.Room.Length == 0)); + } + } + + /// Gets a value indicating whether the visible building. + /// true if visible building, false if not. + [XmlIgnore] + public bool VisibleBuilding + { + get + { + return !((this.Building == string.Empty) || (this.Building.Length == 0)); + } + } + #endregion #region Method - /// Removes unwanted chars in a string. - /// Stubbfel, 15.10.2013. - /// input string. - /// fixed string. - private string FixOpeninghoursString(string str) + /// Day to string. + /// Fiedler, 13.11.2013. + /// The dow. + /// A string. + private string DayToString(DayOfWeek dow) { string retValue = string.Empty; - retValue = str.Replace(" | ", "\n"); + foreach (OpeninghoursDayModel dm in this.dayList) + { + if (dm.DayDOW.Equals(dow)) + { + if (retValue.Equals(string.Empty)) + { + retValue += dm.TimeString; + } + else + { + retValue += "\n" + dm.TimeString; + } + } + } + + return retValue; + } + + /// Query if 'dow' has day. + /// Fiedler, 13.11.2013. + /// The dow. + /// true if day, false if not. + private bool HasDay(DayOfWeek dow) + { + bool retValue = false; + + foreach (OpeninghoursDayModel dm in this.dayList) + { + if (dm.DayDOW.Equals(dow)) + { + retValue = true; + } + } return retValue; } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursLocationModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursLocationModel.cs new file mode 100644 index 00000000..e2027919 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursLocationModel.cs @@ -0,0 +1,62 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 13.11.2013 +// Implements the openinghours location model class +//----------------------------------------------------------------------- +namespace CampusAppWPortalLib8.Model.Openinghours +{ + using System.Collections.ObjectModel; + using System.Xml.Serialization; + + /// Model for menu. + /// Stubbfel, 15.10.2013. + public class OpeninghoursLocationModel + { + /// The institutions. + private ObservableCollection institutions = null; + /// Identifier for the location. + private int locationID = -1; + + /// Initializes a new instance of the OpeninghoursLocationModel class. + /// Fiedler, 13.11.2013. + public OpeninghoursLocationModel() + { + this.institutions = new ObservableCollection(); + } + + /// Gets or sets the identifier of the location. + /// The identifier of the location. + [XmlAttribute("id")] + public int LocationID + { + get + { + return this.locationID; + } + + set + { + this.locationID = value; + } + } + + /// Gets or sets the institutions. + /// The institutions. + [XmlElement("Object")] + public ObservableCollection Institutions + { + get + { + return this.institutions; + } + + set + { + this.institutions = value; + } + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursModel.cs index 42492466..c0dc5316 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursModel.cs @@ -16,7 +16,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// fiedlchr, 15.10.2013. /// Generic type parameter. [XmlRoot("root")] - public class OpeninghoursModel where T : OpeninghoursInstitutionModel + public class OpeninghoursModel { #region Member @@ -24,7 +24,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours private readonly DateTime createTime; /// Gets or sets feed information item list. - private ObservableCollection institutions; + private ObservableCollection locations; #endregion @@ -34,7 +34,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// fiedlchr, 15.10.2013. public OpeninghoursModel() { - this.institutions = new ObservableCollection(); + this.locations = new ObservableCollection(); this.createTime = DateTime.Now; } @@ -55,17 +55,17 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// Gets or sets the Institutions. /// The institutions. [XmlArray("data")] - [XmlArrayItem("institution")] - public ObservableCollection Institutions + [XmlArrayItem("Location")] + public ObservableCollection Locations { get { - return this.institutions; + return this.locations; } set { - this.institutions = value; + this.locations = value; } }