Merge branch 'feature/#74' into develop

This commit is contained in:
stubbfel
2013-07-03 13:37:58 +02:00
12 changed files with 520 additions and 8 deletions

View File

@@ -99,6 +99,7 @@
<Compile Include="Feed\Link\CommonLinkFeed.cs" />
<Compile Include="Feed\Link\ClubLinkFeed.cs" />
<Compile Include="Feed\Openinghours\OpeninghoursFeed.cs" />
<Compile Include="Feed\StudentCouncil\StudentCouncilFeed.cs" />
<Compile Include="LocalizedStrings.cs" />
<Compile Include="Model\Campusmap\MapModel.cs" />
<Compile Include="Model\Campusmap\MapPinModel.cs" />
@@ -121,6 +122,8 @@
<Compile Include="Model\Mensa\MenuWeekModel.cs" />
<Compile Include="Model\Openinghours\OpeninghoursInstitutionModel.cs" />
<Compile Include="Model\Openinghours\OpeninghoursModel.cs" />
<Compile Include="Model\StudentCouncil\StudentCouncilListModel.cs" />
<Compile Include="Model\StudentCouncil\StudentCouncilModel.cs" />
<Compile Include="Model\Utility\UrlParamModel.cs" />
<Compile Include="Pages\Campusmap\CampusMapPage.xaml.cs">
<DependentUpon>CampusMapPage.xaml</DependentUpon>
@@ -173,6 +176,9 @@
<Compile Include="pages\StartPage.xaml.cs">
<DependentUpon>StartPage.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\StudentCouncil\StudentCouncilPage.xaml.cs">
<DependentUpon>StudentCouncilPage.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\Webmail\WebmailPage.xaml.cs">
<DependentUpon>WebmailPage.xaml</DependentUpon>
</Compile>
@@ -269,6 +275,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\StudentCouncil\StudentCouncilPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\Webmail\WebmailPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>

View File

@@ -0,0 +1,83 @@
//-----------------------------------------------------------------------
// <copyright file="StudentCouncilFeed.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>02.07.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Feed.StudentCouncil
{
using System;
using CampusAppWP8.Model.StudentCouncil;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
/// <summary>
/// This Class is for StudentCouncilFeed
/// </summary>
public class StudentCouncilFeed : XmlFeed<StudentCouncilListModel>
{
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="StudentCouncilFeed" /> class.
/// </summary>
public StudentCouncilFeed()
: base(new Uri(Constants.UrlStudentCouncil_StudentCouncils, UriKind.Absolute), Constants.FileStudentCouncil_StudentCouncils)
{
}
#endregion
#region Method
#region Protected
/// <summary>
/// Method implement CheckIsModelUpToDate()-Method <see cref="Pages"/>.
/// </summary>
/// <returns>true, if model is up-to-date, otherwise false</returns>
protected override bool CheckIsModelUpToDate()
{
DateTime lastModified = this.Model.CreateTime;
return this.CheckIsUpToDate(lastModified);
}
/// <summary>
/// Method implement CheckIsFileUpToDate()-Method <see cref="Pages"/>.
/// </summary>
/// <returns>true, if file is up-to-date, otherwise false</returns>
protected override bool CheckIsFileUpToDate()
{
DateTime lastModified = FileManager.GetFileInfo(FileName).LastWriteTime;
return this.CheckIsUpToDate(lastModified);
}
#endregion
#region Private
/// <summary>
/// Check if the model or file is up-to-date.
/// </summary>
/// <param name="lastModified">Date of the last modification</param>
/// <returns>true, if is up-to-date, otherwise false</returns>
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
}
}

View File

@@ -21,22 +21,22 @@ namespace CampusAppWP8.Model.Link
/// <summary>
/// German version of the link title.
/// </summary>
private string titleDE = string.Empty;
private string titleDE;
/// <summary>
/// English version of the link title.
/// </summary>
private string titleEN = string.Empty;
private string titleEN;
/// <summary>
/// German version of the link.
/// </summary>
private string linkDE = string.Empty;
private string linkDE;
/// <summary>
/// English version of the link.
/// </summary>
private string linkEN = string.Empty;
private string linkEN;
#endregion

View File

