events and news page changed and commited

This commit is contained in:
Christian Fiedler
2013-06-10 18:50:28 +02:00
parent 1265e916c7
commit 13c2e96867
24 changed files with 917 additions and 460 deletions

View File

@@ -102,6 +102,8 @@
<Compile Include="model\departments\DepartmentModel.cs" />
<Compile Include="model\departments\DepartmentViewModel.cs" />
<Compile Include="model\departments\FacultyModel.cs" />
<Compile Include="model\events_news\RSSChannelModel.cs" />
<Compile Include="model\events_news\RSSViewModel.cs" />
<Compile Include="model\mensa\MenuModel.cs" />
<Compile Include="model\mensa\MenuWeekModel.cs" />
<Compile Include="pages\campusmap\CampusMapPage.xaml.cs">
@@ -111,6 +113,13 @@
<Compile Include="pages\departments\DepartmentPage.xaml.cs">
<DependentUpon>DepartmentPage.xaml</DependentUpon>
</Compile>
<Compile Include="pages\events\EventFeed.cs" />
<Compile Include="pages\events\EventIndexPage.xaml.cs">
<DependentUpon>EventIndexPage.xaml</DependentUpon>
</Compile>
<Compile Include="pages\events\EventPage.xaml.cs">
<DependentUpon>EventPage.xaml</DependentUpon>
</Compile>
<Compile Include="pages\lecture\LecturePage.xaml.cs">
<DependentUpon>LecturePage.xaml</DependentUpon>
</Compile>
@@ -120,13 +129,14 @@
<Compile Include="pages\mensa\MensaPage.xaml.cs">
<DependentUpon>MensaPage.xaml</DependentUpon>
</Compile>
<Compile Include="pages\news\NewsFeed.cs" />
<Compile Include="pages\news\NewsIndexPage.xaml.cs">
<DependentUpon>NewsIndexPage.xaml</DependentUpon>
</Compile>
<Compile Include="pages\news\NewsPage.xaml.cs">
<DependentUpon>NewsPage.xaml</DependentUpon>
</Compile>
<Compile Include="pages\RSSItem.cs" />
<Compile Include="pages\news\RSSNewsTemplate.xaml.cs">
<DependentUpon>RSSNewsTemplate.xaml</DependentUpon>
</Compile>
<Compile Include="model\events_news\RSSModel.cs" />
<Compile Include="pages\StartPage.xaml.cs">
<DependentUpon>StartPage.xaml</DependentUpon>
</Compile>
@@ -177,6 +187,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="pages\events\EventIndexPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="pages\events\EventPage.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="pages\lecture\LecturePage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
@@ -185,11 +203,11 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="pages\news\NewsPage.xaml">
<Page Include="pages\news\NewsIndexPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="pages\news\RSSNewsTemplate.xaml">
<Page Include="pages\news\NewsPage.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>

View File

@@ -13,7 +13,7 @@
<Capability Name="ID_CAP_ISV_CAMERA" />
</Capabilities>
<Tasks>
<DefaultTask Name="_default" NavigationPage="pages/departments/DepartmentPage.xaml" />
<DefaultTask Name="_default" NavigationPage="pages/news/NewsIndexPage.xaml" />
</Tasks>
<Tokens>
<PrimaryToken TokenID="CampusAppWP8Token" TaskName="_default">

View File

@@ -1,5 +1,4 @@
<<<<<<< HEAD
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
// <auto-generated>
// Dieser Code wurde von einem Tool generiert.
// Laufzeitversion:4.0.30319.18046
@@ -422,5 +421,3 @@ namespace CampusAppWP8.Resources {
}
}
}

View File

@@ -230,10 +230,13 @@
<data name="NewsHomeBtn" xml:space="preserve">
<value>zur Übersicht</value>
</data>
<data name="Faculty" xml:space="preserve">
<value>Fakultät</value>
</data>
<data name="Professorship_chairs" xml:space="preserve">
<value>Lehrstühle</value>
</data>
<data name="Faculty" xml:space="preserve">
<value>Fakultät</value>
</data>
<data name="Professorship_chairs" xml:space="preserve">
<value>Lehrstühle</value>
</data>
<data name="NewsLinkBtn" xml:space="preserve">
<value>Link</value>
</data>
</root>

View File

@@ -18,19 +18,6 @@ namespace CampusAppWP8.model.departments
public DepartmentViewModel()
{
this.Faculties = new ObservableCollection<FacultyModel>();
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<FacultyModel> Faculties

View File

@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
using System.Collections.ObjectModel;
namespace CampusAppWP8.model.events_news
{
/// <summary>
/// Channel Model, which contains the rss feed item list.
/// </summary>
public class RSSChannelModel : BaseModel
{
/// <summary>
/// RssFeed information item list.
/// </summary>
[XmlElement("item")]
public ObservableCollection<RSSModel> item { get; set; }
/// <summary>
/// Default constructor.
/// </summary>
public RSSChannelModel()
{
this.item = new ObservableCollection<RSSModel>();
}
/// <summary>
/// Set/Get the rss feed item list.
/// </summary>
public ObservableCollection<RSSModel> Item
{
get
{
return this.item;
}
set
{
if (value != this.item)
{
this.item = value;
NotifyPropertyChanged("item");
}
}
}
}
}

View File

@@ -0,0 +1,203 @@
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
{
/// <summary>
/// Contains the rss feed informations.
/// </summary>
public class RSSModel : BaseModel
{
/// <summary>
/// Title of the fees
/// </summary>
private string title;
/// <summary>
/// Description text of the feed.
/// </summary>
private string text;
/// <summary>
/// Timestamp (publication date) of the event or news.
/// </summary>
private DateTime timestamp;
/// <summary>
/// Url of the feed.
/// </summary>
private string link;
/// <summary>
/// Set/Get the title of the feed.
/// </summary>
[XmlElement("title")]
public string Title
{
get { return this.title; }
set
{
if (this.title != value)
{
this.title = value;
NotifyPropertyChanged("rss");
}
}
}
/// <summary>
/// Set/Get the text of the feed.
/// </summary>
[XmlElement("description")]
public string Text
{
get { return this.text; }
set
{
if (this.text != HTMLUnicodeToString(value))
{
this.text = HTMLUnicodeToString(value);
NotifyPropertyChanged("rss");
}
}
}
/// <summary>
/// Set/Get the timestamp of the feed as string.
/// </summary>
[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");
}
}
}
/// <summary>
/// Set/Get the timestamp of the feed as DateTime object.
/// </summary>
public DateTime DTTimestamp
{
get { return this.timestamp; }
set { this.timestamp = value; }
}
/// <summary>
/// Return the date of the timestamp as string.
/// example: Mon, 25.06.2013.
/// </summary>
public string Date
{
get { return String.Format("{0:ddd, dd.MM.yyyy}", this.timestamp); }
}
/// <summary>
/// Return the time of the timestamp as string.
/// example: 12:56 Uhr.
/// </summary>
public string Time
{
get { return String.Format("{0:h:mm} Uhr", this.timestamp); }
}
/// <summary>
/// Set/Get the link/url of the feed.
/// </summary>
[XmlElement("link")]
public string Link
{
get { return this.link; }
set
{
if (this.link != value)
{
this.link = value;
NotifyPropertyChanged("rss");
}
}
}
/// <summary>
/// Remove or transform html-unicode specific tags into ascii.
/// </summary>
/// <param name="htmluni">html string</param>
/// <returns>ascii string</returns>
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();
}
/// <summary>
/// Comparing function for Datetime-Timestamps.
/// (currently unused)
/// </summary>
/// <param name="item1">first item</param>
/// <param name="item2">secound item</param>
/// <returns></returns>
public static int CompareTimeStamp(RSSModel item1, RSSModel item2)
{
if (item1.DTTimestamp > item2.DTTimestamp)
return -1;
else
return 0;
}
}
}

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace CampusAppWP8.model.events_news
{
/// <summary>
/// ViewModel of the rss feed, containing the feed/channel object.
/// </summary>
[XmlRoot("root")]
public class RSSViewModel : BaseViewModel
{
/// <summary>
/// channel list for the rss feeds.
/// </summary>
[XmlArray("rss")]
[XmlArrayItem("channel")]
public ObservableCollection<RSSChannelModel> channel { get; set; }
/// <summary>
/// Default constructor.
/// </summary>
public RSSViewModel()
{
this.channel = new ObservableCollection<RSSChannelModel>();
}
/// <summary>
/// Set/Get the channel list.
/// </summary>
public ObservableCollection<RSSChannelModel> Channel
{
get
{
return this.channel;
}
set
{
if (value != this.channel)
{
this.channel = value;
NotifyPropertyChanged("channel");
}
}
}
}
}

View File

@@ -1,112 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CampusAppWP8.pages.news
{
class RSSItem
{
private string title;
private string text;
private DateTime timestamp;
private string link;
public string Title
{
get { return this.title; }
set { this.title = value; }
}
public string Text
{
get { return this.text; }
set { this.text = HTMLUnicodeToString(value); }
}
public string Timestamp
{
get { return this.timestamp.ToString("R"); }
set { this.timestamp = DateTime.Parse(value); }
}
public DateTime DTTimestamp
{
get { return this.timestamp; }
set { this.timestamp = value; }
}
public string Date
{
get { return String.Format("{0:ddd, dd.MM.yyyy}", this.timestamp); }
}
public string Time
{
get { return String.Format("{0:h:mm} Uhr", this.timestamp); }
}
public string Link
{
get { return this.link; }
set { this.link = value; }
}
private string HTMLUnicodeToString(string htmluni)
{
StringBuilder retValue = new StringBuilder();
for(int i = 0; i < htmluni.Length; i++)
{
switch (htmluni[i])
{
case '&':
{
int startOff = i + 2;
int endOff = htmluni.IndexOf(';', startOff);
string sub = htmluni.Substring(startOff, endOff - startOff);
int cVal = int.Parse(sub);
switch (cVal)
{
case 128:
retValue.Append('€');
break;
default:
retValue.Append((char)cVal);
break;
}
i = endOff;
}
break;
case '<':
{
i = htmluni.IndexOf('>', i);
}
break;
case '\t':
break;
default:
{
retValue.Append(htmluni[i]);
}
break;
}
}
return retValue.ToString();
}
public static int CompareTimeStamp(RSSItem item1, RSSItem item2)
{
if (item1.DTTimestamp > item2.DTTimestamp)
return -1;
else
return 0;
}
}
}

View File

@@ -18,28 +18,22 @@
<phone:PhoneApplicationPage.Resources>
<viewModel:DepartmentViewModel x:Key="DepartmentViewModel" x:Name="DepartmentView" />
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
<!-- LayoutRoot -->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.DataContext>
<viewModel:DepartmentViewModel />
</Grid.DataContext>
<!--Pivotsteuerelement-->
<!-- Pivot -->
<phone:Pivot x:Name="DepartmentPivot" Title="{Binding Path=LocalizedResources.DepartmentApp_Title, Source={StaticResource LocalizedStrings}}" ItemsSource="{Binding Faculties}">
<!-- Pivotitem template -->
<phone:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Name, Mode=OneWay}" />
</DataTemplate>
</phone:Pivot.HeaderTemplate>
<!--
<phone:PivotItem Header="{Binding Path=LocalizedResources.DepartmentApp_Title, Source={StaticResource LocalizedStrings}}">
<StackPanel>
<TextBlock Text="Test" />
</StackPanel>
</phone:PivotItem>
-->
<phone:Pivot.ItemTemplate>
<DataTemplate>
<!--
<!-- TEMPORARILY REMOVED, will be abck in soon
<phone:LongListSelector ItemsSource="{Binding Faculties}">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>

View File

@@ -11,23 +11,38 @@ using CampusAppWP8.utility;
using CampusAppWP8.model.departments;
using Microsoft.Phone.Tasks;
//using CampusAppWP8.model.departments;
namespace CampusAppWP8.pages.departments
{
/// <summary>
/// Pivot page with list of the chairs of the facultis.
/// </summary>
public partial class DepartmentPage : PhoneApplicationPage
{
/// <summary>
/// Stores the last visible department panel.
/// </summary>
private UIElement lastVisibleUIElem = null;
/// <summary>
/// department/chair feed object, storing the model and data.
/// </summary>
private DepartmentFeed feed { get; set; }
private DepartmentViewModel dvm;
/// <summary>
/// Default constructor.
/// </summary>
public DepartmentPage()
{
InitializeComponent();
this.dvm = new DepartmentViewModel();
// init feed object
this.feed = new DepartmentFeed();
}
/// <summary>
/// On naviagtion to this page.
/// Init the feed loading.
/// </summary>
/// <param name="e">event args</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
@@ -36,32 +51,54 @@ namespace CampusAppWP8.pages.departments
this.feed.LoadFeed();
}
/// <summary>
/// Called after the feeds are loaded.
/// Set the pivotitem source of this page.
/// </summary>
private void SetupDepartmentPivot()
{
DepartmentPivot.ItemsSource = feed.Model._faculties;
}
/// <summary>
/// On orientation changed.
/// </summary>
/// <param name="sender">unused</param>
/// <param name="e">unused</param>
private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
}
/// <summary>
/// Called at clicking on the department headline buttons.
/// Collapses all visible department panels and open (set to visible)
/// the clicked department list.
/// </summary>
/// <param name="sender">clicked department button</param>
/// <param name="e">unused</param>
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];
}
@@ -70,14 +107,22 @@ namespace CampusAppWP8.pages.departments
}
}
/// <summary>
/// On clicking a chair textbolock.
/// Open the browser with the url of the chair.
/// </summary>
/// <param name="sender">clicked chair textblock</param>
/// <param name="e"></param>
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();

View File

@@ -0,0 +1,24 @@
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.pages.events
{
/// <summary>
/// Event Feed.
/// </summary>
public class EventFeed : XMLFeed<RSSViewModel>
{
/// <summary>
/// Default constructor.
/// </summary>
public EventFeed() : base(URLList.EventsFeedURL, "EventFeed.xml")
{
}
}
}

View File

