updtade feedutlilty
This commit is contained in:
@@ -102,6 +102,7 @@
|
||||
<Compile Include="model\departments\DepartmentModel.cs" />
|
||||
<Compile Include="model\departments\DepartmentViewModel.cs" />
|
||||
<Compile Include="model\departments\FacultyModel.cs" />
|
||||
<Compile Include="model\mensa\MenuModel.cs" />
|
||||
<Compile Include="pages\campusmap\CampusMapPage.xaml.cs">
|
||||
<DependentUpon>CampusMapPage.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -113,8 +114,6 @@
|
||||
</Compile>
|
||||
<Compile Include="model\BaseModel.cs" />
|
||||
<Compile Include="model\BaseViewModel.cs" />
|
||||
<Compile Include="model\mensa\Food.cs" />
|
||||
<Compile Include="model\mensa\FoodDay.cs" />
|
||||
<Compile Include="pages\mensa\MensaFeed.cs" />
|
||||
<Compile Include="pages\mensa\MensaPage.xaml.cs">
|
||||
<DependentUpon>MensaPage.xaml</DependentUpon>
|
||||
|
||||
@@ -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/mensa/MensaPage.xaml" />
|
||||
</Tasks>
|
||||
<Tokens>
|
||||
<PrimaryToken TokenID="CampusAppWP8Token" TaskName="_default">
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace CampusAppWP8.model.mensa
|
||||
{
|
||||
public class Food : BaseModel
|
||||
{
|
||||
private string _detail;
|
||||
private string _title;
|
||||
public Food()
|
||||
{
|
||||
}
|
||||
|
||||
public Food(string title, string detail)
|
||||
{
|
||||
_title = title;
|
||||
_detail = detail;
|
||||
}
|
||||
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
{
|
||||
return _title;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _title)
|
||||
{
|
||||
_title = value;
|
||||
NotifyPropertyChanged("title");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Detail
|
||||
{
|
||||
get
|
||||
{
|
||||
return _detail;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (value != _detail)
|
||||
{
|
||||
_detail = value;
|
||||
NotifyPropertyChanged("detail");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CampusAppWP8.model.mensa
|
||||
{
|
||||
public class FoodDay : BaseModel
|
||||
{
|
||||
private int _id;
|
||||
private string _header;
|
||||
private string _date;
|
||||
|
||||
private ObservableCollection<Food> _foods = null;
|
||||
|
||||
public FoodDay()
|
||||
{
|
||||
this.LoadData();
|
||||
}
|
||||
|
||||
public FoodDay(int id, string header)
|
||||
{
|
||||
_id = id;
|
||||
_header = header;
|
||||
_date = header + " (01.01.1970)";
|
||||
this.LoadData();
|
||||
}
|
||||
|
||||
public void LoadData()
|
||||
{
|
||||
this.Foods = new ObservableCollection<Food>();
|
||||
this.Foods.Add(new Food("Tagesuppe", "Schweinebrühe"));
|
||||
this.Foods.Add(new Food("Essen 1", "Gaisburger Marsch mit Rindfleisch und Wurzelgemüse, dazu eine Scheibe Brot, Obst (R)"));
|
||||
this.Foods.Add(new Food("Essen 2", "Weißkohlroulade mit pikanter Fleischfüllung auf Schmorkohlsauce zu Petersilienkartoffeln, Obst (S)"));
|
||||
this.Foods.Add(new Food("Essen 3", "Spätzle-Pilz-Gouda-Pfanne mit Leipziger Allerlei und Sauce Mousseline (*)"));
|
||||
this.Foods.Add(new Food("Essen 4", "Putenragout \"Florenz\" aus der Brust auf feiner Parmesansauce angerichtet (P),dazu Buttererbsen, Paprikagemüse, Maisgemüse sowie Ingwerreis, Pasta oder Kartoffelrösti(*)"));
|
||||
this.Foods.Add(new Food("Aktion", "Tandem - Magdeburg kocht für Cottbus Harzer Teufelwurst mit grünen Teufelspuck, Scharfes Hexendessert (S)"));
|
||||
}
|
||||
|
||||
public string Header
|
||||
{
|
||||
get { return _header; }
|
||||
set
|
||||
{
|
||||
if (value != _header)
|
||||
{
|
||||
_header = value;
|
||||
NotifyPropertyChanged("header");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Date
|
||||
{
|
||||
get { return _date; }
|
||||
set
|
||||
{
|
||||
if (value != _date)
|
||||
{
|
||||
_date = value;
|
||||
NotifyPropertyChanged("date");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<Food> Foods
|
||||
{
|
||||
get { return _foods; }
|
||||
set
|
||||
{
|
||||
if (value != _foods)
|
||||
{
|
||||
_foods = value;
|
||||
NotifyPropertyChanged("foods");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Id
|
||||
{
|
||||
get { return _id; }
|
||||
set
|
||||
{
|
||||
if (value != _id)
|
||||
{
|
||||
_id = value;
|
||||
NotifyPropertyChanged("id");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.pages.mensa;
|
||||
using CampusAppWP8.Resources;
|
||||
using CampusAppWP8.utility;
|
||||
using Microsoft.Phone.Controls;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -12,24 +14,21 @@ namespace CampusAppWP8.model.mensa
|
||||
{
|
||||
public class MensaViewModel : BaseViewModel
|
||||
{
|
||||
private ObservableCollection<FoodDay> _foodDays = null;
|
||||
private ObservableCollection<MenuModel> _foodDays = null;
|
||||
|
||||
public MensaViewModel()
|
||||
{
|
||||
this.FoodDays = new ObservableCollection<FoodDay>();
|
||||
_foodDays = new ObservableCollection<MenuModel>();
|
||||
this.LoadData();
|
||||
}
|
||||
|
||||
public void LoadData()
|
||||
{
|
||||
this.FoodDays.Add(new FoodDay(0, AppResources.Time_Day_Monday));
|
||||
this.FoodDays.Add(new FoodDay(1, AppResources.Time_Day_Tuesday));
|
||||
this.FoodDays.Add(new FoodDay(2, AppResources.Time_Day_Wednesday));
|
||||
this.FoodDays.Add(new FoodDay(3, AppResources.Time_Day_Thursday));
|
||||
this.FoodDays.Add(new FoodDay(4, AppResources.Time_Day_Friday));
|
||||
Feed feed = new MensaFeed();
|
||||
feed.downloadFeed();
|
||||
}
|
||||
|
||||
public ObservableCollection<FoodDay> FoodDays
|
||||
public ObservableCollection<MenuModel> FoodDays
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
50
CampusAppWP8/CampusAppWP8/model/mensa/MenuModel.cs
Normal file
50
CampusAppWP8/CampusAppWP8/model/mensa/MenuModel.cs
Normal file
@@ -0,0 +1,50 @@
|
||||
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.mensa
|
||||
{
|
||||
|
||||
[XmlRoot("root")]
|
||||
public class MenuWeekModel
|
||||
{
|
||||
[XmlArray("BTU")]
|
||||
[XmlArrayItem("Tagesmenu")]
|
||||
public ObservableCollection<MenuModel> menus { get; set; }
|
||||
public MenuWeekModel()
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class MenuModel
|
||||
{
|
||||
public MenuModel()
|
||||
{
|
||||
}
|
||||
|
||||
[XmlElement("Wochentag")]
|
||||
public string WochenTag { get; set; }
|
||||
|
||||
[XmlElement("Essen1")]
|
||||
public string Essen1 {get; set;}
|
||||
|
||||
[XmlElement("Essen2")]
|
||||
public string Essen2 {get; set;}
|
||||
|
||||
[XmlElement("Essen3")]
|
||||
public string Essen3 {get; set;}
|
||||
|
||||
[XmlElement("Essen4")]
|
||||
public string Essen4 {get; set;}
|
||||
|
||||
[XmlElement("Bio")]
|
||||
public string Bio {get; set;}
|
||||
|
||||
[XmlElement("Aktionstag")]
|
||||
public string Aktionstag {get; set;}
|
||||
}
|
||||
}
|
||||
@@ -1,28 +1,38 @@
|
||||
using CampusAppWP8.utility;
|
||||
using CampusAppWP8.model.mensa;
|
||||
using CampusAppWP8.utility;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.Serialization;
|
||||
|
||||
namespace CampusAppWP8.pages.mensa
|
||||
{
|
||||
public class MensaFeed : Feed
|
||||
{
|
||||
|
||||
private readonly Uri _feedUrl = URLList.MensaFeedURL;
|
||||
|
||||
public MensaFeed()
|
||||
public MensaFeed(): base(URLList.MensaFeedURL)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public Uri FeedURL
|
||||
protected override void doSomething(string downloadResult)
|
||||
{
|
||||
get
|
||||
{
|
||||
return _feedUrl;
|
||||
}
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(MenuWeekModel));
|
||||
XDocument document = XDocument.Parse(downloadResult);
|
||||
|
||||
if (!document.Root.Name.Equals("root"))
|
||||
{
|
||||
XElement content = document.Root;
|
||||
document = new XDocument();
|
||||
document.Add(new XElement("root", content));
|
||||
}
|
||||
MenuWeekModel menuWeek = (MenuWeekModel)serializer.Deserialize(document.CreateReader());
|
||||
menus = menuWeek.menus;
|
||||
}
|
||||
|
||||
public System.Collections.ObjectModel.ObservableCollection<MenuModel> menus { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
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.mensa"
|
||||
mc:Ignorable="d"
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
@@ -14,43 +13,15 @@
|
||||
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
|
||||
OrientationChanged="PhoneApplicationPage_OrientationChanged"
|
||||
shell:SystemTray.IsVisible="True">
|
||||
|
||||
<phone:PhoneApplicationPage.Resources>
|
||||
<viewModel:MensaViewModel x:Key="MensaViewModel" />
|
||||
</phone:PhoneApplicationPage.Resources>
|
||||
<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
<Grid.DataContext>
|
||||
<viewModel:MensaViewModel/>
|
||||
</Grid.DataContext>
|
||||
<!--Pivotsteuerelement-->
|
||||
<phone:Pivot Name="MensaPivot" Title="{Binding Path=LocalizedResources.MensaApp_Title, Source={StaticResource LocalizedStrings}}" ItemsSource="{Binding FoodDays}">
|
||||
<phone:Pivot Name="MensaPivot" Title="{Binding Path=LocalizedResources.MensaApp_Title, Source={StaticResource LocalizedStrings}}">
|
||||
<phone:Pivot.HeaderTemplate>
|
||||
<DataTemplate>
|
||||
<TextBlock Text="{Binding Header}" />
|
||||
<TextBlock Text="{Binding WochenTag}" />
|
||||
</DataTemplate>
|
||||
</phone:Pivot.HeaderTemplate>
|
||||
<phone:Pivot.ItemTemplate >
|
||||
<DataTemplate>
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Date}" />
|
||||
<ScrollViewer>
|
||||
<phone:LongListSelector ItemsSource="{Binding Foods}" >
|
||||
<phone:LongListSelector.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border BorderThickness="0 1 0 0" BorderBrush="{StaticResource PhoneBorderBrush}" Padding="0,5,0,5" >
|
||||
<StackPanel>
|
||||
<TextBlock Text="{Binding Title}" Style="{StaticResource PhoneTextTitle3Style}" TextWrapping="Wrap" FontWeight="Bold" />
|
||||
<TextBlock Text="{Binding Detail}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap"/>
|
||||
</StackPanel>
|
||||
</Border >
|
||||
</DataTemplate>
|
||||
</phone:LongListSelector.ItemTemplate>
|
||||
</phone:LongListSelector>
|
||||
</ScrollViewer>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</phone:Pivot.ItemTemplate>
|
||||
</phone:Pivot>
|
||||
</Grid>
|
||||
</phone:PhoneApplicationPage>
|
||||
@@ -7,6 +7,10 @@ using System.Windows.Controls;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using CampusAppWP8.utility;
|
||||
using System.Xml.Serialization;
|
||||
using CampusAppWP8.model.mensa;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace CampusAppWP8.pages.mensa
|
||||
{
|
||||
@@ -15,8 +19,36 @@ namespace CampusAppWP8.pages.mensa
|
||||
public MensaPage()
|
||||
{
|
||||
InitializeComponent();
|
||||
MensaPivot.SelectedIndex = this.calcSelectedIndex();
|
||||
//MensaPivot.SelectedIndex = this.calcSelectedIndex();
|
||||
WebClient client = new WebClient();
|
||||
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadCompleted);
|
||||
client.DownloadStringAsync(URLList.MensaFeedURL);
|
||||
}
|
||||
|
||||
private void DownloadCompleted(object sender, DownloadStringCompletedEventArgs e)
|
||||
{
|
||||
Exception downloadError = e.Error;
|
||||
if (downloadError != null)
|
||||
{
|
||||
Console.Out.WriteLineAsync(downloadError.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
string downloadResult = e.Result;
|
||||
if (downloadResult != null && !downloadResult.Equals(String.Empty))
|
||||
{
|
||||
XmlSerializer serializer = new XmlSerializer(typeof(MenuWeekModel));
|
||||
XDocument document = XDocument.Parse(downloadResult);
|
||||
|
||||
if (!document.Root.Name.Equals("root"))
|
||||
{
|
||||
XElement content = document.Root;
|
||||
document = new XDocument();
|
||||
document.Add(new XElement("root", content));
|
||||
}
|
||||
MenuWeekModel menuWeek = (MenuWeekModel)serializer.Deserialize(document.CreateReader());
|
||||
MensaPivot.ItemsSource = menuWeek.menus;
|
||||
}
|
||||
}
|
||||
|
||||
private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
|
||||
|
||||
@@ -3,10 +3,67 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Net;
|
||||
|
||||
namespace CampusAppWP8.utility
|
||||
{
|
||||
public abstract class Feed
|
||||
{
|
||||
#region Member
|
||||
|
||||
private readonly Uri _feedURL;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructor
|
||||
|
||||
public Feed()
|
||||
{
|
||||
}
|
||||
|
||||
public Feed(Uri FeedURL)
|
||||
{
|
||||
_feedURL = FeedURL;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Methods
|
||||
public void downloadFeed()
|
||||
{
|
||||
WebClient client = new WebClient();
|
||||
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(DownloadCompleted);
|
||||
client.DownloadStringAsync(_feedURL);
|
||||
}
|
||||
|
||||
private void DownloadCompleted(object sender, DownloadStringCompletedEventArgs e)
|
||||
{
|
||||
Exception downloadError = e.Error;
|
||||
if (downloadError != null)
|
||||
{
|
||||
Console.Out.WriteLineAsync(downloadError.Message);
|
||||
return;
|
||||
}
|
||||
|
||||
string downloadResult = e.Result;
|
||||
if (downloadResult != null && !downloadResult.Equals(String.Empty))
|
||||
{
|
||||
doSomething(downloadResult);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void doSomething(string downloadResult);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Getter&Setter
|
||||
|
||||
public Uri FeedURL
|
||||
{
|
||||
get { return _feedURL; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user