diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 6854c997..46158269 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -99,6 +99,7 @@ + @@ -121,6 +122,8 @@ + + CampusMapPage.xaml @@ -173,6 +176,9 @@ StartPage.xaml + + StudentCouncilPage.xaml + WebmailPage.xaml @@ -269,6 +275,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/CampusAppWP8/CampusAppWP8/Feed/StudentCouncil/StudentCouncilFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/StudentCouncil/StudentCouncilFeed.cs new file mode 100644 index 00000000..9925ac05 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Feed/StudentCouncil/StudentCouncilFeed.cs @@ -0,0 +1,83 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Feed.StudentCouncil +{ + using System; + using CampusAppWP8.Model.StudentCouncil; + using CampusAppWP8.Resources; + using CampusAppWP8.Utility; + + /// + /// This Class is for StudentCouncilFeed + /// + public class StudentCouncilFeed : XmlFeed + { + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public StudentCouncilFeed() + : base(new Uri(Constants.UrlStudentCouncil_StudentCouncils, UriKind.Absolute), Constants.FileStudentCouncil_StudentCouncils) + { + } + + #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/Model/Link/LinkModel.cs b/CampusAppWP8/CampusAppWP8/Model/Link/LinkModel.cs index fd36f338..d25e347d 100644 --- a/CampusAppWP8/CampusAppWP8/Model/Link/LinkModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Link/LinkModel.cs @@ -21,22 +21,22 @@ namespace CampusAppWP8.Model.Link /// /// German version of the link title. /// - private string titleDE = string.Empty; + private string titleDE; /// /// English version of the link title. /// - private string titleEN = string.Empty; + private string titleEN; /// /// German version of the link. /// - private string linkDE = string.Empty; + private string linkDE; /// /// English version of the link. /// - private string linkEN = string.Empty; + private string linkEN; #endregion diff --git a/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilListModel.cs b/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilListModel.cs new file mode 100644 index 00000000..1a935a1a --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilListModel.cs @@ -0,0 +1,80 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Model.StudentCouncil +{ + using System; + using System.Collections.Generic; + using System.Collections.ObjectModel; + using System.Linq; + using System.Xml.Serialization; + + /// + /// Model for menus in one week + /// + [XmlRoot("root")] + public class StudentCouncilListModel + { + #region Members + /// + /// Time when the model was created + /// + private readonly DateTime createTime; + + #endregion + #region Constructor + /// + /// Initializes a new instance of the class. + /// + public StudentCouncilListModel() + { + this.createTime = DateTime.Now; + } + + #endregion + + #region Proberty + /// + /// Gets or sets the StudentCouncils + /// + [XmlArray("data")] + [XmlArrayItem("studentcouncil")] + public ObservableCollection StudentCouncils { get; set; } + + /// + /// Gets the creation time of the model + /// + public DateTime CreateTime + { + get + { + return this.createTime; + } + } + + #endregion + + #region Method + /// + /// Method group the StudentCouncilList by Faculty + /// + /// a Dictionary, where the Key is name of the Faculty und the value is a List of StudentCouncil + public Dictionary> GetStudentCouncilsGroupByFaculty() + { + List> tmpList = this.StudentCouncils.GroupBy(p => p.Faculty).ToList(); + Dictionary> itemMap = new Dictionary>(); + foreach (IGrouping group in tmpList) + { + Dictionary> tempDic = new Dictionary>(); + itemMap.Add(group.Key, group.ToList()); + } + + return itemMap; + } + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilModel.cs b/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilModel.cs new file mode 100644 index 00000000..1009645e --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilModel.cs @@ -0,0 +1,86 @@ +//----------------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 02.07.2013 +//----------------------------------------------------------------------------- + +namespace CampusAppWP8.Model.StudentCouncil +{ + using System.Xml.Serialization; + using CampusAppWP8.Resources; + + /// + /// Model for menu + /// + public class StudentCouncilModel + { + #region Member + + /// + /// name of the faculty. + /// + private string faculty; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public StudentCouncilModel() + { + } + + #endregion + + #region Property + + /// + /// Gets or sets the faculty of the StudentCouncil. + /// + [XmlAttribute("faculty")] + public string Faculty + { + get + { + return this.faculty; + } + + set + { + if (value != this.faculty) + { + this.faculty = value; + int num; + if (int.TryParse(this.faculty, out num)) + { + this.faculty = AppResources.Faculty + " " + num; + } + } + } + } + + /// + /// Gets or sets the name of the StudentCouncil. + /// + [XmlAttribute("name")] + public string Name { get; set; } + + /// + /// Gets or sets the webpage-url of the StudentCouncil. + /// + [XmlAttribute("url")] + public string Url { get; set; } + + /// + /// Gets or sets the email-address of the StudentCouncil. + /// + [XmlAttribute("email")] + public string Email { get; set; } + + #endregion + } +} diff --git a/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml new file mode 100644 index 00000000..a2cde1cb --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml.cs new file mode 100644 index 00000000..52f690fe --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/StudentCouncil/StudentCouncilPage.xaml.cs @@ -0,0 +1,170 @@ +//----------------------------------------------------------------------- +// +// Company copyright tag. +// +// stubbfel +// 03.07.2013 +//---------------------------------------------------------------------- +namespace CampusAppWP8.Pages.StudentCouncil +{ + using System; + using System.Linq; + using System.Windows; + using System.Windows.Controls; + using System.Windows.Navigation; + using CampusAppWP8.Feed.StudentCouncil; + using CampusAppWP8.Utility; + using Microsoft.Phone.Controls; + using Microsoft.Phone.Tasks; + + /// + /// Class for the StudentCouncilPage + /// + public partial class StudentCouncilPage : PhoneApplicationPage + { + #region Members + + /// + /// the feed of the StudentCouncil + /// + private StudentCouncilFeed feed; + + /// + /// last visible UI element. + /// + private UIElement lastOpenUIElem = null; + + #endregion + + #region Constructor + + /// + /// Initializes a new instance of the class. + /// + public StudentCouncilPage() + { + this.InitializeComponent(); + this.InitializeFeed(); + } + + #endregion + + #region Method + + #region protected + + /// + /// Override the OnNavigatedTo method + /// + /// Arguments of navigation + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + if (this.feed == null) + { + this.InitializeFeed(); + } + + this.ProgressBar.Visibility = System.Windows.Visibility.Visible; + this.feed.LoadFeed(); + } + + #endregion + #region private + + /// + /// Method toggle the Visibility of the Link- and Details-Buttons + /// + /// Caller of the function + /// some EventArgs + private void ToggleOptions(object sender, RoutedEventArgs e) + { + if (this.lastOpenUIElem != null) + { + this.lastOpenUIElem.Visibility = Visibility.Collapsed; + } + + FrameworkElement btn = sender as FrameworkElement; + StackPanel parent = btn.Parent as StackPanel; + + if (parent.Children.Count() >= 2) + { + if (!parent.Children[1].Equals(this.lastOpenUIElem)) + { + this.lastOpenUIElem = parent.Children[1]; + this.lastOpenUIElem.Visibility = Visibility.Visible; + this.ProgressBar.Visibility = Visibility.Collapsed; + } + else + { + this.lastOpenUIElem = null; + } + } + } + + /// + /// Method navigate to StudentCouncilWebPage + /// + /// Caller of the function + /// some EventArgs + private void ShowWebpage(object sender, RoutedEventArgs e) + { + FrameworkElement linkBtn = sender as FrameworkElement; + if (linkBtn.Tag == null) + { + return; + } + + Uri linkUrl = new Uri(linkBtn.Tag as string, UriKind.Absolute); + WebBrowserTask webBrowserTask = new WebBrowserTask(); + webBrowserTask.Uri = linkUrl; + webBrowserTask.Show(); + } + + /// + /// Method initialize the Feed + /// + private void InitializeFeed() + { + this.feed = new StudentCouncilFeed(); + this.feed.EventHandler.FeedIsReadyEvent += new FeedEventHandler.FeedReadyHandler(this.FeedIsReady); + } + + /// + /// Method will be execute if the feed is ready + /// + private void FeedIsReady() + { + this.SetupStudentCouncilPivot(); + this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed; + } + + /// + /// Method set ItemSource + /// + private void SetupStudentCouncilPivot() + { + this.StudentCouncilPivot.ItemsSource = this.feed.Model.GetStudentCouncilsGroupByFaculty(); + } + + /// + /// Called on clicking on a mail button. + /// + /// button object + /// event args + private void ShowEmail(object sender, RoutedEventArgs e) + { + FrameworkElement tempUIElem = sender as FrameworkElement; + + string info = tempUIElem.Tag.ToString(); + + EmailComposeTask emailTask = new EmailComposeTask(); + emailTask.To = "mailto:" + info; + emailTask.Show(); + } + + #endregion + + #endregion + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml b/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml index 7eaa8266..c1e5572e 100644 --- a/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml +++ b/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml @@ -14,7 +14,7 @@ - + diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs index d3783dd3..b2b37f4e 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.Designer.cs @@ -78,6 +78,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die StudentCouncils.xml ähnelt. + /// + internal static string FileStudentCouncil_StudentCouncils { + get { + return ResourceManager.GetString("FileStudentCouncil_StudentCouncils", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die LectureModel ähnelt. /// @@ -303,6 +312,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/getdata.php?db=studentcouncils&app=2&appversion=1 ähnelt. + /// + internal static string UrlStudentCouncil_StudentCouncils { + get { + return ResourceManager.GetString("UrlStudentCouncil_StudentCouncils", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die https://webmail.tu-cottbus.de ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 1703b66c..17118a23 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -204,4 +204,10 @@ /Pages/Links/LinkPage.xaml + + StudentCouncils.xml + + + http://www.tu-cottbus.de/campusapp-data/getdata.php?db=studentcouncils&app=2&appversion=1 + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/pages/mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/pages/mensa/MensaPage.xaml.cs index ce0c6824..9239ebdf 100644 --- a/CampusAppWP8/CampusAppWP8/pages/mensa/MensaPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/pages/mensa/MensaPage.xaml.cs @@ -68,7 +68,7 @@ namespace CampusAppWP8.Pages.Mensa this.ProgressBar.Visibility = System.Windows.Visibility.Visible; this.feed.LoadFeed(); } - +#endregion #region private /// @@ -80,7 +80,7 @@ namespace CampusAppWP8.Pages.Mensa this.feed.EventHandler.FeedIsReadyEvent += new FeedEventHandler.FeedReadyHandler(this.FeedIsReady); this.CalcSelectedIndex(); } - #endregion + /// /// Method will be execute if the feed is ready @@ -132,7 +132,6 @@ namespace CampusAppWP8.Pages.Mensa this.selectedIndex = todayIndex; } #endregion - #endregion } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/utility/Feed.cs b/CampusAppWP8/CampusAppWP8/utility/Feed.cs index eafe14d5..9a118158 100644 --- a/CampusAppWP8/CampusAppWP8/utility/Feed.cs +++ b/CampusAppWP8/CampusAppWP8/utility/Feed.cs @@ -121,6 +121,7 @@ namespace CampusAppWP8.Utility { if (this.IsModelUpToDate()) { + this.EventHandler.FireFeedReadyevent(); return; }