@@ -0,0 +1,32 @@
<phone:PhoneApplicationPage
x:Class="CampusAppWP8.pages.events.EventIndexPage"
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"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot -->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Title and headline -->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="{Binding Path=LocalizedResources.EventApp_Title, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!-- Content -->
<ListBox x:Name="ButtonPanel" Grid.Row="1">
</ListBox>
</Grid>
</phone:PhoneApplicationPage>

View File

@@ -0,0 +1,107 @@
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;
namespace CampusAppWP8.pages.events
{
/// <summary>
/// Overview page of all events.
/// </summary>
public partial class EventIndexPage : PhoneApplicationPage
{
/// <summary>
/// Event Feed object, which contains the rss models and data.
/// </summary>
public static EventFeed eventFeed { get; set; }
/// <summary>
/// Default constructor.
/// </summary>
public EventIndexPage()
{
InitializeComponent();
EventIndexPage.eventFeed = new EventFeed();
}
/// <summary>
/// On navigation to this page, creates a FeedEventHandler and load the rss feed data.
/// </summary>
/// <param name="e">event args</param>
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();
}
/// <summary>
/// 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.
/// </summary>
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<RSSModel> tempList = EventIndexPage.eventFeed.Model.Channel[0].item.OrderByDescending(e => e.DTTimestamp);
EventIndexPage.eventFeed.Model.Channel[0].item = new ObservableCollection<RSSModel>(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);
}
}
}
/// <summary>
/// Return the eventFeed object.
/// </summary>
static public EventFeed GetEventFeed
{
get { return EventIndexPage.eventFeed; }
set { }
}
/// <summary>
/// Is called on clicking on a feed button.
/// Navigates to the event pivot page with the information of the
/// selected feed index.
/// </summary>
/// <param name="sender">pressed button object</param>
/// <param name="e">event args</param>
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));
}
}
}

View File

@@ -6,6 +6,7 @@
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"
xmlns:viewModel="clr-namespace:CampusAppWP8.model.events_news"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
@@ -13,15 +14,37 @@
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
<phone:PhoneApplicationPage.Resources>
<viewModel:RSSViewModel x:Key="RssViewModel" x:Name="RssView" />
</phone:PhoneApplicationPage.Resources>
<!-- LayoutRoot -->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!--Pivotsteuerelement-->
<!-- Pivotpage -->
<phone:Pivot x:Name="EventPivot" Title="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}">
<!--Pivotelement eins-->
<phone:PivotItem Name="EventPivotHome" Header="{Binding Path=LocalizedResources.EventApp_Title, Source={StaticResource LocalizedStrings}}">
<ListBox x:Name="ButtonPanel" Grid.Row="1">
</ListBox>
</phone:PivotItem>
<!-- Pivotitem template -->
<phone:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Date, Mode=OneWay}" />
</DataTemplate>
</phone:Pivot.HeaderTemplate>
<phone:Pivot.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
<RowDefinition Height="90"/>
</Grid.RowDefinitions>
<TextBlock x:Name="EventHeadline" Text="{Binding Path=Title, Mode=OneWay}" Grid.Row="0" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="42"/>
<ScrollViewer Grid.Row="1">
<TextBlock x:Name="EventText" Text="{Binding Path=Text, Mode=OneWay}" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="24" />
</ScrollViewer>
<Button Name="EventHome" Content="{Binding Path=LocalizedResources.NewsHomeBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="EventHome_Click"/>
<Button Name="EventLink" Tag="{Binding Path=Link, Mode=OneWay}" Content="{Binding Path=LocalizedResources.NewsLinkBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" Click="EventLink_Click"/>
</Grid>
</DataTemplate>
</phone:Pivot.ItemTemplate>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>

View File

