diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 880f1859..19f0fb80 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -97,10 +97,12 @@ App.xaml - - - - + + + + + + @@ -109,14 +111,22 @@ - + CampusMapPage.xaml - + + + DepartmentPage.xaml - - + + + EventIndexPage.xaml + + + EventPage.xaml + + LecturePage.xaml @@ -134,17 +144,18 @@ MensaPage.xaml - + + + NewsIndexPage.xaml + + NewsPage.xaml - - - RSSNewsTemplate.xaml - - + + StartPage.xaml - + WebmailPage.xaml @@ -173,11 +184,11 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile @@ -197,23 +208,31 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + + + MSBuild:Compile + Designer + MSBuild:Compile Designer - + Designer MSBuild:Compile - + Designer MSBuild:Compile - + Designer MSBuild:Compile - + MSBuild:Compile Designer @@ -279,6 +298,7 @@ PublicResXFileCodeGenerator AppResources.Designer.cs + Designer ResXFileCodeGenerator diff --git a/CampusAppWP8/CampusAppWP8/Feed/Departments/DepartmentFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Departments/DepartmentFeed.cs new file mode 100644 index 00000000..27402138 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Feed/Departments/DepartmentFeed.cs @@ -0,0 +1,37 @@ +using CampusAppWP8.Model.Departments; +using CampusAppWP8.Utility; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CampusAppWP8.Feed.Departments +{ + class DepartmentFeed : XmlFeed + { + public DepartmentFeed() : base(URLList.DepartmentFeedURL, "DepartmentFeed.xml") + { + + } + public System.Collections.ObjectModel.ObservableCollection _faculties { get; set; } + + /// + /// Method implement CheckIsModelUpToDate()-Method + /// + /// true, if model is up-to-date, otherwise false + protected override bool CheckIsModelUpToDate() + { + return false; + } + + /// + /// Method implement CheckIsFileUpToDate()-Method + /// + /// true, if file is up-to-date, otherwise false + protected override bool CheckIsFileUpToDate() + { + return false; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Feed/Events/EventFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Events/EventFeed.cs new file mode 100644 index 00000000..29cd3f77 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Feed/Events/EventFeed.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using CampusAppWP8.Model.events_news; +using CampusAppWP8.Utility; + +namespace CampusAppWP8.Feed.Events +{ + /// + /// Event Feed. + /// + public class EventFeed : XmlFeed + { + /// + /// Default constructor. + /// + public EventFeed() : base(URLList.EventsFeedURL, "EventFeed.xml") + { + } + /// + /// Method implement CheckIsModelUpToDate()-Method + /// + /// true, if model is up-to-date, otherwise false + protected override bool CheckIsModelUpToDate() + { + return false; + } + + /// + /// Method implement CheckIsFileUpToDate()-Method + /// + /// true, if file is up-to-date, otherwise false + protected override bool CheckIsFileUpToDate() + { + return true; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Feed/News/NewsFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/News/NewsFeed.cs new file mode 100644 index 00000000..f74e989c --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Feed/News/NewsFeed.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +using CampusAppWP8.Model.events_news; +using CampusAppWP8.Utility; + +namespace CampusAppWP8.Feed.News +{ + /// + /// News Feed. + /// + public class NewsFeed : XmlFeed + { + /// + /// Default constructor. + /// + public NewsFeed() : base(URLList.NewsFeedURL, "NewsFeed.xml") + { + } + + /// + /// Method implement CheckIsModelUpToDate()-Method + /// + /// true, if model is up-to-date, otherwise false + protected override bool CheckIsModelUpToDate() + { + return false; + } + + /// + /// Method implement CheckIsFileUpToDate()-Method + /// + /// true, if file is up-to-date, otherwise false + protected override bool CheckIsFileUpToDate() + { + return true; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Departments/ChairModel.cs b/CampusAppWP8/CampusAppWP8/Model/Departments/ChairModel.cs new file mode 100644 index 00000000..c98aadc2 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Departments/ChairModel.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Xml.Serialization; + +namespace CampusAppWP8.Model.Departments +{ + /// + /// Class to hold information about a professorship chair. + /// + public class ChairModel : BaseModel + { + private string name_de; // german name of the chair + private string url; // link-url to the chair homepage + private string name_en; // english name of the chair + + /// + /// Default Constructor. Set every class variable to default value. + /// + public ChairModel() + { + this.name_de = String.Empty; + this.name_en = String.Empty; + this.url = String.Empty; + } + + /// + /// Constructor. Set the german and english name. + /// + /// Name of the professorship chair. + public ChairModel(string name) + { + this.name_de = name; + this.name_en = name; + this.url = String.Empty; + } + + /// + /// Set or return the german name of the chair. + /// + [XmlAttribute("name_de")] + public string Name_DE + { + get { return this.name_de; } + set + { + if (value != this.name_de) + { + this.name_de = value; + NotifyPropertyChanged("chair"); + } + } + } + + /// + /// Set or return the english name of the chair. + /// + [XmlAttribute("name_en")] + public string Name_EN + { + get { return this.name_en; } + set + { + if (value != this.name_en) + { + this.name_en = value; + NotifyPropertyChanged("chair"); + } + } + } + + /// + /// Set or return the url of the chair homepage. + /// + [XmlAttribute("url")] + public string Url + { + get { return this.url; } + set + { + if (value != this.url) + { + this.url = value; + NotifyPropertyChanged("chair"); + } + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/model/departments/DepartmentModel.cs b/CampusAppWP8/CampusAppWP8/Model/Departments/DepartmentModel.cs similarity index 66% rename from CampusAppWP8/CampusAppWP8/model/departments/DepartmentModel.cs rename to CampusAppWP8/CampusAppWP8/Model/Departments/DepartmentModel.cs index 0caa7504..ab547308 100644 --- a/CampusAppWP8/CampusAppWP8/model/departments/DepartmentModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Departments/DepartmentModel.cs @@ -3,26 +3,32 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Text; +using System.Windows; +using System.Xml.Serialization; -namespace CampusAppWP8.Model.departments +namespace CampusAppWP8.Model.Departments { public class DepartmentModel : BaseModel { - private ObservableCollection _chairs = null; - private string _name; - + [XmlElement("chair")] + public ObservableCollection _chairs { get; set; } + + private string _name = "d_mod"; + private Visibility visible; public DepartmentModel() { + this.visible = Visibility.Collapsed; this.Chairs = new ObservableCollection(); - this.LoadData(); + //this.LoadData(); } public DepartmentModel(string name) { + this.visible = Visibility.Collapsed; _name = name; this.Chairs = new ObservableCollection(); - this.LoadData(); + //this.LoadData(); } public void LoadData() @@ -64,5 +70,17 @@ namespace CampusAppWP8.Model.departments } } } + + public Visibility Visible + { + get { return this.visible; } + set + { + if (value != this.visible) + { + this.visible = value; + } + } + } } } diff --git a/CampusAppWP8/CampusAppWP8/model/departments/DepartmentViewModel.cs b/CampusAppWP8/CampusAppWP8/Model/Departments/DepartmentViewModel.cs similarity index 55% rename from CampusAppWP8/CampusAppWP8/model/departments/DepartmentViewModel.cs rename to CampusAppWP8/CampusAppWP8/Model/Departments/DepartmentViewModel.cs index daf6dee8..5b57d3c6 100644 --- a/CampusAppWP8/CampusAppWP8/model/departments/DepartmentViewModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/Departments/DepartmentViewModel.cs @@ -4,26 +4,20 @@ using System.Collections.ObjectModel; using System.Linq; using System.Text; using System.Threading.Tasks; +using System.Xml.Serialization; -namespace CampusAppWP8.Model.departments +namespace CampusAppWP8.Model.Departments { + [XmlRoot("root")] public class DepartmentViewModel : BaseViewModel { - private ObservableCollection _faculties = null; + [XmlArray("professorships")] + [XmlArrayItem("faculty")] + public ObservableCollection _faculties { get; set; } - public DepartmentViewModel() + public DepartmentViewModel() { this.Faculties = new ObservableCollection(); - this.LoadData(); - } - - public void LoadData() - { - this.Faculties.Add(new FacultyModel("Fakultät 1")); - this.Faculties.Add(new FacultyModel("Fakultät 2")); - this.Faculties.Add(new FacultyModel("Fakultät 3")); - this.Faculties.Add(new FacultyModel("Fakultät 4")); - this.Faculties.Add(new FacultyModel("Favoriten")); } public ObservableCollection Faculties diff --git a/CampusAppWP8/CampusAppWP8/Model/Departments/FacultyModel.cs b/CampusAppWP8/CampusAppWP8/Model/Departments/FacultyModel.cs new file mode 100644 index 00000000..3ceea2a8 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Departments/FacultyModel.cs @@ -0,0 +1,62 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Xml.Serialization; +using CampusAppWP8.Resources; + +namespace CampusAppWP8.Model.Departments +{ + public class FacultyModel : BaseModel + { + [XmlElement("chair")] + public ObservableCollection chairs { get; set; } + //public ObservableCollection _faculties { get; set; } + + private string name = "t_fak"; + + public FacultyModel() + { + //this.Faculties = new ObservableCollection(); + this.chairs = new ObservableCollection(); + } + + public FacultyModel(string name) + { + this.name = name; + //this.Faculties = new ObservableCollection(); + this.chairs = new ObservableCollection(); + } + + public ObservableCollection Chairs + { + get { return this.chairs; } + set + { + if (value != this.chairs) + { + this.chairs = value; + NotifyPropertyChanged("faculty"); + } + } + } + + [XmlAttribute("id")] + public string Name + { + get + { + return AppResources.Faculty + " " + this.name; + } + set + { + if (value != this.name) + { + this.name = value; + NotifyPropertyChanged("faculty"); + } + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Events/RSSChannelModel.cs b/CampusAppWP8/CampusAppWP8/Model/Events/RSSChannelModel.cs new file mode 100644 index 00000000..2e8bc8aa --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Events/RSSChannelModel.cs @@ -0,0 +1,45 @@ +using CampusAppWP8.Model; +using System.Collections.ObjectModel; +using System.Xml.Serialization; + +namespace CampusAppWP8.Model.events_news +{ + /// + /// Channel Model, which contains the rss feed item list. + /// + public class RSSChannelModel : BaseModel + { + /// + /// RssFeed information item list. + /// + [XmlElement("item")] + public ObservableCollection item { get; set; } + + /// + /// Default constructor. + /// + public RSSChannelModel() + { + this.item = new ObservableCollection(); + } + + /// + /// Set/Get the rss feed item list. + /// + public ObservableCollection Item + { + get + { + return this.item; + } + set + { + if (value != this.item) + { + this.item = value; + NotifyPropertyChanged("item"); + } + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Events/RSSModel.cs b/CampusAppWP8/CampusAppWP8/Model/Events/RSSModel.cs new file mode 100644 index 00000000..19d53cb9 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Events/RSSModel.cs @@ -0,0 +1,204 @@ +using CampusAppWP8.Model; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Xml.Serialization; + +namespace CampusAppWP8.Model.events_news +{ + /// + /// Contains the rss feed informations. + /// + public class RSSModel : BaseModel + { + /// + /// Title of the fees + /// + private string title; + /// + /// Description text of the feed. + /// + private string text; + /// + /// Timestamp (publication date) of the event or news. + /// + private DateTime timestamp; + /// + /// Url of the feed. + /// + private string link; + + /// + /// Set/Get the title of the feed. + /// + [XmlElement("title")] + public string Title + { + get { return this.title; } + set + { + if (this.title != value) + { + this.title = value; + NotifyPropertyChanged("rss"); + } + } + } + + /// + /// Set/Get the text of the feed. + /// + [XmlElement("description")] + public string Text + { + get { return this.text; } + set + { + if (this.text != HTMLUnicodeToString(value)) + { + this.text = HTMLUnicodeToString(value); + NotifyPropertyChanged("rss"); + } + } + } + + /// + /// Set/Get the timestamp of the feed as string. + /// + [XmlElement("pubDate")] + public string Timestamp + { + get { return this.timestamp.ToString("R"); } + set + { + if (this.timestamp != DateTime.Parse(value)) + { + this.timestamp = DateTime.Parse(value); + NotifyPropertyChanged("rss"); + } + } + } + + /// + /// Set/Get the timestamp of the feed as DateTime object. + /// + public DateTime DTTimestamp + { + get { return this.timestamp; } + set { this.timestamp = value; } + } + + /// + /// Return the date of the timestamp as string. + /// example: Mon, 25.06.2013. + /// + public string Date + { + get { return String.Format("{0:ddd, dd.MM.yyyy}", this.timestamp); } + } + + /// + /// Return the time of the timestamp as string. + /// example: 12:56 Uhr. + /// + public string Time + { + get { return String.Format("{0:h:mm} Uhr", this.timestamp); } + } + + /// + /// Set/Get the link/url of the feed. + /// + [XmlElement("link")] + public string Link + { + get { return this.link; } + set + { + if (this.link != value) + { + this.link = value; + NotifyPropertyChanged("rss"); + } + } + } + + /// + /// Remove or transform html-unicode specific tags into ascii. + /// + /// html string + /// ascii string + private string HTMLUnicodeToString(string htmluni) + { + StringBuilder retValue = new StringBuilder(); + + for(int i = 0; i < htmluni.Length; i++) + { + switch (htmluni[i]) + { + // beginning tag of the unicode + case '&': + { + int startOff = i + 2; + // sear closing tag of the unicode + int endOff = htmluni.IndexOf(';', startOff); + // get and parse value inbetween + string sub = htmluni.Substring(startOff, endOff - startOff); + int cVal = int.Parse(sub); + + switch (cVal) + { + // if the unicode value is 128 (€) + case 128: + retValue.Append('€'); + break; + + default: + retValue.Append((char)cVal); + break; + } + + // set the current index to the end of the unicode tag + i = endOff; + } + break; + case '<': + { + // ignoring <..> html tags + i = htmluni.IndexOf('>', i); + } + break; + case '\t': + // removing tabs + break; + + default: + { + // adding other characters to the return string + retValue.Append(htmluni[i]); + } + break; + } + } + + return retValue.ToString(); + } + + /// + /// Comparing function for Datetime-Timestamps. + /// (currently unused) + /// + /// first item + /// secound item + /// + public static int CompareTimeStamp(RSSModel item1, RSSModel item2) + { + if (item1.DTTimestamp > item2.DTTimestamp) + return -1; + else + return 0; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/Events/RSSViewModel.cs b/CampusAppWP8/CampusAppWP8/Model/Events/RSSViewModel.cs new file mode 100644 index 00000000..a9625df9 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Model/Events/RSSViewModel.cs @@ -0,0 +1,47 @@ +using CampusAppWP8.Model; +using System.Collections.ObjectModel; +using System.Xml.Serialization; + +namespace CampusAppWP8.Model.events_news +{ + /// + /// ViewModel of the rss feed, containing the feed/channel object. + /// + [XmlRoot("root")] + public class RSSViewModel : BaseViewModel + { + /// + /// channel list for the rss feeds. + /// + [XmlArray("rss")] + [XmlArrayItem("channel")] + public ObservableCollection channel { get; set; } + + /// + /// Default constructor. + /// + public RSSViewModel() + { + this.channel = new ObservableCollection(); + } + + /// + /// Set/Get the channel list. + /// + public ObservableCollection Channel + { + get + { + return this.channel; + } + set + { + if (value != this.channel) + { + this.channel = value; + NotifyPropertyChanged("channel"); + } + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/pages/campusmap/CampusMapPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml similarity index 97% rename from CampusAppWP8/CampusAppWP8/pages/campusmap/CampusMapPage.xaml rename to CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml index ef15c95a..7919009f 100644 --- a/CampusAppWP8/CampusAppWP8/pages/campusmap/CampusMapPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml @@ -6,7 +6,7 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:Location="clr-namespace:System.Device.Location;assembly=System.Device" - x:Class="CampusAppWP8.Pages.campusmap.CampusMapPage" + x:Class="CampusAppWP8.Pages.Campusmap.CampusMapPage" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" diff --git a/CampusAppWP8/CampusAppWP8/pages/campusmap/CampusMapPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs similarity index 93% rename from CampusAppWP8/CampusAppWP8/pages/campusmap/CampusMapPage.xaml.cs rename to CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs index 5f3fbb66..9e4cd703 100644 --- a/CampusAppWP8/CampusAppWP8/pages/campusmap/CampusMapPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/CampusMapPage.xaml.cs @@ -8,7 +8,7 @@ using System.Windows.Navigation; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; -namespace CampusAppWP8.Pages.campusmap +namespace CampusAppWP8.Pages.Campusmap { public partial class CampusMapPage : PhoneApplicationPage { diff --git a/CampusAppWP8/CampusAppWP8/pages/departments/DepartmentPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentPage.xaml similarity index 54% rename from CampusAppWP8/CampusAppWP8/pages/departments/DepartmentPage.xaml rename to CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentPage.xaml index d09797e6..3049f3c9 100644 --- a/CampusAppWP8/CampusAppWP8/pages/departments/DepartmentPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentPage.xaml @@ -1,12 +1,12 @@  - + - + - + - - + + + - + - + + + + + + + + + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentPage.xaml.cs new file mode 100644 index 00000000..2d71e3cd --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Departments/DepartmentPage.xaml.cs @@ -0,0 +1,131 @@ +using CampusAppWP8.Feed.Departments; +using CampusAppWP8.Pages.Departments; +using CampusAppWP8.Utility; +using Microsoft.Phone.Controls; +using Microsoft.Phone.Tasks; +using System; +using System.Linq; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Navigation; + + +namespace CampusAppWP8.Pages.Departments +{ + /// + /// Pivot page with list of the chairs of the facultis. + /// + public partial class DepartmentPage : PhoneApplicationPage + { + /// + /// Stores the last visible department panel. + /// + private UIElement lastVisibleUIElem = null; + /// + /// department/chair feed object, storing the model and data. + /// + private DepartmentFeed feed { get; set; } + + /// + /// Default constructor. + /// + public DepartmentPage() + { + InitializeComponent(); + // init feed object + this.feed = new DepartmentFeed(); + } + + /// + /// On naviagtion to this page. + /// Init the feed loading. + /// + /// event args + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + + this.feed.EventHandler.FeedIsReadyEvent += new FeedEventHandler.FeedReadyHandler(SetupDepartmentPivot); + this.feed.LoadFeed(); + } + + /// + /// Called after the feeds are loaded. + /// Set the pivotitem source of this page. + /// + private void SetupDepartmentPivot() + { + DepartmentPivot.ItemsSource = feed.Model._faculties; + } + + /// + /// On orientation changed. + /// + /// unused + /// unused + private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e) + { + } + + /// + /// Called at clicking on the department headline buttons. + /// Collapses all visible department panels and open (set to visible) + /// the clicked department list. + /// + /// clicked department button + /// unused + private void DepartmentBtn_Click(object sender, RoutedEventArgs e) + { + // if the sender was a button + if(sender is Button) + { + Button btn = sender as Button; + + // if the parent is a stackpanel + if(btn.Parent is StackPanel) + { + StackPanel pan = (StackPanel)btn.Parent; + + // if there is a child after the clicked button in the parent panel + if ((pan.Children.Count() > 1) && (pan.Children[1] != null)) + { + // if the clicked department wasn't the one clicked before + if (pan.Children[1] != this.lastVisibleUIElem) + { + // collapse the last visible chair list + if (this.lastVisibleUIElem != null) + this.lastVisibleUIElem.Visibility = Visibility.Collapsed; + + // open the choosen chair list + pan.Children[1].Visibility = Visibility.Visible; + this.lastVisibleUIElem = pan.Children[1]; + } + } + } + } + } + + /// + /// On clicking a chair textbolock. + /// Open the browser with the url of the chair. + /// + /// clicked chair textblock + /// + private void ChairTB_Click(object sender, RoutedEventArgs e) + { + if (sender is FrameworkElement) + { + FrameworkElement btn = sender as FrameworkElement; + + // if the chair has a url in the tag element + if ((btn.Tag != null) && ((btn.Tag as string).Length > 0)) + { + // open browser with the url + WebBrowserTask task = new WebBrowserTask(); + task.Uri = new Uri(btn.Tag.ToString(), UriKind.Absolute); + task.Show(); + } + } + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml new file mode 100644 index 00000000..1c4b30c8 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml.cs new file mode 100644 index 00000000..3db3df1f --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Events/EventIndexPage.xaml.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Navigation; +using Microsoft.Phone.Controls; +using Microsoft.Phone.Shell; + +using CampusAppWP8.Model.events_news; +using CampusAppWP8.Utility; +using CampusAppWP8.Resources; +using System.Collections.ObjectModel; +using CampusAppWP8.Feed.Events; + +namespace CampusAppWP8.Pages.Events +{ + /// + /// Overview page of all events. + /// + public partial class EventIndexPage : PhoneApplicationPage + { + /// + /// Event Feed object, which contains the rss models and data. + /// + public static EventFeed eventFeed { get; set; } + + /// + /// Default constructor. + /// + public EventIndexPage() + { + InitializeComponent(); + EventIndexPage.eventFeed = new EventFeed(); + } + + /// + /// On navigation to this page, creates a FeedEventHandler and load the rss feed data. + /// + /// event args + protected override void OnNavigatedTo(NavigationEventArgs e) + { + base.OnNavigatedTo(e); + + // Set handler and load the fees informations. + EventIndexPage.eventFeed.EventHandler.FeedIsReadyEvent += new FeedEventHandler.FeedReadyHandler(SetupEventPageList); + EventIndexPage.eventFeed.LoadFeed(); + } + + /// + /// Is called after the rss feeds are loaded into the eventFeed model. + /// If there was no feed informations set to the ui, the feed list + /// will be sorted by timestamp and the buttons will be created. + /// + private void SetupEventPageList() + { + if ((EventIndexPage.eventFeed.Model != null) + && (EventIndexPage.eventFeed.Model.Channel != null) + && (EventIndexPage.eventFeed.Model.Channel.Count() >= 1) + && (this.ButtonPanel.Items.Count() == 0)) + { + // Sort the list of rssfeeds. + IEnumerable tempList = EventIndexPage.eventFeed.Model.Channel[0].item.OrderByDescending(e => e.DTTimestamp); + EventIndexPage.eventFeed.Model.Channel[0].item = new ObservableCollection(tempList); + + // Create the buttons for the fees selection and add it to the buttonpanel. + for (int i = 0; i < EventIndexPage.eventFeed.Model.Channel[0].item.Count(); i++) + { + Button tempBtn = new Button(); + tempBtn.Name = "EventRowAppButton"; + tempBtn.Content = EventIndexPage.eventFeed.Model.Channel[0].item[i].Title; + tempBtn.VerticalContentAlignment = VerticalAlignment.Stretch; + tempBtn.HorizontalContentAlignment = HorizontalAlignment.Stretch; + tempBtn.BorderThickness = new Thickness(0.0); + tempBtn.Padding = new Thickness(0.0); + tempBtn.Click += EventRowAppButton_Click; + tempBtn.Tag = i; + + this.ButtonPanel.Items.Add(tempBtn); + } + } + } + + /// + /// Return the eventFeed object. + /// + static public EventFeed GetEventFeed + { + get { return EventIndexPage.eventFeed; } + set { } + } + + /// + /// Is called on clicking on a feed button. + /// Navigates to the event pivot page with the information of the + /// selected feed index. + /// + /// pressed button object + /// event args + private void EventRowAppButton_Click(object sender, RoutedEventArgs e) + { + FrameworkElement tempElem = sender as FrameworkElement; + + NavigationService.Navigate(new Uri("/pages/events/EventPage.xaml?pivotindex=" + tempElem.Tag, UriKind.Relative)); + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml new file mode 100644 index 00000000..e5782082 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/Events/EventPage.xaml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +