From 655b4c063897790d27ab903d9eeb269ab2ef533e Mon Sep 17 00:00:00 2001 From: stubbfel Date: Tue, 2 Jul 2013 12:17:15 +0200 Subject: [PATCH 1/2] add Linkpage, Model and feeds --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 11 ++ .../CampusAppWP8/Feed/Link/ClubLinkFeed.cs | 83 ++++++++ .../CampusAppWP8/Feed/Link/CommonLinkFeed.cs | 83 ++++++++ .../CampusAppWP8/Feed/Mensa/MensaFeed.cs | 2 +- .../CampusAppWP8/Model/Link/LinkListModel.cs | 64 +++++++ .../CampusAppWP8/Model/Link/LinkModel.cs | 173 +++++++++++++++++ .../Pages/Lecture/LecturePage.xaml | 16 +- .../Pages/Lecture/ResultDetailPage.xaml | 3 +- .../Pages/Lecture/ResultPage.xaml | 89 +++------ .../CampusAppWP8/Pages/Links/LinkPage.xaml | 61 ++++++ .../CampusAppWP8/Pages/Links/LinkPage.xaml.cs | 177 ++++++++++++++++++ .../CampusAppWP8/Properties/WMAppManifest.xml | 2 +- .../Resources/AppResources.Designer.cs | 18 ++ .../CampusAppWP8/Resources/AppResources.resx | 6 + .../Resources/Constants.Designer.cs | 36 ++++ .../CampusAppWP8/Resources/Constants.resx | 12 ++ .../CampusAppWP8/pages/mensa/MensaPage.xaml | 3 +- 17 files changed, 759 insertions(+), 80 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs create mode 100644 CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs create mode 100644 CampusAppWP8/CampusAppWP8/Model/Link/LinkListModel.cs create mode 100644 CampusAppWP8/CampusAppWP8/Model/Link/LinkModel.cs create mode 100644 CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml create mode 100644 CampusAppWP8/CampusAppWP8/Pages/Links/LinkPage.xaml.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 3fdb572d..6854c997 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -96,6 +96,8 @@ App.xaml + + @@ -113,6 +115,8 @@ + + @@ -149,6 +153,9 @@ ResultPage.xaml + + LinkPage.xaml + MensaPage.xaml @@ -238,6 +245,10 @@ MSBuild:Compile Designer + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs new file mode 100644 index 00000000..c34b5f5a --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Feed/Link/ClubLinkFeed.cs @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Feed.Link +{ + using System; + using CampusAppWP8.Model.Link; + using CampusAppWP8.Resources; + using CampusAppWP8.Utility; + + /// + /// This Class is for ClubLinkFeeds + /// + public class ClubLinkFeed : XmlFeed + { + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public ClubLinkFeed() + : base(new Uri(Constants.UrlLink_ClubLinks, UriKind.Absolute), Constants.FileLink_ClubLinks) + { + } + + #endregion + + #region Method + + #region Protected + + /// + /// Method implement CheckIsModelUpToDate()-Method . + /// + /// true, if model is up-to-date, otherwise false + protected override bool CheckIsModelUpToDate() + { + DateTime lastModified = this.Model.CreateTime; + return this.CheckIsUpToDate(lastModified); + } + + /// + /// Method implement CheckIsFileUpToDate()-Method . + /// + /// true, if file is up-to-date, otherwise false + protected override bool CheckIsFileUpToDate() + { + DateTime lastModified = FileManager.GetFileInfo(FileName).LastWriteTime; + return this.CheckIsUpToDate(lastModified); + } + + #endregion + + #region Private + + /// + /// Check if the model or file is up-to-date. + /// + /// Date of the last modification + /// true, if is up-to-date, otherwise false + private bool CheckIsUpToDate(DateTime lastModified) + { + DateTime temp = lastModified.AddDays(1); + + int diff = temp.CompareTo(DateTime.Now); + + if (diff < 0) + { + return false; + } + + return true; + } + + #endregion + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs new file mode 100644 index 00000000..d1bd538c --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Feed/Link/CommonLinkFeed.cs @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Feed.Link +{ + using System; + using CampusAppWP8.Model.Link; + using CampusAppWP8.Resources; + using CampusAppWP8.Utility; + + /// + /// This Class is for CommonLinkFeeds + /// + public class CommonLinkFeed : XmlFeed + { + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public CommonLinkFeed() + : base(new Uri(Constants.UrlLink_CommonLinks, UriKind.Absolute), Constants.FileLink_CommonLinks) + { + } + + #endregion + + #region Method + + #region Protected + + /// + /// Method implement CheckIsModelUpToDate()-Method . + /// + /// true, if model is up-to-date, otherwise false + protected override bool CheckIsModelUpToDate() + { + DateTime lastModified = this.Model.CreateTime; + return this.CheckIsUpToDate(lastModified); + } + + /// + /// Method implement CheckIsFileUpToDate()-Method . + /// + /// true, if file is up-to-date, otherwise false + protected override bool CheckIsFileUpToDate() + { + DateTime lastModified = FileManager.GetFileInfo(FileName).LastWriteTime; + return this.CheckIsUpToDate(lastModified); + } + + #endregion + + #region Private + + /// + /// Check if the model or file is up-to-date. + /// + /// Date of the last modification + /// true, if is up-to-date, otherwise false + private bool CheckIsUpToDate(DateTime lastModified) + { + DateTime temp = lastModified.AddDays(1); + + int diff = temp.CompareTo(DateTime.Now); + + if (diff < 0) + { + return false; + } + + return true; + } + + #endregion + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs index e1c85c4e..ef3405ee 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs @@ -13,7 +13,7 @@ namespace CampusAppWP8.Api.Mensa using CampusAppWP8.Utility; /// - /// This Class is for MesaFeeds + /// This Class is for MensaFeeds /// public class MensaFeed : XmlFeed { diff --git a/CampusAppWP8/CampusAppWP8/Model/Link/LinkListModel.cs b/CampusAppWP8/CampusAppWP8/Model/Link/LinkListModel.cs new file mode 100644 index 00000000..c512e9ea --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Link/LinkListModel.cs @@ -0,0 +1,64 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.07.2013 +//----------------------------------------------------------------------------- + +namespace CampusAppWP8.Model.Link +{ + using System; + using System.Collections.ObjectModel; + using System.Xml.Serialization; + + /// + /// Model for a list of links. + /// + [XmlRoot("root")] + public class LinkListModel + { + #region Member + + /// + /// Time when the model was created. + /// + private readonly DateTime createTime; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public LinkListModel() + { + this.createTime = DateTime.Now; + } + + #endregion + + #region Property + + /// + /// Gets or sets feed information item list. + /// + [XmlArray("data")] + [XmlArrayItem("link")] + public ObservableCollection Links { get; set; } + + /// + /// Gets the creation time of the model. + /// + public DateTime CreateTime + { + get + { + return this.createTime; + } + } + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Link/LinkModel.cs b/CampusAppWP8/CampusAppWP8/Model/Link/LinkModel.cs new file mode 100644 index 00000000..fd36f338 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Link/LinkModel.cs @@ -0,0 +1,173 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.07.2013 +//----------------------------------------------------------------------------- + +namespace CampusAppWP8.Model.Link +{ + using System.Globalization; + using System.Xml.Serialization; + + /// + /// Model for menu + /// + public class LinkModel + { + #region Member + + /// + /// German version of the link title. + /// + private string titleDE = string.Empty; + + /// + /// English version of the link title. + /// + private string titleEN = string.Empty; + + /// + /// German version of the link. + /// + private string linkDE = string.Empty; + + /// + /// English version of the link. + /// + private string linkEN = string.Empty; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public LinkModel() + { + } + + #endregion + + #region Property + + /// + /// Gets or sets the german title of the link. + /// + [XmlAttribute("title_de")] + public string Title_DE + { + get + { + return this.titleDE; + } + + set + { + if (value != this.titleDE) + { + this.titleDE = value; + } + } + } + + /// + /// Gets or sets the english title of the link. + /// + [XmlAttribute("title_en")] + public string Title_EN + { + get + { + return this.titleEN; + } + + set + { + this.titleEN = value; + } + } + + /// + /// Gets or sets the german link. + /// + [XmlAttribute("link_de")] + public string Link_DE + { + get + { + return this.linkDE; + } + + set + { + if (value != this.linkDE) + { + this.linkDE = value; + } + } + } + + /// + /// Gets or sets the english link. + /// + [XmlAttribute("link_en")] + public string Link_EN + { + get + { + return this.linkEN; + } + + set + { + if (value != this.linkEN) + { + this.linkEN = value; + } + } + } + + /// + /// Gets the localized title. If the phone is set to german language, + /// the german title will be returned otherwise the english title. + /// + public string Title + { + get + { + if (CultureInfo.CurrentUICulture.Name.StartsWith("de")) + { + return this.titleDE; + } + else + { + return this.titleEN; + } + } + } + + /// + /// Gets the localized link. if the phone is set to german language, + /// the german comment will be returned otherwise the english link. + /// + public string Link + { + get + { + if (CultureInfo.CurrentUICulture.Name.StartsWith("de")) + { + return this.Link_DE; + } + else + { + return this.Link_EN; + } + } + } + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml index f0454ac3..c17b9ab7 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/LecturePage.xaml @@ -22,13 +22,15 @@ - - - - - - + + + + + + + + @@ -159,7 +161,7 @@ diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml index dfea3521..bc3d090b 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultDetailPage.xaml @@ -22,7 +22,8 @@ - + + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml index e82ed803..2f369ed6 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Lecture/ResultPage.xaml @@ -13,39 +13,6 @@ mc:Ignorable="d" shell:SystemTray.IsVisible="True"> - - - - - - - - - -