daily commit
This commit is contained in:
@@ -151,6 +151,7 @@
|
||||
<Compile Include="Pages\TimeTable\TimeTableWeek.xaml.cs">
|
||||
<DependentUpon>TimeTableWeek.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Pages\TimeTable\WeekViewPageItem.cs" />
|
||||
<Compile Include="Utility\ICalObject.cs" />
|
||||
<Compile Include="Utility\ICSClasses.cs" />
|
||||
<Compile Include="Utility\ICSManager.cs" />
|
||||
@@ -247,6 +248,9 @@
|
||||
<DependentUpon>WeekViewPivotHeader.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Utility\Lui\ListBoxFixed.cs" />
|
||||
<Compile Include="Utility\Lui\Templates\AppointmentCanvas.xaml.cs">
|
||||
<DependentUpon>AppointmentCanvas.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Utility\Lui\Templates\WeekView.xaml.cs">
|
||||
<DependentUpon>WeekView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -531,6 +535,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Utility\Lui\Templates\AppointmentCanvas.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Utility\Lui\Templates\WeekView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
||||
@@ -25,16 +25,8 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
[XmlRoot("root")]
|
||||
public class AppointmentModel
|
||||
{
|
||||
/// <summary>The Visual object.</summary>
|
||||
//private Rectangle rect = null;
|
||||
//private Canvas canvas = null;
|
||||
//private double offsetY = 0;
|
||||
//private double height = 0;
|
||||
//private double width = 100;
|
||||
|
||||
private ICalObject icalObj = null;
|
||||
//private ICalObject eventICalObj = null;
|
||||
|
||||
|
||||
public delegate void OnAppointmentClick(AppointmentModel sender);
|
||||
public event OnAppointmentClick OnClick = null;
|
||||
|
||||
@@ -53,11 +45,6 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
this.icalObj.Header = newBegin;
|
||||
this.icalObj.AddProperty(newVersion);
|
||||
this.icalObj.AddProperty(newProdID);
|
||||
|
||||
//this.rect = new Rectangle();
|
||||
//this.canvas = new Canvas();
|
||||
//this.canvas.DoubleTap += new EventHandler<System.Windows.Input.GestureEventArgs>(this.OnCanvasClick);
|
||||
//this.canvas.SizeChanged += new SizeChangedEventHandler(this.OnCanvasSizeChanged);
|
||||
}
|
||||
|
||||
public AppointmentModel(string icsData) : this()
|
||||
@@ -150,93 +137,50 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
vevent.AddProperty(value);
|
||||
}
|
||||
|
||||
public Canvas GetCanvas(double width, double hourSpacing, DateTime date)
|
||||
public object GetValue(string propertyName)
|
||||
{
|
||||
Canvas retValue = new Canvas();
|
||||
//retValue.DoubleTap += new EventHandler<System.Windows.Input.GestureEventArgs>()
|
||||
retValue.Tag = this;
|
||||
|
||||
if (this.End.Date.Equals(this.Start.Date) == false)
|
||||
{
|
||||
DateTime realDate = date.Date;
|
||||
|
||||
if (realDate.Equals(this.Start.Date))
|
||||
{
|
||||
TimeSpan span = this.Start.Date.AddDays(1).Subtract(this.Start);
|
||||
retValue.Height = span.TotalHours * hourSpacing;
|
||||
retValue.Margin = new Thickness(0, (hourSpacing * this.Start.TimeOfDay.TotalHours), 0, 0);
|
||||
}
|
||||
else if (realDate.Equals(this.End.Date))
|
||||
{
|
||||
retValue.Height = this.End.TimeOfDay.TotalHours * hourSpacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
retValue.Height = hourSpacing * 24;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
TimeSpan span = this.End.Subtract(this.Start);
|
||||
retValue.Height = span.TotalHours * hourSpacing;
|
||||
retValue.Margin = new Thickness(0, (hourSpacing * this.Start.TimeOfDay.TotalHours), 0, 0);
|
||||
}
|
||||
|
||||
retValue.Width = width;
|
||||
|
||||
this.CreateRect(retValue);
|
||||
this.CreateContent(retValue, hourSpacing);
|
||||
object retValue = this.GetVEventObj().GetProperty(propertyName);
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
private void CreateRect(Canvas can)
|
||||
public double GetTotalHours()
|
||||
{
|
||||
// can.Children.Clear();
|
||||
|
||||
Rectangle rect = new Rectangle();
|
||||
rect.Width = can.Width;
|
||||
rect.Height = can.Height;
|
||||
|
||||
rect.StrokeThickness = 1;
|
||||
rect.Stroke = new SolidColorBrush(Colors.DarkGray);
|
||||
rect.Fill = new SolidColorBrush(Colors.Green);
|
||||
rect.RadiusX = 5;
|
||||
rect.RadiusY = 5;
|
||||
|
||||
can.Children.Add(rect);
|
||||
return this.End.Subtract(this.Start).TotalHours;
|
||||
}
|
||||
|
||||
private void CreateContent(Canvas can, double hourSpacing)
|
||||
public double GetTotalHours(DateTime date)
|
||||
{
|
||||
if (this.icalObj != null)
|
||||
double retValue = 0;
|
||||
|
||||
if (date.Date.Equals(this.Start.Date))
|
||||
{
|
||||
ICalObject eventObj = this.GetVEventObj();
|
||||
Summary title = eventObj.GetProperty(ICSTag.SUMMARY) as Summary;
|
||||
|
||||
TextBlock txtTitle = new TextBlock();
|
||||
txtTitle.FontSize = hourSpacing / 3;
|
||||
txtTitle.FontWeight = FontWeights.Bold;
|
||||
txtTitle.TextWrapping = TextWrapping.Wrap;
|
||||
txtTitle.Width = can.Width - 4.0;
|
||||
txtTitle.SetValue(Canvas.LeftProperty, 3.0);
|
||||
txtTitle.SetValue(Canvas.TopProperty, 3.0);
|
||||
|
||||
if (can.Height >= ((hourSpacing / 2)))
|
||||
if (this.End.Date.Equals(this.Start.Date))
|
||||
{
|
||||
txtTitle.Margin = new Thickness(0, -2, 0, 0);
|
||||
txtTitle.Text = title.Value;
|
||||
retValue = this.GetTotalHours();
|
||||
}
|
||||
else
|
||||
{
|
||||
txtTitle.Height = can.Height;
|
||||
txtTitle.VerticalAlignment = VerticalAlignment.Center;
|
||||
txtTitle.Margin = new Thickness(0, -10, 0, 0);
|
||||
txtTitle.Text = "...";
|
||||
retValue = date.Date.AddDays(1).Subtract(this.Start).TotalHours;
|
||||
}
|
||||
|
||||
can.Children.Add(txtTitle);
|
||||
}
|
||||
else if (date.Date.Equals(this.End.Date))
|
||||
{
|
||||
retValue = this.End.Subtract(date.Date).TotalHours;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.Start.Date <= date && date <= this.End.Date)
|
||||
{
|
||||
retValue = 24;
|
||||
}
|
||||
else
|
||||
{
|
||||
retValue = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
private ICalObject GetVEventObj(bool create = false)
|
||||
|
||||
@@ -24,9 +24,9 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
{
|
||||
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:20131002T113500Z\r\nDTEND;VALUE=DATE-TIME:20131002T212000Z\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:20131002T110000Z\r\nDTEND:20131004T113000Z\r\nDTSTAMP:20131003T125900Z\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:20131003T150000Z\r\nDTEND:20131003T170000Z\r\nSUMMARY:Bastille Day Party\r\nEND:VEVENT\r\nEND:VCALENDAR"),
|
||||
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:20131022T113500Z\r\nDTEND;VALUE=DATE-TIME:20131022T212000Z\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 welche einen etwas längeren titel enthält\r\nDESCRIPTION:Beschreibung des Termines\r\nCLASS:PUBLIC\r\nDTSTART:20131023T110000Z\r\nDTEND:20131024T113000Z\r\nDTSTAMP:20131003T125900Z\r\nPRIORITY:3\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:20131025T150000Z\r\nDTEND:20131025T170000Z\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:20130917T033000Z\r\nDTEND:20130917T043000Z\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:20130918T080000Z\r\nDTEND:20130918T110000Z\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"),
|
||||
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:20130914T120000Z\r\nDTEND:20130914T140000Z\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")
|
||||
|
||||
@@ -471,6 +471,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
private void DrawAppointmentModel(AppointmentModel model, int index, double opacity = 1.0, int zIndex = 0, int modelCount = 0)
|
||||
{
|
||||
/* TODO
|
||||
Canvas modelCan = model.GetCanvas(
|
||||
((this.itemPages[index].Content.Width - DAY_TABLE_HEAD_WIDTH) - 2 - 2 - (modelCount * DAY_TABLE_ZINDEX_SHIFT)),
|
||||
DAY_TABLE_CELL_HEIGHT,
|
||||
@@ -479,6 +480,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
modelCan.DoubleTap += new EventHandler<System.Windows.Input.GestureEventArgs>(this.OnAppointmentClick);
|
||||
|
||||
this.DrawAppointmentCanvas(modelCan, index, opacity, zIndex, modelCount);
|
||||
*/
|
||||
}
|
||||
|
||||
private void DrawMultiBubble(int stackIndex, int listIndex, int number, double xOffset, double yOffset)
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
SupportedOrientations="Landscape" Orientation="Landscape"
|
||||
mc:Ignorable="d"
|
||||
shell:SystemTray.IsVisible="True">
|
||||
shell:SystemTray.IsVisible="True"
|
||||
>
|
||||
|
||||
<!--LayoutRoot ist das Stammraster, in dem alle anderen Seiteninhalte platziert werden-->
|
||||
<Grid x:Name="LayoutRoot" Background="Transparent">
|
||||
@@ -27,11 +28,11 @@
|
||||
<DataTemplate>
|
||||
<templ:WeekView
|
||||
x:Name="TheWeekView"
|
||||
Margin="0,-36,0,0"
|
||||
DateFrom="{Binding DateFrom, Mode=OneWay}"
|
||||
WeekName="{Binding WeekChar, Mode=OneWay}"
|
||||
Appointments="{Binding AppointmentList, Mode=OneWay}"
|
||||
WeekNumber="{Binding WeekNumber, Mode=OneWay}"/>
|
||||
Margin="0,-36,0,0"
|
||||
DateFrom="{Binding Path=FromDT, Mode=OneWay}"
|
||||
WeekName="{Binding Path=WeekStr, Mode=OneWay}"
|
||||
Appointments="{Binding Path=AppointmentList, Mode=OneWay}"
|
||||
WeekNumber="{Binding Path=WeekNr, Mode=OneWay}"/>
|
||||
</DataTemplate>
|
||||
</phone:Pivot.ItemTemplate>
|
||||
</phone:Pivot>
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
@@ -33,25 +34,14 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
private static readonly double WEEK_TABLE_INNER_THICKNESS = 1;
|
||||
private static readonly int WEEK_TABLE_ZINDEX_MAX = 10;
|
||||
|
||||
|
||||
private struct PageItem
|
||||
{
|
||||
public DateTime DateFrom { get; set; }
|
||||
public DateTime DateTo { get; set; }
|
||||
public char WeekChar { get; set; }
|
||||
public int WeekNumber { get; set; }
|
||||
public WeekView weekView { get; set; }
|
||||
//???
|
||||
public List<Appointment> AppointmentList { get; set; }
|
||||
}
|
||||
|
||||
private static readonly int PIVOT_PAGES = 3;
|
||||
private static readonly int PIVOT_PAGES_HALF_DOWN = 1;
|
||||
private static readonly int PIVOT_PAGES_COLUMNS = 5; // days in week
|
||||
|
||||
private PageItem[] itemPages = new PageItem[PIVOT_PAGES];
|
||||
private int lastSelectedIndex = 0;
|
||||
|
||||
|
||||
private ObservableCollection<WeekViewPageItem> itemList = new ObservableCollection<WeekViewPageItem>();
|
||||
|
||||
public TimeTableWeek()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
@@ -60,10 +50,13 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
for (int i = 0; i < PIVOT_PAGES; i++)
|
||||
{
|
||||
this.itemPages[i].DateFrom = firstDay;
|
||||
this.itemPages[i].DateTo = firstDay.AddDays(6);
|
||||
this.itemPages[i].WeekNumber = this.GetWeekNumber(this.itemPages[i].DateFrom);
|
||||
this.itemPages[i].WeekChar = ((this.itemPages[i].WeekNumber % 2) != 0) ? 'A' : 'B';
|
||||
int weekNr = this.GetWeekNumber(firstDay);
|
||||
string weekStr = ((weekNr % 2) != 0) ? "A" : "B";
|
||||
|
||||
WeekViewPageItem newItem = new WeekViewPageItem(firstDay, weekStr, weekNr, 6);
|
||||
|
||||
this.itemList.Add(newItem);
|
||||
|
||||
firstDay = firstDay.AddDays(7);
|
||||
}
|
||||
|
||||
@@ -102,9 +95,11 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
else
|
||||
{
|
||||
this.ThePivot.ItemsSource = this.itemPages;
|
||||
this.ThePivot.ItemsSource = this.itemList;
|
||||
this.lastSelectedIndex = PIVOT_PAGES_HALF_DOWN;
|
||||
this.ThePivot.SelectedIndex = PIVOT_PAGES_HALF_DOWN;
|
||||
|
||||
this.CheckAppointments();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +151,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
page.NavigationService.Navigate(url);
|
||||
*/
|
||||
// this.itemPages[this.ThePivot.SelectedIndex].weekView.SetColumnBackground(0, new SolidColorBrush(Colors.Red));
|
||||
(this.ThePivot.SelectedItem as WeekViewPageItem).AppointmentList.Add(TimeTable.AppointmentsModel.Appointments[1]);
|
||||
}
|
||||
|
||||
private void OnClickToday(object sender, EventArgs e)
|
||||
@@ -198,7 +194,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
private void OnPivotSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
int delta = this.ThePivot.SelectedIndex - this.lastSelectedIndex;
|
||||
|
||||
/*
|
||||
if (delta < -1) delta = 1;
|
||||
else if (delta > 1) delta = -1;
|
||||
|
||||
@@ -210,10 +206,10 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
else
|
||||
{
|
||||
this.itemPages[index].DateFrom = this.itemPages[this.ThePivot.SelectedIndex].DateFrom.AddDays((7 * delta));
|
||||
this.itemPages[index].DateTo = this.itemPages[this.ThePivot.SelectedIndex].DateTo.AddDays((7 * delta));
|
||||
this.itemList[index].FromDT = this.itemList[this.ThePivot.SelectedIndex].FromDT.AddDays((7 * delta));
|
||||
this.itemList[index].ToDT = this.itemList[this.ThePivot.SelectedIndex].ToDT.AddDays((7 * delta));
|
||||
}
|
||||
|
||||
*/
|
||||
//this.itemPages[index].Content.Children.Clear();
|
||||
// this.itemPages[index].WeekNumber = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(
|
||||
// this.itemPages[index].DateFrom,
|
||||
@@ -292,7 +288,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
*/
|
||||
// this.RemoveContentUIElement(index, sender as Canvas);
|
||||
|
||||
bool bubbleDrawn = false;
|
||||
//bool bubbleDrawn = false;
|
||||
/*
|
||||
for (int day = 0; day < 5; day++)
|
||||
{
|
||||
@@ -329,7 +325,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
{
|
||||
for (int i = 0; i < PIVOT_PAGES; i++)
|
||||
{
|
||||
if (tempModel.IsDate(this.itemPages[i].DateFrom, 4) > -1)
|
||||
if (tempModel.IsDate(this.itemList[i].FromDT, 4) > -1)
|
||||
{
|
||||
this.SetupPage(i);
|
||||
}
|
||||
@@ -337,30 +333,21 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCanvasSizeChanged(object sender, SizeChangedEventArgs e)
|
||||
private void CheckAppointments()
|
||||
{
|
||||
/*
|
||||
if (e.NewSize.Width.Equals(e.PreviousSize.Width) == false)
|
||||
foreach (AppointmentModel m in TimeTable.AppointmentsModel.Appointments)
|
||||
{
|
||||
Canvas tempContainer = (sender as Canvas);
|
||||
Canvas tempBG = (tempContainer.Children[0] as Canvas);
|
||||
Canvas tempContent = (tempContainer.Children[1] as Canvas);
|
||||
tempBG.Width = e.NewSize.Width;
|
||||
tempBG.Height = e.NewSize.Height;
|
||||
tempContent.Width = e.NewSize.Width;
|
||||
tempContent.Height = e.NewSize.Height;
|
||||
|
||||
PivotItem pvItem = ((tempContainer.Parent as ScrollViewer).Parent as PivotItem);
|
||||
Grid headGrid = pvItem.Header as Grid;
|
||||
int index = this.ThePivot.Items.IndexOf(pvItem);
|
||||
|
||||
headGrid.Width = e.NewSize.Width;
|
||||
|
||||
this.SetupPage(index);
|
||||
for (int i = 0; i < PIVOT_PAGES; i++)
|
||||
{
|
||||
if (m.IsDate(this.itemList[i].FromDT, 4) >= 0)
|
||||
{
|
||||
this.itemList[i].AppointmentList.Add(m);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
private void SetupPage(int index)
|
||||
{
|
||||
// Header
|
||||
@@ -400,7 +387,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
*/
|
||||
if (TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemPages[index].DateFrom.Date, 4) > -1)
|
||||
if (TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemList[index].FromDT.Date, 4) > -1)
|
||||
{
|
||||
tempList.Add(TimeTable.AppointmentsModel.Appointments[i]);
|
||||
}
|
||||
@@ -633,46 +620,6 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
*/
|
||||
}
|
||||
|
||||
private void RemoveContentUIElement(int index, UIElement elem)
|
||||
{
|
||||
// if (this.itemPages[index].Content.Children.Remove(elem) == false)
|
||||
{
|
||||
throw new ArgumentException();
|
||||
}
|
||||
}
|
||||
|
||||
private void RemoveContentUIElement(int index, AppointmentModel model)
|
||||
{
|
||||
Canvas[] list = this.GetModelCanvasFromContent(index, model);
|
||||
|
||||
if (list.Count() > 0)
|
||||
{
|
||||
foreach (Canvas can in list)
|
||||
{
|
||||
// this.itemPages[index].Content.Children.Remove(can);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Canvas[] GetModelCanvasFromContent(int index, AppointmentModel model)
|
||||
{
|
||||
List<Canvas> retValue = new List<Canvas>();
|
||||
|
||||
// foreach (FrameworkElement elem in this.itemPages[index].Content.Children)
|
||||
{
|
||||
// if (elem.Tag.GetType().Equals(typeof(AppointmentModel)))
|
||||
{
|
||||
// if ((elem.Tag as AppointmentModel).Equals(model))
|
||||
{
|
||||
// retValue.Add(elem as Canvas);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retValue.ToArray();
|
||||
}
|
||||
|
||||
|
||||
private void DrawAppointment(AppointmentModel model, int index, int xIndex, double opacity = 1.0, int zIndex = 0, int modelCount = 0)
|
||||
{
|
||||
/*
|
||||
@@ -736,107 +683,6 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
// this.itemPages[index].Content.Children.Add(can);
|
||||
}
|
||||
/*
|
||||
private PageItem CreatePivotItem(PageItem pItem)
|
||||
{
|
||||
pItem.pItemPtr = new PivotItem();
|
||||
pItem.pItemPtr.Header = new Grid();
|
||||
|
||||
pItem.weekView = new WeekView();
|
||||
pItem.weekView.Name = "TheWeekView";
|
||||
pItem.weekView.StartDate = pItem.DateFrom;
|
||||
|
||||
WeekViewPivotHeader wvpHeader = new WeekViewPivotHeader();
|
||||
wvpHeader.DateFrom = pItem.DateFrom;
|
||||
|
||||
Grid g = (pItem.pItemPtr.Header as Grid);
|
||||
|
||||
Binding colLineBind = new Binding();
|
||||
colLineBind.Path = new PropertyPath("ActualWidth");
|
||||
colLineBind.ElementName = "TheWeekView";
|
||||
colLineBind.Mode = BindingMode.OneWay;
|
||||
|
||||
g.SetBinding(WidthProperty, colLineBind);
|
||||
g.Children.Clear();
|
||||
//wvpHeader.Width = g.Width;
|
||||
//g.Children.Add(wvpHeader);
|
||||
|
||||
RowDefinition row = new RowDefinition();
|
||||
row.Height = GridLength.Auto;
|
||||
g.RowDefinitions.Add(row);
|
||||
|
||||
g.Background = new SolidColorBrush(Colors.Green);
|
||||
TextBlock tb = new TextBlock();
|
||||
tb.Text = "hallo";
|
||||
tb.SetValue(Grid.RowProperty, 0);
|
||||
g.Children.Add(tb);
|
||||
|
||||
pItem.pItemPtr.Content = pItem.weekView;
|
||||
|
||||
return pItem;
|
||||
}
|
||||
*/
|
||||
private void DrawHeader(int index)
|
||||
{
|
||||
Grid grid = ((this.ThePivot.Items[index] as PivotItem).Header as Grid);
|
||||
string text = string.Format("{0:dd.MM.yyyy} < {1:c} > {2:dd.MM.yyyy}", this.itemPages[index].DateFrom, this.itemPages[index].WeekChar, this.itemPages[index].DateTo);
|
||||
|
||||
RowDefinition row_0 = new RowDefinition();
|
||||
RowDefinition row_1 = new RowDefinition();
|
||||
row_0.Height = GridLength.Auto;
|
||||
row_1.Height = GridLength.Auto;
|
||||
|
||||
grid.RowDefinitions.Add(row_0);
|
||||
grid.RowDefinitions.Add(row_1);
|
||||
|
||||
TextBlock newTB = new TextBlock();
|
||||
newTB.Text = text;
|
||||
newTB.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
newTB.FontSize = 24;
|
||||
newTB.SetValue(Grid.RowProperty, 0);
|
||||
|
||||
grid.Children.Add(newTB);
|
||||
|
||||
Canvas headCan = new Canvas();
|
||||
|
||||
string[] dayStr = new string[] {"Mo", "Di", "Mi", "Do", "Fr" };
|
||||
|
||||
double w = (grid.Width - WEEK_TABLE_HEAD_WIDTH) / 5;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
Rectangle dayRect = new Rectangle();
|
||||
TextBlock dayTB = new TextBlock();
|
||||
|
||||
dayRect.Width = w;
|
||||
dayRect.Height = 30;
|
||||
dayRect.StrokeThickness = WEEK_TABLE_HEAD_THICKNESS;
|
||||
dayRect.Stroke = new SolidColorBrush(Colors.White);
|
||||
dayRect.Stretch = Stretch.Fill;
|
||||
dayRect.Margin = new Thickness(WEEK_TABLE_HEAD_WIDTH - 9 + i * w, 0, 0, 0);
|
||||
|
||||
if (this.itemPages[index].DateFrom.Date.AddDays(i).Equals(DateTime.Now.Date))
|
||||
{
|
||||
dayRect.Fill = new SolidColorBrush(Colors.White);
|
||||
dayTB.Foreground = new SolidColorBrush(Colors.Black);
|
||||
}
|
||||
|
||||
headCan.Children.Add(dayRect);
|
||||
|
||||
dayTB.Text = dayStr[i];
|
||||
dayTB.TextAlignment = TextAlignment.Center;
|
||||
dayTB.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
dayTB.Width = w;
|
||||
dayTB.FontSize = 16;
|
||||
dayTB.Margin = new Thickness(WEEK_TABLE_HEAD_WIDTH - 9 + i * w, 4, 0, 0);
|
||||
|
||||
headCan.Children.Add(dayTB);
|
||||
}
|
||||
|
||||
headCan.SetValue(Grid.RowProperty, 1);
|
||||
|
||||
grid.Children.Add(headCan);
|
||||
}
|
||||
|
||||
private void ThePivot_LoadedPivotItem(object sender, PivotItemEventArgs e)
|
||||
{
|
||||
|
||||
128
CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs
Normal file
128
CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs
Normal file
@@ -0,0 +1,128 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using CampusAppWP8.Utility.Lui.Templates;
|
||||
using CampusAppWP8.Model.TimeTable;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace CampusAppWP8.Pages.TimeTable
|
||||
{
|
||||
public class WeekViewPageItem : INotifyPropertyChanged
|
||||
{
|
||||
private DateTime fromDT;
|
||||
private DateTime toDT;
|
||||
private int days;
|
||||
private string weekStr = string.Empty;
|
||||
private int weekNumber = -1;
|
||||
private WeekView weekView = null;
|
||||
private ObservableCollection<AppointmentModel> appointmentList = null;
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
||||
public WeekViewPageItem(DateTime from, string str, int number, int days)
|
||||
{
|
||||
this.fromDT = from;
|
||||
this.toDT = from.Date.AddDays(days);
|
||||
this.days = days;
|
||||
this.weekStr = str;
|
||||
this.weekNumber = number;
|
||||
this.appointmentList = new ObservableCollection<AppointmentModel>();
|
||||
}
|
||||
|
||||
public DateTime FromDT
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.fromDT;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.fromDT = value;
|
||||
this.NotifyPropertyChanged("FromDT");
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime ToDT
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.toDT;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.toDT = value;
|
||||
this.NotifyPropertyChanged("ToDT");
|
||||
}
|
||||
}
|
||||
|
||||
public string WeekStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.weekStr;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.weekStr = value;
|
||||
this.NotifyPropertyChanged("WeekStr");
|
||||
}
|
||||
}
|
||||
|
||||
public int WeekNr
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.weekNumber;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.weekNumber = value;
|
||||
this.NotifyPropertyChanged("WeekNr");
|
||||
}
|
||||
}
|
||||
|
||||
public WeekView View
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.weekView;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.weekView = value;
|
||||
this.NotifyPropertyChanged("View");
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<AppointmentModel> AppointmentList
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.appointmentList;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.appointmentList = value;
|
||||
this.NotifyPropertyChanged("AppointmentList");
|
||||
}
|
||||
}
|
||||
|
||||
private void NotifyPropertyChanged(string info)
|
||||
{
|
||||
if (this.PropertyChanged != null)
|
||||
{
|
||||
this.PropertyChanged(this, new PropertyChangedEventArgs(info));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<UserControl x:Class="CampusAppWP8.Utility.Lui.Templates.AppointmentCanvas"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
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}"
|
||||
>
|
||||
|
||||
<Canvas
|
||||
SizeChanged="TheMainCanvas_SizeChanged">
|
||||
|
||||
<Rectangle x:Name="TheRect"
|
||||
Stroke="Gray"
|
||||
StrokeThickness="1"
|
||||
Fill="LightBlue"
|
||||
RadiusX="5"
|
||||
RadiusY="5"
|
||||
/>
|
||||
<TextBlock x:Name="TheText"
|
||||
FontSize="14"
|
||||
Padding="3"
|
||||
TextWrapping="Wrap"
|
||||
/>
|
||||
</Canvas>
|
||||
</UserControl>
|
||||
@@ -0,0 +1,125 @@
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="AppointmentCanvas.xaml.cs" company="BTU/IIT">
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>Fiedler</author>
|
||||
// <date>28.10.2013</date>
|
||||
// <summary>Implements the appointment canvas.xaml class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Utility.Lui.Templates
|
||||
{
|
||||
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.TimeTable;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
public partial class AppointmentCanvas : UserControl
|
||||
{
|
||||
private static readonly double HOURS_SPACING = 40;
|
||||
private static readonly double INDEX_SPACING = 10;
|
||||
|
||||
private static readonly SolidColorBrush[] PRIO_COLORS = new SolidColorBrush[]
|
||||
{
|
||||
new SolidColorBrush(Colors.Green),
|
||||
new SolidColorBrush(Colors.Orange),
|
||||
new SolidColorBrush(Colors.Blue),
|
||||
new SolidColorBrush(Colors.Brown),
|
||||
new SolidColorBrush(Colors.Cyan),
|
||||
new SolidColorBrush(Colors.DarkGray),
|
||||
new SolidColorBrush(Colors.Magenta),
|
||||
new SolidColorBrush(Colors.Purple),
|
||||
new SolidColorBrush(Colors.Yellow),
|
||||
new SolidColorBrush(Colors.Red)
|
||||
};
|
||||
|
||||
private AppointmentModel appPtr = null;
|
||||
|
||||
public AppointmentCanvas() : base()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
public AppointmentCanvas(AppointmentModel model) : this(model, new DateTime(0))
|
||||
{
|
||||
}
|
||||
|
||||
public AppointmentCanvas(AppointmentModel model, DateTime day) : this()
|
||||
{
|
||||
this.appPtr = model;
|
||||
|
||||
this.Height = model.GetTotalHours(day) * HOURS_SPACING;
|
||||
this.SetText(model.Title);
|
||||
this.SetValue(Canvas.TopProperty, (day.Date.Equals(model.Start.Date)) ? (model.Start.TimeOfDay.TotalHours * HOURS_SPACING) : 0);
|
||||
|
||||
object tempProp = null;
|
||||
|
||||
if ((tempProp = model.GetValue(ICSTag.PRIORITY)) != null)
|
||||
{
|
||||
this.SetBGColorByPriority((tempProp as ICSProperties.Priority).Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.SetBGColorByPriority(0);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Is(AppointmentModel model)
|
||||
{
|
||||
return (this.appPtr.Equals(model));
|
||||
}
|
||||
|
||||
public void SetListPosition(int index, int count)
|
||||
{
|
||||
this.Margin = new Thickness(
|
||||
(INDEX_SPACING * index),
|
||||
0,
|
||||
(INDEX_SPACING * count),
|
||||
0);
|
||||
|
||||
if (index > 0)
|
||||
{
|
||||
this.Opacity = 0.5;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetListPosition(List<AppointmentModel> list)
|
||||
{
|
||||
int index = list.IndexOf(this.appPtr);
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
this.SetListPosition(index, list.Count);
|
||||
}
|
||||
}
|
||||
|
||||
private void TheMainCanvas_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
// because Binding did not work, why ever
|
||||
this.TheRect.Width = ((e.NewSize.Width - this.Margin.Right) < 0) ? 0 : (e.NewSize.Width - this.Margin.Right);
|
||||
this.TheRect.Height = e.NewSize.Height;
|
||||
this.TheText.Width = ((e.NewSize.Width - this.Margin.Right) < 0) ? 0 : (e.NewSize.Width - this.Margin.Right);
|
||||
this.TheText.Height = e.NewSize.Height;
|
||||
}
|
||||
|
||||
private void SetText(string text)
|
||||
{
|
||||
this.TheText.Text = text;
|
||||
}
|
||||
|
||||
private void SetBGColorByPriority(int prio)
|
||||
{
|
||||
if (prio < PRIO_COLORS.Count() && prio >= 0)
|
||||
{
|
||||
this.TheRect.Fill = PRIO_COLORS[prio];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
>
|
||||
x:Name="root">
|
||||
|
||||
<Grid x:Name="ContentRoot">
|
||||
<Grid.RowDefinitions>
|
||||
@@ -30,12 +30,12 @@
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock x:Name="TB_KW" Grid.Column="0" Text="{Binding Path=LocalizedResources.Calendar_Week_Short, Source={StaticResource LocalizedStrings}}" FontStretch="SemiExpanded" FontSize="20"/>
|
||||
<TextBlock x:Name="TB_KW_NUM" Grid.Column="1" Text="{Binding WeekNumber, Mode=OneWay}" FontStretch="Expanded" FontSize="20"/>
|
||||
<TextBlock x:Name="TB_From" Grid.Column="2" Text="{Binding DateFrom, Mode=OneWay, StringFormat='dd.MM.yyyy'}" HorizontalAlignment="Center" FontSize="20"/>
|
||||
<TextBlock x:Name="TB_KW_NUM" Grid.Column="1" Text="{Binding WeekNumber, ElementName=root, Mode=OneWay}" FontStretch="Expanded" FontSize="20"/>
|
||||
<TextBlock x:Name="TB_From" Grid.Column="2" Text="{Binding DateFrom, ElementName=root, Mode=OneWay, StringFormat='dd.MM.yyyy'}" HorizontalAlignment="Center" FontSize="20"/>
|
||||
<TextBlock Grid.Column="3" Text="<" HorizontalAlignment="Center" FontSize="20"/>
|
||||
<TextBlock x:Name="TB_Week_Char" Grid.Column="4" Text="{Binding WeekName, Mode=OneWay}" HorizontalAlignment="Center" FontSize="20"/>
|
||||
<TextBlock Grid.Column="4" Text="{Binding WeekName, ElementName=root, Mode=OneWay}" HorizontalAlignment="Center" FontSize="20"/>
|
||||
<TextBlock Grid.Column="5" Text=">" HorizontalAlignment="Center" FontSize="20"/>
|
||||
<TextBlock x:Name="TB_To" Grid.Column="6" Text="{Binding DateTo, Mode=OneWay, StringFormat='dd.MM.yyyy'}" HorizontalAlignment="Center" FontSize="20"/>
|
||||
<TextBlock x:Name="TB_To" Grid.Column="6" Text="{Binding DateTo, ElementName=root, Mode=OneWay, StringFormat='dd.MM.yyyy'}" HorizontalAlignment="Center" FontSize="20"/>
|
||||
</Grid>
|
||||
|
||||
<Grid x:Name="Head_Days" Grid.Row="1">
|
||||
@@ -48,7 +48,7 @@
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
|
||||
<Line Grid.Column="0" X1="0" Y1="0" X2="1" Y2="0" VerticalAlignment="Bottom" Stroke="White" Stretch="Fill" StrokeThickness="2" HorizontalAlignment="Left" Margin="-1,0,-1,0"/>
|
||||
<Border Grid.Column="1" BorderThickness="2" BorderBrush="White" Background="DarkGoldenrod">
|
||||
<TextBlock Text="{Binding Path=LocalizedResources.Time_Day_Monday_Short, Source={StaticResource LocalizedStrings}}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
|
||||
</Border>
|
||||
|
||||
@@ -9,6 +9,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
@@ -18,30 +20,89 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
using Microsoft.Phone.Controls;
|
||||
using Microsoft.Phone.Shell;
|
||||
using CampusAppWP8.Model.TimeTable;
|
||||
|
||||
|
||||
|
||||
public partial class WeekView : UserControl
|
||||
{
|
||||
public static readonly DependencyProperty DateFromProperty = DependencyProperty.Register("DateFrom", typeof(DateTime), typeof(WeekView), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DateToProperty = DependencyProperty.Register("DateTo", typeof(DateTime), typeof(WeekView), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DaysProperty = DependencyProperty.Register("Days", typeof(int), typeof(WeekView), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(List<AppointmentModel>), typeof(WeekView), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty WeekNameProperty = DependencyProperty.Register("WeekName", typeof(string), typeof(WeekView), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty WeekNumberProperty = DependencyProperty.Register("WeekNumber", typeof(int), typeof(WeekView), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DateFromProperty = DependencyProperty.Register("DateFrom", typeof(DateTime), typeof(WeekView), new PropertyMetadata(new DateTime(0), OnDateFromChanged));
|
||||
public static readonly DependencyProperty DateToProperty = DependencyProperty.Register("DateTo", typeof(DateTime), typeof(WeekView), new PropertyMetadata(new DateTime(0)));
|
||||
public static readonly DependencyProperty DaysProperty = DependencyProperty.Register("Days", typeof(int), typeof(WeekView), new PropertyMetadata(5));
|
||||
public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(ObservableCollection<AppointmentModel>), typeof(WeekView), new PropertyMetadata(null, OnAppointmentsChanged));
|
||||
public static readonly DependencyProperty WeekNameProperty = DependencyProperty.Register("WeekName", typeof(string), typeof(WeekView), new PropertyMetadata("T-Woche"));
|
||||
public static readonly DependencyProperty WeekNumberProperty = DependencyProperty.Register("WeekNumber", typeof(int), typeof(WeekView), new PropertyMetadata(-1));
|
||||
|
||||
private List<Border> borderList = new List<Border>();
|
||||
private List<WeekViewDay> dayList = new List<WeekViewDay>();
|
||||
|
||||
private string[] timeStrings = new string[24];
|
||||
private string[] monStrings = new string[24];
|
||||
|
||||
|
||||
public WeekView()
|
||||
{
|
||||
this.Days = 5;
|
||||
|
||||
this.InitializeComponent();
|
||||
|
||||
this.InitLayout();
|
||||
}
|
||||
|
||||
private static void OnDateFromChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
(o as WeekView).SetValue(DateToProperty, ((DateTime)e.NewValue).AddDays(6));
|
||||
|
||||
for (int i = 0; i < (o as WeekView).dayList.Count; i++)
|
||||
{
|
||||
(o as WeekView).dayList[i].Date = ((DateTime)e.NewValue).AddDays(i);
|
||||
}
|
||||
|
||||
TimeSpan diff = DateTime.Today.Subtract((o as WeekView).DateFrom);
|
||||
|
||||
if (diff.TotalDays >= 0 && diff.TotalDays < 5)
|
||||
{
|
||||
(o as WeekView).SetColumnBackground(diff.Days, new SolidColorBrush(Colors.Orange));
|
||||
}
|
||||
}
|
||||
|
||||
private static void OnAppointmentsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.NewValue != null)
|
||||
{
|
||||
(e.NewValue as ObservableCollection<AppointmentModel>).CollectionChanged += (o as WeekView).OnAppointmentListChanged;
|
||||
(o as WeekView).SeperateAppointments(e.NewValue as ObservableCollection<AppointmentModel>);
|
||||
}
|
||||
|
||||
if (e.OldValue != null)
|
||||
{
|
||||
(e.OldValue as ObservableCollection<AppointmentModel>).CollectionChanged -= (o as WeekView).OnAppointmentListChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAppointmentListChanged(object s, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
for(int i = 0; i < e.NewItems.Count; i++)
|
||||
{
|
||||
this.SeperateAppointments(e.NewItems[i] as AppointmentModel);
|
||||
}
|
||||
}
|
||||
|
||||
private void SeperateAppointments(ObservableCollection<AppointmentModel> list)
|
||||
{
|
||||
foreach (AppointmentModel m in list)
|
||||
{
|
||||
this.SeperateAppointments(m);
|
||||
}
|
||||
}
|
||||
|
||||
private void SeperateAppointments(AppointmentModel model)
|
||||
{
|
||||
for(int i = 0; i < this.Days; i++)
|
||||
{
|
||||
if (model.IsDate(this.DateFrom.AddDays(i)) == 0)
|
||||
{
|
||||
this.dayList[i].Appointments.Add(model);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime DateFrom
|
||||
{
|
||||
get
|
||||
@@ -52,7 +113,19 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
set
|
||||
{
|
||||
this.SetValue(DateFromProperty, value);
|
||||
this.SetValue(DateToProperty, value.AddDays(this.Days));
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime DateTo
|
||||
{
|
||||
get
|
||||
{
|
||||
return (DateTime)this.GetValue(DateToProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.SetValue(DateToProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,11 +142,11 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
public List<AppointmentModel> Appointments
|
||||
public ObservableCollection<AppointmentModel> Appointments
|
||||
{
|
||||
get
|
||||
{
|
||||
return (List<AppointmentModel>)this.GetValue(AppointmentsProperty);
|
||||
return (ObservableCollection<AppointmentModel>)this.GetValue(AppointmentsProperty);
|
||||
}
|
||||
|
||||
set
|
||||
@@ -92,6 +165,7 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
set
|
||||
{
|
||||
this.SetValue(WeekNameProperty, value);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,6 +204,12 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
this.borderList.Add(this.ThuBorder);
|
||||
this.borderList.Add(this.FriBorder);
|
||||
|
||||
this.dayList.Add(this.MonList);
|
||||
this.dayList.Add(this.TueList);
|
||||
this.dayList.Add(this.WedList);
|
||||
this.dayList.Add(this.ThuList);
|
||||
this.dayList.Add(this.FriList);
|
||||
|
||||
this.TimeList.ItemsSource = this.timeStrings;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
x:Name="root"
|
||||
>
|
||||
|
||||
<Grid x:Name="TheGrid">
|
||||
@@ -16,12 +17,16 @@
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Canvas x:Name="MainCanvas" Grid.Row="0" Grid.Column="0">
|
||||
|
||||
<Canvas
|
||||
x:Name="MainCanvas"
|
||||
Grid.Row="0"
|
||||
Grid.Column="0"
|
||||
>
|
||||
<Canvas
|
||||
x:Name="BGCanvas"
|
||||
Canvas.ZIndex="1"
|
||||
Height="{Binding Path=ActualHeight, ElementName=MainCanvas, Mode=OneWay}"
|
||||
Height="{Binding Path=ActualHeight, ElementName=MainCanvas, Mode=OneWay}"
|
||||
Width="{Binding Path=ActualWidth, ElementName=MainCanvas, Mode=OneWay}"
|
||||
/>
|
||||
<Canvas
|
||||
|
||||
@@ -10,6 +10,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
{
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Windows;
|
||||
@@ -20,21 +22,81 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
using System.Windows.Shapes;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Data;
|
||||
using CampusAppWP8.Model.TimeTable;
|
||||
|
||||
public partial class WeekViewDay : UserControl
|
||||
{
|
||||
/// <summary> The background list elements property. </summary>
|
||||
public static readonly DependencyProperty BgListElementsProperty = DependencyProperty.Register("BgListElements", typeof(int), typeof(WeekViewDay), new PropertyMetadata(null));
|
||||
/// <summary> The background list element height property. </summary>
|
||||
public static readonly DependencyProperty BgListElementHeightProperty = DependencyProperty.Register("BgListElementHeight", typeof(double), typeof(WeekViewDay), new PropertyMetadata(null));
|
||||
public static readonly DependencyProperty DateProperty = DependencyProperty.Register("Date", typeof(DateTime), typeof(WeekViewDay), new PropertyMetadata(DateTime.Today));
|
||||
public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(ObservableCollection<AppointmentModel>), typeof(WeekViewDay), new PropertyMetadata(null, OnAppointmentsChanged));
|
||||
|
||||
private List<List<AppointmentModel>> stacks = new List<List<AppointmentModel>>();
|
||||
|
||||
|
||||
/// <summary> Initializes a new instance of the WeekViewDay class. </summary>
|
||||
/// <remarks> Fiedler, 22.10.2013. </remarks>
|
||||
public WeekViewDay()
|
||||
{
|
||||
this.Appointments = new ObservableCollection<AppointmentModel>();
|
||||
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
private static void OnAppointmentsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if(e.NewValue != null)
|
||||
{
|
||||
(e.NewValue as ObservableCollection<AppointmentModel>).CollectionChanged += (o as WeekViewDay).OnAppointmentListChanged;
|
||||
}
|
||||
|
||||
if (e.OldValue != null)
|
||||
{
|
||||
(e.OldValue as ObservableCollection<AppointmentModel>).CollectionChanged -= (o as WeekViewDay).OnAppointmentListChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAppointmentListChanged(object s, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
if (e.Action == NotifyCollectionChangedAction.Add)
|
||||
{
|
||||
for (int i = 0; i < e.NewItems.Count; i++)
|
||||
{
|
||||
this.CheckForStack(e.NewItems[i] as AppointmentModel);
|
||||
}
|
||||
}
|
||||
else if (e.Action == NotifyCollectionChangedAction.Remove)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
public ObservableCollection<AppointmentModel> Appointments
|
||||
{
|
||||
get
|
||||
{
|
||||
return (ObservableCollection<AppointmentModel>)this.GetValue(AppointmentsProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.SetValue(AppointmentsProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime Date
|
||||
{
|
||||
get
|
||||
{
|
||||
return (DateTime)this.GetValue(DateProperty);
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
this.SetValue(DateProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the background list elements. </summary>
|
||||
/// <value> The background list elements. </value>
|
||||
public int BgListElements
|
||||
@@ -75,6 +137,55 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckForStack(AppointmentModel model)
|
||||
{
|
||||
int[] intersect = model.IntersectArray(this.Appointments.ToArray<AppointmentModel>());
|
||||
|
||||
if (intersect.Count() == 0)
|
||||
{
|
||||
this.DrawApp(model);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawApp(AppointmentModel model, int stackIndex = -1)
|
||||
{
|
||||
AppointmentCanvas newCan = new AppointmentCanvas(model, this.Date);
|
||||
|
||||
Binding widthBind = new Binding("ActualWidth");
|
||||
widthBind.ElementName = "MainCanvas";
|
||||
widthBind.Mode = BindingMode.OneWay;
|
||||
newCan.SetBinding(WidthProperty, widthBind);
|
||||
|
||||
if (stackIndex >= 0)
|
||||
{
|
||||
newCan.SetListPosition(this.stacks[stackIndex]);
|
||||
}
|
||||
|
||||
this.UserCanvas.Children.Add(newCan);
|
||||
}
|
||||
|
||||
private void UnDrawApp(AppointmentModel model)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
for (int i = 0; i < this.UserCanvas.Children.Count; i++)
|
||||
{
|
||||
if ((this.UserCanvas.Children[i] as AppointmentCanvas).Is(model))
|
||||
{
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
this.UserCanvas.Children.RemoveAt(index);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Draw lines. </summary>
|
||||
/// <remarks> Fiedler, 22.10.2013. </remarks>
|
||||
private void DrawLines()
|
||||
|
||||
Reference in New Issue
Block a user