@@ -0,0 +1,80 @@
//-----------------------------------------------------------------------
// <copyright file="StudentCouncilListModel.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>02.07.2013</sience>
//----------------------------------------------------------------------
namespace CampusAppWP8.Model.StudentCouncil
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Xml.Serialization;
/// <summary>
/// Model for menus in one week
/// </summary>
[XmlRoot("root")]
public class StudentCouncilListModel
{
#region Members
/// <summary>
/// Time when the model was created
/// </summary>
private readonly DateTime createTime;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="StudentCouncilListModel" /> class.
/// </summary>
public StudentCouncilListModel()
{
this.createTime = DateTime.Now;
}
#endregion
#region Proberty
/// <summary>
/// Gets or sets the StudentCouncils
/// </summary>
[XmlArray("data")]
[XmlArrayItem("studentcouncil")]
public ObservableCollection<StudentCouncilModel> StudentCouncils { get; set; }
/// <summary>
/// Gets the creation time of the model
/// </summary>
public DateTime CreateTime
{
get
{
return this.createTime;
}
}
#endregion
#region Method
/// <summary>
/// Method group the StudentCouncilList by Faculty
/// </summary>
/// <returns>a Dictionary, where the Key is name of the Faculty und the value is a List of StudentCouncil</returns>
public Dictionary<string, List<StudentCouncilModel>> GetStudentCouncilsGroupByFaculty()
{
List<IGrouping<string, StudentCouncilModel>> tmpList = this.StudentCouncils.GroupBy(p => p.Faculty).ToList();
Dictionary<string, List<StudentCouncilModel>> itemMap = new Dictionary<string, List<StudentCouncilModel>>();
foreach (IGrouping<string, StudentCouncilModel> group in tmpList)
{
Dictionary<string, List<StudentCouncilModel>> tempDic = new Dictionary<string, List<StudentCouncilModel>>();
itemMap.Add(group.Key, group.ToList());
}
return itemMap;
}
#endregion
}
}

View File

@@ -0,0 +1,86 @@
//-----------------------------------------------------------------------------
// <copyright file="StudentCouncilModel.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>02.07.2013</sience>
//-----------------------------------------------------------------------------
namespace CampusAppWP8.Model.StudentCouncil
{
using System.Xml.Serialization;
using CampusAppWP8.Resources;
/// <summary>
/// Model for menu
/// </summary>
public class StudentCouncilModel
{
#region Member
/// <summary>
/// name of the faculty.
/// </summary>
private string faculty;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="StudentCouncilModel" /> class.
/// </summary>
public StudentCouncilModel()
{
}
#endregion
#region Property
/// <summary>
/// Gets or sets the faculty of the StudentCouncil.
/// </summary>
[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;
}
}
}
}
/// <summary>
/// Gets or sets the name of the StudentCouncil.
/// </summary>
[XmlAttribute("name")]
public string Name { get; set; }
/// <summary>
/// Gets or sets the webpage-url of the StudentCouncil.
/// </summary>
[XmlAttribute("url")]
public string Url { get; set; }
/// <summary>
/// Gets or sets the email-address of the StudentCouncil.
/// </summary>
[XmlAttribute("email")]
public string Email { get; set; }
#endregion
}
}

View File

@@ -0,0 +1,59 @@
<phone:PhoneApplicationPage
x:Class="CampusAppWP8.Pages.StudentCouncil.StudentCouncilPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<ProgressBar Name="ProgressBar" Visibility="Collapsed" IsIndeterminate="True"/>
<phone:Pivot Name="StudentCouncilPivot" Title="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}">
<phone:Pivot.HeaderTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Key}" />
</StackPanel>
</DataTemplate>
</phone:Pivot.HeaderTemplate>
<phone:Pivot.ItemTemplate>
<DataTemplate>
<ListBox x:Name="ListPanel" ItemsSource="{Binding Value}">
<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel>
<Button Content="{Binding Name}" Background="Gray" BorderBrush="Gray" Foreground="Black" Margin="-10,-10,-10,-10" Click="ToggleOptions"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Visibility="Collapsed">
<Button Name="Link" Tag="{Binding Url}" Click="ShowWebpage" Height="75">
<Image Source="{Binding Path=ThemelizedIcon.Link, Source={StaticResource ThemelizedIcons}}" />
</Button>
<Button Name="Email" Tag="{Binding Email}" Click="ShowEmail" Height="75">
<Image Source="{Binding Path=ThemelizedIcon.WebMail, Source={StaticResource ThemelizedIcons}}" />
</Button>
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</DataTemplate>
</phone:Pivot.ItemTemplate>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>

View File