@@ -12,116 +12,95 @@ using System.Xml;
using System.IO;
using Microsoft.Phone.Tasks;
// Should be CampusAppWP8.pages (for RSSItem).
using CampusAppWP8.pages.news;
using CampusAppWP8.model.events_news;
using CampusAppWP8.utility;
using CampusAppWP8.Resources;
namespace CampusAppWP8.pages.events
{
/// <summary>
/// EventPage, where every event fees has his own pivotitem.
/// </summary>
public partial class EventPage : PhoneApplicationPage
{
List<RSSItem> itemList;
/// <summary>
/// for checking if the feed source is already set or not.
/// </summary>
private bool isSourceSet = false;
/// <summary>
/// Default constructor.
/// </summary>
public EventPage()
{
InitializeComponent();
}
/// <summary>
/// On navigation to this page.
/// The pivotitem source will be set, if it wasn't befor.
/// Navigating to the submited index of the choosen pivotitem page.
/// </summary>
/// <param name="e"></param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
this.itemList = new List<RSSItem>();
this.itemList.Clear();
WebClient wc = new WebClient();
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(WC_DownloadStringCompleted);
base.OnNavigatedTo(e);
wc.DownloadStringAsync(new Uri("http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php"));
}
private void WC_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
return;
int i = 0;
XElement xmlitems = XElement.Parse(e.Result);
List<XElement> elements = xmlitems.Descendants("item").ToList();
foreach (XElement rssItem in elements)
// Set pivotitem Source
if (this.isSourceSet == false)
{
if(i < 12)
if ((EventIndexPage.GetEventFeed.Model != null)
&& (EventIndexPage.GetEventFeed.Model.Channel != null)
&& (EventIndexPage.GetEventFeed.Model.Channel.Count() >= 1))
{
RSSItem rss = new RSSItem();
rss.Title = rssItem.Element("title").Value;
rss.Text = rssItem.Element("description").Value;
rss.Timestamp = rssItem.Element("pubDate").Value;
rss.Link = rssItem.Element("link").Value;
this.itemList.Add(rss);
i++;
this.EventPivot.ItemsSource = EventIndexPage.GetEventFeed.Model.Channel[0].item;
this.isSourceSet = true;
}
}
this.itemList.Sort(RSSItem.CompareTimeStamp);
string pivotIndex = "";
for(i = 0; i < this.itemList.Count(); i++)
// Navigate to the selected pivotitem
if (NavigationContext.QueryString.TryGetValue("pivotindex", out pivotIndex))
{
Button btn = new Button();
btn.Name = "EventRowAppButton" + i;
btn.Content = this.itemList[i].Title;
btn.BorderBrush = null;
btn.Background = null;
btn.VerticalContentAlignment = VerticalAlignment.Stretch;
btn.HorizontalContentAlignment = HorizontalAlignment.Stretch;
btn.BorderThickness = new Thickness(0);
btn.Padding = new Thickness(0);
btn.Click += EventRowAppButton_Click;
btn.Tag = i;
int pivotIndexInt = int.Parse(pivotIndex);
PivotItem newPivItem = new PivotItem();
newPivItem.Name = "EventPivot" + i;
newPivItem.Header = this.itemList[i].Date;
RSSNewsTemplate pvContent = new RSSNewsTemplate();
pvContent.NewsHeadline.Text = this.itemList[i].Title;
pvContent.NewsText.Text = this.itemList[i].Text;
pvContent.NewsHome.Click += EventHome_Click;
pvContent.NewsLink.Click += EventLink_Click;
pvContent.NewsLink.Tag = i;
if (this.itemList[i].Link.Length == 0)
pvContent.NewsLink.Visibility = Visibility.Collapsed;
newPivItem.Content = pvContent;
EventPivot.Items.Add(newPivItem);
ButtonPanel.Items.Add(btn);
// if the index is in the range of the array
if((pivotIndexInt >= 0) && (pivotIndexInt < EventIndexPage.GetEventFeed.Model.Channel[0].item.Count()))
EventPivot.SelectedIndex = pivotIndexInt;
else
MessageBox.Show("ERROR: pivotIndex out of range!!!");
}
}
//
private void EventRowAppButton_Click(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
EventPivot.SelectedIndex = (int)btn.Tag + 1;
}
/// <summary>
/// On clicking the home button (lower left).
/// Navigate back to the event index page.
/// </summary>
/// <param name="sender">clicked button</param>
/// <param name="e">event args</param>
private void EventHome_Click(object sender, RoutedEventArgs e)
{
EventPivot.SelectedIndex = 0;
// Navigate back to the event index page
NavigationService.GoBack();
}
/// <summary>
/// On clicking the link button if a link exists in the feed
/// (lower right).
/// Open the webbrowser with the url set in the feed.
/// </summary>
/// <param name="sender">clicked button</param>
/// <param name="e">event args</param>
private void EventLink_Click(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
FrameworkElement fe = sender as FrameworkElement;
// Open the webbrowser
WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.Uri = new Uri(this.itemList[(int)btn.Tag].Link, UriKind.Absolute);
webBrowserTask.Uri = new Uri(fe.Tag.ToString(), UriKind.Absolute);
webBrowserTask.Show();
}
}

View File

@@ -0,0 +1,24 @@
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.pages.news
{
/// <summary>
/// News Feed.
/// </summary>
public class NewsFeed : XMLFeed<RSSViewModel>
{
/// <summary>
/// Default constructor.
/// </summary>
public NewsFeed() : base(URLList.NewsFeedURL, "NewsFeed.xml")
{
}
}
}

View File

