timetable ui & models

This commit is contained in:
Christian Fiedler
2013-09-12 17:33:12 +02:00
parent e1c77d5544
commit 156df2766d
11 changed files with 404 additions and 18 deletions

View File

@@ -122,11 +122,16 @@
<Compile Include="Model\Person\PersonModel.cs" />
<Compile Include="Model\Setting\AppSettings.cs" />
<Compile Include="Model\Setting\UserProfilModel.cs" />
<Compile Include="Model\TimeTable\AppointmentListModel.cs" />
<Compile Include="Model\TimeTable\AppointmentModel.cs" />
<Compile Include="Model\Utility\CourseListPickerItemListModel.cs" />
<Compile Include="Model\Utility\DegreeListPickerItemListModel.cs" />
<Compile Include="Model\Utility\CleanUrlParamModel.cs" />
<Compile Include="Model\Utility\CampusListPickerItemListModel.cs" />
<Compile Include="Pages\TimeTable\Appointment.xaml.cs">
<DependentUpon>Appointment.xaml</DependentUpon>
</Compile>
<Compile Include="Pages\TimeTable\TimeTable.cs" />
<Compile Include="Pages\TimeTable\TimeTableDay.xaml.cs">
<DependentUpon>TimeTableDay.xaml</DependentUpon>
</Compile>
@@ -434,6 +439,10 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\TimeTable\Appointment.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Pages\TimeTable\TimeTableDay.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>

View File

@@ -0,0 +1,63 @@
//-----------------------------------------------------------------------------
// <copyright file="AppointmentListModel.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>fiedlchr</author>
// <sience>26.08.2013</sience>
//-----------------------------------------------------------------------------
namespace CampusAppWP8.Model.TimeTable
{
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Text.RegularExpressions;
using System.Windows.Shapes;
using System.Xml.Serialization;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows;
using CampusAppWP8.Utility;
using CampusAppWP8.Utility.ICSProperties;
/// <summary>
/// Model for appointments.
/// </summary>
[XmlRoot("root")]
public class AppointmentListModel
{
private ObservableCollection<AppointmentModel> appointmentList;
/// <summary>Initializes a new instance of the <see cref="AppointmentModel" /> class. </summary>
public AppointmentListModel()
{
this.appointmentList = new ObservableCollection<AppointmentModel>();
}
// for testing
public AppointmentListModel(AppointmentModel[] appList) : this()
{
if (appList != null)
{
foreach (AppointmentModel a in appList)
{
this.appointmentList.Add(a);
}
}
}
public ObservableCollection<AppointmentModel> Appointments
{
get
{
return this.appointmentList;
}
set
{
this.appointmentList = value;
}
}
}
}

View File

@@ -35,6 +35,9 @@ namespace CampusAppWP8.Model.TimeTable
private ICalObject icalObj = null;
public delegate void OnAppointmentClick(AppointmentModel sender);
public event OnAppointmentClick OnClick = null;
/// <summary>Initializes a new instance of the <see cref="AppointmentModel" /> class. </summary>
public AppointmentModel()
{
@@ -167,7 +170,84 @@ namespace CampusAppWP8.Model.TimeTable
private void OnCanvasClick(object sender, EventArgs e)
{
if (this.OnClick != null)
{
this.OnClick(this);
}
}
// ------------------------------------------------------
public string Title
{
get
{
ICalObject eventICal = this.GetVEventObj();
Summary tempSum = eventICal.GetProperty(ICSTag.SUMMARY) as Summary;
return tempSum.Value;
}
}
public string Date
{
get
{
string retValue = string.Empty;
ICalObject eventICal = this.GetVEventObj();
DTStart startDT = eventICal.GetProperty(ICSTag.DT_START) as DTStart;
DTEnd endDT = eventICal.GetProperty(ICSTag.DT_END) as DTEnd;
if (startDT != null && endDT != null)
{
if (startDT.Value.Year.Equals(endDT.Value.Year) && startDT.Value.Month.Equals(endDT.Value.Month) && startDT.Value.Day.Equals(endDT.Value.Day))
{
retValue = string.Format("{0:d}, {0:HH:ss} - {1:HH:ss}", startDT.Value, endDT.Value);
}
else
{
retValue = string.Format("{0:d} {0:HH:ss} - {1:d} {1:HH:ss}", startDT.Value, endDT.Value);
}
}
return retValue;
}
}
public string Location
{
get
{
string retValue = string.Empty;
ICalObject eventICal = this.GetVEventObj();
Location loc = eventICal.GetProperty(ICSTag.LOCATION) as Location;
if (loc != null)
{
retValue = loc.Value;
}
return retValue;
}
}
public string Description
{
get
{
string retValue = string.Empty;
ICalObject eventICal = this.GetVEventObj();
Description desc = eventICal.GetProperty(ICSTag.DESCRIPTION) as Description;
if (desc != null)
{
retValue = desc.Value;
}
return retValue;
}
}
}
}

