diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 4e02ffa1..46158269 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -176,6 +176,9 @@ StartPage.xaml + + StudentCouncilPage.xaml + WebmailPage.xaml @@ -272,6 +275,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilListModel.cs b/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilListModel.cs index 23aad7bd..1a935a1a 100644 --- a/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilListModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilListModel.cs @@ -8,7 +8,9 @@ namespace CampusAppWP8.Model.StudentCouncil { using System; + using System.Collections.Generic; using System.Collections.ObjectModel; + using System.Linq; using System.Xml.Serialization; /// @@ -34,7 +36,7 @@ namespace CampusAppWP8.Model.StudentCouncil } #endregion - + #region Proberty /// /// Gets or sets the StudentCouncils @@ -55,5 +57,24 @@ namespace CampusAppWP8.Model.StudentCouncil } #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 index 5058b293..1009645e 100644 --- a/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/StudentCouncil/StudentCouncilModel.cs @@ -8,8 +8,8 @@ namespace CampusAppWP8.Model.StudentCouncil { - using System.Globalization; using System.Xml.Serialization; + using CampusAppWP8.Resources; /// /// Model for menu @@ -19,24 +19,9 @@ namespace CampusAppWP8.Model.StudentCouncil #region Member /// - /// German version of the link title. + /// name of the faculty. /// - 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; + private string faculty; #endregion @@ -57,7 +42,26 @@ namespace CampusAppWP8.Model.StudentCouncil /// Gets or sets the faculty of the StudentCouncil. /// [XmlAttribute("faculty")] - public string Faculty { get; set; } + 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. 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/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; }