@@ -0,0 +1,33 @@
<phone:PhoneApplicationPage
x:Class="CampusAppWP8.pages.news.NewsIndexPage"
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"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<!--LayoutRoot -->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!-- Title and headline -->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="{Binding Path=LocalizedResources.NewsApp_Title, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!-- Content -->
<ListBox x:Name="ButtonPanel" Grid.Row="1">
</ListBox>
</Grid>
</phone:PhoneApplicationPage>

View File

@@ -0,0 +1,107 @@
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;
namespace CampusAppWP8.pages.news
{
/// <summary>
/// Overview page of all news.
/// </summary>
public partial class NewsIndexPage : PhoneApplicationPage
{
/// <summary>
/// News Feed object, which contains the rss models and data.
/// </summary>
public static NewsFeed newsFeed { get; set; }
/// <summary>
/// Default constructor.
/// </summary>
public NewsIndexPage()
{
InitializeComponent();
NewsIndexPage.newsFeed = new NewsFeed();
}
/// <summary>
/// On navigation to this page, creates a FeedEventHandler and load the rss feed data.
/// </summary>
/// <param name="e">event args</param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
// Set handler and load the fees informations.
NewsIndexPage.newsFeed.EventHandler.FeedIsReadyEvent += new FeedEventHandler.FeedReadyHandler(SetupNewsPageList);
NewsIndexPage.newsFeed.LoadFeed();
}
/// <summary>
/// Is called after the rss feeds are loaded into the newsFeed 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.
/// </summary>
private void SetupNewsPageList()
{
if ((NewsIndexPage.newsFeed.Model != null)
&& (NewsIndexPage.newsFeed.Model.Channel != null)
&& (NewsIndexPage.newsFeed.Model.Channel.Count() >= 1)
&& (this.ButtonPanel.Items.Count() == 0))
{
// Sort the list of rssfeeds.
IEnumerable<RSSModel> tempList = NewsIndexPage.newsFeed.Model.Channel[0].item.OrderByDescending(e => e.DTTimestamp);
NewsIndexPage.newsFeed.Model.Channel[0].item = new ObservableCollection<RSSModel>(tempList);
// Create the buttons for the fees selection and add it to the buttonpanel.
for (int i = 0; i < NewsIndexPage.newsFeed.Model.Channel[0].item.Count(); i++)
{
Button tempBtn = new Button();
tempBtn.Name = "NewsRowAppButton";
tempBtn.Content = NewsIndexPage.newsFeed.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 += NewsRowAppButton_Click;
tempBtn.Tag = i;
this.ButtonPanel.Items.Add(tempBtn);
}
}
}
/// <summary>
/// Return the newsFeed object.
/// </summary>
static public NewsFeed GetNewsFeed
{
get { return NewsIndexPage.newsFeed; }
set { }
}
/// <summary>
/// Is called on clicking on a feed button.
/// Navigates to the news pivot page with the information of the
/// selected feed index.
/// </summary>
/// <param name="sender">pressed button object</param>
/// <param name="e">event args</param>
private void NewsRowAppButton_Click(object sender, RoutedEventArgs e)
{
FrameworkElement tempElem = sender as FrameworkElement;
NavigationService.Navigate(new Uri("/pages/news/NewsPage.xaml?pivotindex=" + tempElem.Tag, UriKind.Relative));
}
}
}

View File

@@ -1,47 +1,50 @@
<phone:PhoneApplicationPage
x:Class="CampusAppWP8.pages.news.NewsPage"
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">
<!--Pivotsteuerelement-->
<phone:Pivot x:Name="NewsPivot" Title="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}">
<!--Pivotelement eins-->
<phone:PivotItem Name="NewsPivotHome" Header="{Binding Path=LocalizedResources.NewsApp_Title, Source={StaticResource LocalizedStrings}}">
<ListBox x:Name="ButtonPanel" Grid.Row="1">
<!-- rows
<Button Name="NewsRow01AppButton" Content="Test News Title 01" Click="NewsRow01AppButton_Click" Grid.Row="0" BorderBrush="{x:Null}" Background="{x:Null}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" BorderThickness="0" Padding="0">
</Button>
-->
</ListBox>
</phone:PivotItem>
<!--Pivotelement news template
<phone:PivotItem Name="NewsPivot01" Header="(timestamp)">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
<RowDefinition Height="90"/>
</Grid.RowDefinitions>
<TextBlock x:Name="NewsHeadline01" Text="(headline)" Grid.Row="0" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="42"/>
<TextBlock x:Name="NewsText01" Text="(text)" Grid.Row="1" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="24" />
<Button Name="NewsHome" Content="zur News Übersicht" Click="NewsHome_Click" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
</Grid>
</phone:PivotItem>
-->
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>
<phone:PhoneApplicationPage
x:Class="CampusAppWP8.pages.news.NewsPage"
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"
xmlns:viewModel="clr-namespace:CampusAppWP8.model.events_news"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources>
<viewModel:RSSViewModel x:Key="RssViewModel" x:Name="RssView" />
</phone:PhoneApplicationPage.Resources>
<!-- LayoutRoot -->
<Grid x:Name="LayoutRoot" Background="Transparent">
<!-- Pivotpage -->
<phone:Pivot x:Name="NewsPivot" Title="{Binding Path=LocalizedResources.ApplicationTitle, Source={StaticResource LocalizedStrings}}">
<!-- Pivotitem template -->
<phone:Pivot.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=Date, Mode=OneWay}" />
</DataTemplate>
</phone:Pivot.HeaderTemplate>
<phone:Pivot.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
<RowDefinition Height="90"/>
</Grid.RowDefinitions>
<TextBlock x:Name="NewsHeadline" Text="{Binding Path=Title, Mode=OneWay}" Grid.Row="0" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="42"/>
<ScrollViewer Grid.Row="1">
<TextBlock x:Name="NewsText" Text="{Binding Path=Text, Mode=OneWay}" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="24" />
</ScrollViewer>
<Button Name="NewsHome" Content="{Binding Path=LocalizedResources.NewsHomeBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Left" Click="NewsHome_Click"/>
<Button Name="NewsLink" Tag="{Binding Path=Link, Mode=OneWay}" Content="{Binding Path=LocalizedResources.NewsLinkBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" Click="NewsLink_Click"/>
</Grid>
</DataTemplate>
</phone:Pivot.ItemTemplate>
</phone:Pivot>
</Grid>
</phone:PhoneApplicationPage>