View File

@@ -0,0 +1,42 @@
<phone:PhoneApplicationPage
x:Class="CampusAppWP8.Pages.TimeTable.Appointment"
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 ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
<Grid x:Name="LayoutRoot" Background="Transparent">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<!--TitlePanel enthält den Namen der Anwendung und den Seitentitel-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<TextBlock Text="{Binding Path=LocalizedResources.Appointment, Source={StaticResource LocalizedStrings}}" Style="{StaticResource PhoneTextNormalStyle}"/>
<TextBlock Text="{Binding Path=LocalizedResources.Info, Source={StaticResource LocalizedStrings}}" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
</StackPanel>
<!--ContentPanel - zusätzliche Inhalte hier platzieren-->
<StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<TextBlock x:Name="InfoTitle" Text="{Binding Title}" />
<TextBlock x:Name="InfoDate" Text="{Binding Date}" />
<TextBlock x:Name="InfoLocation" Text="{Binding Location}" />
<TextBlock x:Name="InfoDescription" Text="{Binding Description}" TextWrapping="Wrap" />
</StackPanel>
</Grid>
<phone:PhoneApplicationPage.ApplicationBar>
<shell:ApplicationBar IsVisible="True" IsMenuEnabled="False" Mode="Default" Opacity="1.0" >
</shell:ApplicationBar>
</phone:PhoneApplicationPage.ApplicationBar>
</phone:PhoneApplicationPage>

View File

@@ -0,0 +1,84 @@
//-----------------------------------------------------------------------------
// <copyright file="Appointment.xaml.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>fiedlchr</author>
// <sience>12.09.2013</sience>
//-----------------------------------------------------------------------------
namespace CampusAppWP8.Pages.TimeTable
{
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.Resources;
using CampusAppWP8.Utility;
public partial class Appointment : PhoneApplicationPage
{
public Appointment()
{
this.InitializeComponent();
ApplicationBarIconButton editBtn = new ApplicationBarIconButton();
editBtn.IconUri = new Uri(Icons.Link, UriKind.Relative);
editBtn.Text = AppResources.Edit;
editBtn.Click += new EventHandler(this.OnClickEdit);
ApplicationBar.Buttons.Add(editBtn);
ApplicationBarIconButton deleteBtn = new ApplicationBarIconButton();
deleteBtn.IconUri = new Uri(Icons.TextToSpeech, UriKind.Relative);
deleteBtn.Text = AppResources.Delete;
deleteBtn.Click += new EventHandler(this.OnClickDelete);
ApplicationBar.Buttons.Add(deleteBtn);
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
string appointmentIndex = string.Empty;
// Navigate to the selected pivotitem
if (NavigationContext.QueryString.TryGetValue(Constants.Param_Appointment_Index, out appointmentIndex))
{
int appointmentIndexInt = int.Parse(appointmentIndex);
// if the index is in the range of the array
if ((appointmentIndexInt >= 0) && (appointmentIndexInt < TimeTable.AppointmentsModel.Appointments.Count()))
{
this.DataContext = TimeTable.AppointmentsModel.Appointments[appointmentIndexInt];
}
else
{
string o = string.Empty;
foreach (KeyValuePair<string, string> kvp in NavigationContext.QueryString)
{
o += string.Format("Key = {0}, Value = {1}", kvp.Key, kvp.Value) + "\n";
}
MessageBox.Show("ERROR: appointment index out of range!!! (" + o + ")");
}
}
}
private void OnClickEdit(object sender, EventArgs e)
{
}
private void OnClickDelete(object sender, EventArgs e)
{
TimeTable.AppointmentsModel.Appointments.Remove(this.DataContext as Model.TimeTable.AppointmentModel);
this.NavigationService.GoBack();
}
}
}

View File

@@ -0,0 +1,54 @@
//-----------------------------------------------------------------------------
// <copyright file="TimeTable.cs" company="BTU/IIT">
// Company copyright tag.
// </copyright>
// <author>fiedlchr</author>
// <sience>12.09.2013</sience>
//-----------------------------------------------------------------------------
namespace CampusAppWP8.Pages.TimeTable
{
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.Resources;
using CampusAppWP8.Utility;
using CampusAppWP8.Model.TimeTable;
public partial class TimeTable : PhoneApplicationPage
{
private static AppointmentListModel appList //= null;
= new AppointmentListModel(new AppointmentModel[] {
new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:ownCloud Calendar 0.6.3\r\nX-WR-CALNAME:Das is der Titel\r\nBEGIN:VEVENT\r\nCREATED;VALUE=DATE-TIME:20130827T113216Z\r\nUID:c9904ea73c\r\nLAST-MODIFIED;VALUE=DATE-TIME:20130827T113216Z\r\nDTSTAMP;VALUE=DATE-TIME:20130827T113216Z\r\nSUMMARY:Das is der Titel\r\nDTSTART;VALUE=DATE-TIME:20130827T113500Z\r\nDTEND;VALUE=DATE-TIME:20130827T152000Z\r\nCLASS:PUBLIC\r\nLOCATION:BTU Campus\r\nDESCRIPTION:For Outlook 2003, the behavior is peculiar. It can save the sa\r\n me calendar entry in both .ics and .vcs format, but it only read & displa\r\n y .vcs file correctly. It can read .ics file but it omits some fields and \r\n does not display it in calendar mode. My guess is that back then Microsoft\r\n wanted to provide .ics to be compatible with Mac's iCal but not quite com\r\n mitted to v2.0 yet.\r\nCATEGORIES:Projekte\r\nEND:VEVENT\r\nEND:VCALENDAR"),
new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:http://www.example.com/calendarapplication/\r\nMETHOD:PUBLISH\r\nBEGIN:VEVENT\r\nUID:461092315540@example.com\r\nORGANIZER:MAILTO:alice@example.com\r\nLOCATION:Somewhere\r\nSUMMARY:Eine Kurzinfo\r\nDESCRIPTION:Beschreibung des Termines\r\nCLASS:PUBLIC\r\nDTSTART:20060910T110000Z\r\nDTEND:20060910T195900Z\r\nDTSTAMP:20060812T125900Z\r\nEND:VEVENT\r\nEND:VCALENDAR"),
new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//hacksw/handcal//NONSGML v1.0//EN\r\nBEGIN:VEVENT\r\nUID:uid1@example.com\r\nDTSTAMP:19970714T170000Z\r\nORGANIZER;CN=John Doe:MAILTO:john.doe@example.com\r\nDTSTART:19970714T170000Z\r\nDTEND:19970715T035959Z\r\nSUMMARY:Bastille Day Party\r\nEND:VEVENT\r\nEND:VCALENDAR"),
new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:1.0\r\nBEGIN:VEVENT\r\nCATEGORIES:MEETING\r\nSTATUS:TENTATIVE\r\nDTSTART:19960401T033000Z\r\nDTEND:19960401T043000Z\r\nSUMMARY:Your Proposal Review\r\nDESCRIPTION:Steve and John to review newest proposal material bla fsdfasfsdfsdfgsdafg sfdgfdsgf dsfg dsfgds fgds\r\nCLASS:PRIVATE\r\nEND:VEVENT\r\nEND:VCALENDAR"),
new AppointmentModel("BEGIN:VCALENDAR\r\nPRODID:-//bobbin v0.1//NONSGML iCal Writer//EN\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nMETHOD:PUBLISH\r\nBEGIN:VEVENT\r\nDTSTART:20100701T080000Z\r\nDTEND:20100701T110000Z\r\nDTSTAMP:20091130T213238Z\r\nUID:1285935469767a7c7c1a9b3f0df8003a@yoursever.com\r\nCREATED:20091130T213238Z\r\nDESCRIPTION:Example event 1\r\nLAST-MODIFIED:20091130T213238Z\r\nSEQUENCE:0\r\nSTATUS:CONFIRMED\r\nSUMMARY:Example event 1\r\nTRANSP:OPAQUE\r\nEND:VEVENT\r\nEND:VCALENDAR")
});
public TimeTable()
{
//this.InitializeComponent();
TimeTable.appList = new AppointmentListModel();
}
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
}
public static AppointmentListModel AppointmentsModel
{
get
{
return TimeTable.appList;
}
}
}
}