@@ -0,0 +1,170 @@
//-----------------------------------------------------------------------
// <copyright file="StudentCouncilPage.xaml.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>stubbfel</author>
// <sience>03.07.2013</sience>
//----------------------------------------------------------------------
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;
/// <summary>
/// Class for the StudentCouncilPage
/// </summary>
public partial class StudentCouncilPage : PhoneApplicationPage
{
#region Members
/// <summary>
/// the feed of the StudentCouncil
/// </summary>
private StudentCouncilFeed feed;
/// <summary>
/// last visible UI element.
/// </summary>
private UIElement lastOpenUIElem = null;
#endregion
#region Constructor
/// <summary>
/// Initializes a new instance of the <see cref="StudentCouncilPage" /> class.
/// </summary>
public StudentCouncilPage()
{
this.InitializeComponent();
this.InitializeFeed();
}
#endregion
#region Method
#region protected
/// <summary>
/// Override the OnNavigatedTo method
/// </summary>
/// <param name="e">Arguments of navigation</param>
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
/// <summary>
/// Method toggle the Visibility of the Link- and Details-Buttons
/// </summary>
/// <param name="sender">Caller of the function</param>
/// <param name="e">some EventArgs</param>
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;
}
}
}
/// <summary>
/// Method navigate to StudentCouncilWebPage
/// </summary>
/// <param name="sender">Caller of the function</param>
/// <param name="e">some EventArgs</param>
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();
}
/// <summary>
/// Method initialize the Feed
/// </summary>
private void InitializeFeed()
{
this.feed = new StudentCouncilFeed();
this.feed.EventHandler.FeedIsReadyEvent += new FeedEventHandler.FeedReadyHandler(this.FeedIsReady);
}
/// <summary>
/// Method will be execute if the feed is ready
/// </summary>
private void FeedIsReady()
{
this.SetupStudentCouncilPivot();
this.ProgressBar.Visibility = System.Windows.Visibility.Collapsed;
}
/// <summary>
/// Method set ItemSource
/// </summary>
private void SetupStudentCouncilPivot()
{
this.StudentCouncilPivot.ItemsSource = this.feed.Model.GetStudentCouncilsGroupByFaculty();
}
/// <summary>
/// Called on clicking on a mail button.
/// </summary>
/// <param name="sender">button object</param>
/// <param name="e">event args</param>
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
}
}

View File

@@ -14,7 +14,7 @@
<Capability Name="ID_CAP_PHONEDIALER" />
</Capabilities>
<Tasks>
<DefaultTask Name="_default" NavigationPage="pages/StartPage.xaml" />
<DefaultTask Name="_default" NavigationPage="pages/StudentCouncil/StudentCouncilPage.xaml" />
</Tasks>
<Tokens>
<PrimaryToken TokenID="CampusAppWP8Token" TaskName="_default">

View File

@@ -78,6 +78,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die StudentCouncils.xml ähnelt.
/// </summary>
internal static string FileStudentCouncil_StudentCouncils {
get {
return ResourceManager.GetString("FileStudentCouncil_StudentCouncils", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die LectureModel ähnelt.
/// </summary>
@@ -303,6 +312,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/getdata.php?db=studentcouncils&amp;app=2&amp;appversion=1 ähnelt.
/// </summary>
internal static string UrlStudentCouncil_StudentCouncils {
get {
return ResourceManager.GetString("UrlStudentCouncil_StudentCouncils", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die https://webmail.tu-cottbus.de ähnelt.
/// </summary>

View File

@@ -204,4 +204,10 @@
<data name="PathLinks_LinkPage" xml:space="preserve">
<value>/Pages/Links/LinkPage.xaml</value>
</data>
<data name="FileStudentCouncil_StudentCouncils" xml:space="preserve">
<value>StudentCouncils.xml</value>
</data>
<data name="UrlStudentCouncil_StudentCouncils" xml:space="preserve">
<value>http://www.tu-cottbus.de/campusapp-data/getdata.php?db=studentcouncils&amp;app=2&amp;appversion=1</value>
</data>
</root>

View File

@@ -68,7 +68,7 @@ namespace CampusAppWP8.Pages.Mensa
this.ProgressBar.Visibility = System.Windows.Visibility.Visible;
this.feed.LoadFeed();
}
#endregion
#region private
/// <summary>
@@ -80,7 +80,7 @@ namespace CampusAppWP8.Pages.Mensa
this.feed.EventHandler.FeedIsReadyEvent += new FeedEventHandler.FeedReadyHandler(this.FeedIsReady);
this.CalcSelectedIndex();
}
#endregion
/// <summary>
/// Method will be execute if the feed is ready
@@ -132,7 +132,6 @@ namespace CampusAppWP8.Pages.Mensa
this.selectedIndex = todayIndex;
}
#endregion
#endregion
}
}

View File

@@ -121,6 +121,7 @@ namespace CampusAppWP8.Utility
{
if (this.IsModelUpToDate())
{
this.EventHandler.FireFeedReadyevent();
return;
}