View File

@@ -12,126 +12,96 @@ using System.Xml;
using System.IO;
using Microsoft.Phone.Tasks;
using CampusAppWP8.model.events_news;
using CampusAppWP8.utility;
using CampusAppWP8.Resources;
namespace CampusAppWP8.pages.news
{
/// <summary>
/// EventPage, where every news fees has his own pivotitem.
/// </summary>
public partial class NewsPage : PhoneApplicationPage
{
List<RSSItem> itemList;
/// <summary>
/// for checking if the feed source is already set or not.
/// </summary>
private bool isSourceSet = false;
/// <summary>
/// Default constructor.
/// </summary>
public NewsPage()
{
InitializeComponent();
}
//
/// <summary>
/// On navigation to this page.
/// The pivotitem source will be set, if it wasn't befor.
/// Navigating to the submited index of the choosen pivotitem page.
/// </summary>
/// <param name="e"></param>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
this.itemList = new List<RSSItem>();
this.itemList.Clear();
WebClient wc = new WebClient();
wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(WC_DownloadStringCompleted);
base.OnNavigatedTo(e);
wc.DownloadStringAsync(new Uri("http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php"));
}
private void WC_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
return;
int i = 0;
XElement xmlitems = XElement.Parse(e.Result);
List<XElement> elements = xmlitems.Descendants("item").ToList();
foreach (XElement rssItem in elements)
// Set pivotitem Source
if (this.isSourceSet == false)
{
if(i < 12)
if ((NewsIndexPage.GetNewsFeed.Model != null)
&& (NewsIndexPage.GetNewsFeed.Model.Channel != null)
&& (NewsIndexPage.GetNewsFeed.Model.Channel.Count() >= 1))
{
RSSItem rss = new RSSItem();
rss.Title = rssItem.Element("title").Value;
rss.Text = rssItem.Element("description").Value;
rss.Timestamp = rssItem.Element("pubDate").Value;
this.itemList.Add(rss);
Button btn = new Button();
btn.Name = "NewsRowAppButton" + i;
btn.Content = rss.Title;
btn.BorderBrush = null;
btn.Background = null;
btn.VerticalContentAlignment = VerticalAlignment.Stretch;
btn.HorizontalContentAlignment = HorizontalAlignment.Stretch;
btn.BorderThickness = new Thickness(0);
btn.Padding = new Thickness(0);
btn.Click += NewsRowAppButton_Click;
btn.Tag = i;
PivotItem newPivItem = new PivotItem();
newPivItem.Name = "NewsPivot" + i;
newPivItem.Header = rss.Date;
RSSNewsTemplate pvContent = new RSSNewsTemplate();
pvContent.NewsHeadline.Text = rss.Title;
pvContent.NewsText.Text = rss.Text;
pvContent.NewsHome.Click += NewsHome_Click;
pvContent.NewsLink.Click += NewsLink_Click;
pvContent.NewsLink.Tag = i;
/*
{
double height = pvContent.NewsHeadline.Height * 0.99;
double width = pvContent.NewsHeadline.Width * 0.99;
Font tryFont = pvContent.NewsHeadline.Font;
Size tempSize = TextRenderer.MeasureText(pvContent.NewsHeadline.Text, tryFont);
float heightRatio = height / tempSize.Height;
float widthRatio = width / tempSize.Width;
tryFont = new Font(tryFont.FontFamily, tryFont.Size * Math.Min(widthRatio, heightRatio), tryFont.Style);
pvContent.NewsHeadline.Font = tryFont;
}
*/
if ((rss.Link == null) || (rss.Link.Length == 0))
pvContent.NewsLink.Visibility = Visibility.Collapsed;
newPivItem.Content = pvContent;
NewsPivot.Items.Add(newPivItem);
ButtonPanel.Items.Add(btn);
i++;
this.NewsPivot.ItemsSource = NewsIndexPage.GetNewsFeed.Model.Channel[0].item;
this.isSourceSet = true;
}
}
string pivotIndex = "";
// Navigate to the selected pivotitem
if (NavigationContext.QueryString.TryGetValue("pivotindex", out pivotIndex))
{
int pivotIndexInt = int.Parse(pivotIndex);
// if the index is in the range of the array
if ((pivotIndexInt >= 0) && (pivotIndexInt < NewsIndexPage.GetNewsFeed.Model.Channel[0].item.Count()))
NewsPivot.SelectedIndex = pivotIndexInt;
else
MessageBox.Show("ERROR: pivotIndex out of range!!!");
}
}
// Button Functions
private void NewsRowAppButton_Click(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
NewsPivot.SelectedIndex = (int)btn.Tag + 1;
}
/// <summary>
/// On clicking the home button (lower left).
/// Navigate back to the news index page.
/// </summary>
/// <param name="sender">clicked button</param>
/// <param name="e">event args</param>
private void NewsHome_Click(object sender, RoutedEventArgs e)
{
NewsPivot.SelectedIndex = 0;
// Navigate back to the news index page
NavigationService.GoBack();
}
/// <summary>
/// On clicking the link button if a link exists in the feed
/// (lower right).
/// Open the webbrowser with the url set in the feed.
/// </summary>
/// <param name="sender">clicked button</param>
/// <param name="e">event args</param>
private void NewsLink_Click(object sender, RoutedEventArgs e)
{
Button btn = (Button)sender;
FrameworkElement fe = sender as FrameworkElement;
// Open the webbrowser
WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.Uri = new Uri(this.itemList[(int)btn.Tag].Link, UriKind.Absolute);
webBrowserTask.Uri = new Uri(fe.Tag.ToString(), UriKind.Absolute);
webBrowserTask.Show();
}
}
}
}