View File

@@ -11,6 +11,7 @@ using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using CampusAppWP8.Model.TimeTable;
using CampusAppWP8.Utility;
using CampusAppWP8.Resources;
namespace CampusAppWP8.Pages.TimeTable
{
@@ -22,15 +23,11 @@ namespace CampusAppWP8.Pages.TimeTable
private readonly double DAY_TABLE_HEAD_THICKNESS = 2;
private readonly double DAY_TABLE_INNER_THICKNESS = 1;
private AppointmentModel testMod = null;
private AppointmentModel testMod2 = null;
private bool DayLayoutDone = false;
public TimeTableDay()
{
InitializeComponent();
this.testMod = new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:ownCloud Calendar 0.6.3\r\nX-WR-CALNAME:Das is der Titel\r\nBEGIN:VEVENT\r\nCREATED;VALUE=DATE-TIME:20130827T113216Z\r\nUID:c9904ea73c\r\nLAST-MODIFIED;VALUE=DATE-TIME:20130827T113216Z\r\nDTSTAMP;VALUE=DATE-TIME:20130827T113216Z\r\nSUMMARY:Das is der Titel\r\nDTSTART;VALUE=DATE-TIME:20130827T113500Z\r\nDTEND;VALUE=DATE-TIME:20130827T152000Z\r\nCLASS:PUBLIC\r\nLOCATION:BTU Campus\r\nDESCRIPTION:For Outlook 2003, the behavior is peculiar. It can save the sa\r\n me calendar entry in both .ics and .vcs format, but it only read & displa\r\n y .vcs file correctly. It can read .ics file but it omits some fields and \r\n does not display it in calendar mode. My guess is that back then Microsoft\r\n wanted to provide .ics to be compatible with Mac's iCal but not quite com\r\n mitted to v2.0 yet.\r\nCATEGORIES:Projekte\r\nEND:VEVENT\r\nEND:VCALENDAR");
this.testMod2 = new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:http://www.example.com/calendarapplication/\r\nMETHOD:PUBLISH\r\nBEGIN:VEVENT\r\nUID:461092315540@example.com\r\nORGANIZER:MAILTO:alice@example.com\r\nLOCATION:Somewhere\r\nSUMMARY:Eine Kurzinfo\r\nDESCRIPTION:Beschreibung des Termines\r\nCLASS:PUBLIC\r\nDTSTART:20060910T110000Z\r\nDTEND:20060910T195900Z\r\nDTSTAMP:20060812T125900Z\r\nEND:VEVENT\r\nEND:VCALENDAR");
this.DayScroll.LayoutUpdated += new EventHandler(this.AutoScrollToDay);
}
@@ -39,25 +36,46 @@ namespace CampusAppWP8.Pages.TimeTable
{
base.OnNavigatedTo(e);
this.DrawDayViewBackground();
double maxW = Application.Current.Host.Content.ActualWidth;
maxW -= (DAY_TABLE_HEAD_WIDTH + 6.0);
if (e.NavigationMode != NavigationMode.Back)
{
Canvas temp = this.testMod.GetCanvas();
temp.Margin = new Thickness(DAY_TABLE_HEAD_WIDTH + 2, this.testMod.GetYOffset, 0, 0);
this.DayView.Children.Add(temp);
this.DrawDayViewBackground();
temp = this.testMod2.GetCanvas();
temp.Margin = new Thickness(DAY_TABLE_HEAD_WIDTH + 2 + 2 + (maxW / 2), this.testMod2.GetYOffset, 0, 0);
this.DayView.Children.Add(temp);
double maxW = Application.Current.Host.Content.ActualWidth;
maxW -= (DAY_TABLE_HEAD_WIDTH + 6.0);
List<AppointmentModel> tempList = TimeTable.AppointmentsModel.Appointments.ToList();
for (int i = 0; i < tempList.Count(); i++)
{
tempList[i].OnClick += new AppointmentModel.OnAppointmentClick(this.EventOnAppointmentClick);
Canvas temp = tempList[i].GetCanvas();
temp.Margin = new Thickness(DAY_TABLE_HEAD_WIDTH + 2, tempList[i].GetYOffset, 0, 0);
this.DayView.Children.Add(temp);
/*
temp = this.testMod2.GetCanvas();
temp.Margin = new Thickness(DAY_TABLE_HEAD_WIDTH + 2 + 2 + (maxW / 2), this.testMod2.GetYOffset, 0, 0);
this.DayView.Children.Add(temp);
*/
}
}
this.DayLayoutDone = true;
}
private void EventOnAppointmentClick(AppointmentModel sender)
{
int index = TimeTable.AppointmentsModel.Appointments.IndexOf(sender);
if (index >= 0)
{
string urlString = "/Pages/TimeTable/Appointment.xaml?" + Constants.Param_Appointment_Index + "=" + index;
Uri url = new Uri(urlString, UriKind.Relative);
Page page = App.RootFrame.Content as Page;
page.NavigationService.Navigate(url);
}
}
private void AutoScrollToDay(object sender, EventArgs e)
{

View File

@@ -96,6 +96,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Termin ähnelt.
/// </summary>
public static string Appointment {
get {
return ResourceManager.GetString("Appointment", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Gebäude ähnelt.
/// </summary>
@@ -213,6 +222,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Bearbeiten ähnelt.
/// </summary>
public static string Edit {
get {
return ResourceManager.GetString("Edit", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Events ähnelt.
/// </summary>

View File

@@ -431,4 +431,10 @@
<data name="PersonApp_Title" xml:space="preserve">
<value>Personen</value>
</data>
<data name="Appointment" xml:space="preserve">
<value>Termin</value>
</data>
<data name="Edit" xml:space="preserve">
<value>Bearbeiten</value>
</data>
</root>

View File

@@ -492,6 +492,15 @@ namespace CampusAppWP8.Resources {
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die AppointmentIndex ähnelt.
/// </summary>
public static string Param_Appointment_Index {
get {
return ResourceManager.GetString("Param_Appointment_Index", resourceCulture);
}
}
/// <summary>
/// Sucht eine lokalisierte Zeichenfolge, die Studiengang ähnelt.
/// </summary>

View File

@@ -459,4 +459,7 @@
<data name="UniCBTelPrefix" xml:space="preserve">
<value>035569</value>
</data>
<data name="Param_Appointment_Index" xml:space="preserve">
<value>AppointmentIndex</value>
</data>
</root>