View File

@@ -1,60 +0,0 @@
<<<<<<< HEAD
<UserControl
x:Class="CampusAppWP8.pages.news.RSSNewsTemplate"
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"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
<RowDefinition Height="90"/>
</Grid.RowDefinitions>
<TextBlock x:Name="NewsHeadline" Text="(headline)" Grid.Row="0" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="42"/>
<ScrollViewer Grid.Row="1">
<TextBlock x:Name="NewsText" Text="(text)" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="24" />
</ScrollViewer>
<Button Name="NewsHome" Content="{Binding Path=LocalizedResources.NewsHomeBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
<Button Name="NewsLink" Content="{Binding Path=LocalizedResources.NewsLinkBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
</Grid>
</UserControl>
=======
<UserControl
x:Class="CampusAppWP8.pages.news.RSSNewsTemplate"
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"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="100"/>
<RowDefinition Height="*"/>
<RowDefinition Height="90"/>
</Grid.RowDefinitions>
<TextBlock x:Name="NewsHeadline" Text="(headline)" Grid.Row="0" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="42"/>
<ScrollViewer Grid.Row="1">
<TextBlock x:Name="NewsText" Text="(text)" Height="Auto" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Left" FontSize="24" />
</ScrollViewer>
<Button Name="NewsHome" Content="{Binding Path=LocalizedResources.NewsHomeBtn, Source={StaticResource LocalizedStrings}}" Grid.Row="2" VerticalAlignment="Bottom" HorizontalAlignment="Left" />
</Grid>
</UserControl>
>>>>>>> d70e3da558c01e1f589ef06e919074b36a45d32c

View File

@@ -1,22 +0,0 @@
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 Windows.Foundation;
using Windows.Foundation.Collections;
namespace CampusAppWP8.pages.news
{
public partial class RSSNewsTemplate : UserControl
{
public RSSNewsTemplate()
{
InitializeComponent();
}
}
}

View File

@@ -10,5 +10,7 @@ namespace CampusAppWP8.utility
{
public static Uri MensaFeedURL = new Uri("http://www.studentenwerk-frankfurt.de/2011/ClassPackage/App_IKMZ_BTU/", UriKind.Absolute);
public static Uri DepartmentFeedURL = new Uri("http://www.tu-cottbus.de/campusapp-data/professorships.xml", UriKind.Absolute);
public static Uri EventsFeedURL = new Uri("http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_veranstaltungen.php", UriKind.Absolute);
public static Uri NewsFeedURL = new Uri("http://www.tu-cottbus.de/oracle-gateway/php/rss2feed_aktuelles.php", UriKind.Absolute);
}
}