multi appointments

This commit is contained in:
Christian Fiedler
2013-09-23 18:16:19 +02:00
parent 824bd7c8b1
commit 543247cea2
3 changed files with 143 additions and 25 deletions

View File

@@ -61,6 +61,14 @@ namespace CampusAppWP8.Model.TimeTable
return this.offsetY;
}
}
public double GetPosRight
{
get
{
return (this.canvas.Margin.Left + this.rect.Width);
}
}
public Canvas GetCanvas()
{
@@ -97,6 +105,43 @@ namespace CampusAppWP8.Model.TimeTable
return retValue;
}
public bool Intersect(AppointmentModel model)
{
bool retValue = false;
Rectangle modelRect = model.rect;
Canvas modelCanvas = model.canvas;
if ((this.canvas.Margin.Left >= modelCanvas.Margin.Left
&& this.canvas.Margin.Left <= (modelCanvas.Margin.Left + modelRect.Width)
&& this.canvas.Margin.Top >= modelCanvas.Margin.Top
&& this.canvas.Margin.Top <= (modelCanvas.Margin.Top + modelRect.Height))
|| (modelCanvas.Margin.Left >= this.canvas.Margin.Left
&& modelCanvas.Margin.Left <= (this.canvas.Margin.Left + this.rect.Width)
&& modelCanvas.Margin.Top >= this.canvas.Margin.Top
&& modelCanvas.Margin.Top <= (this.canvas.Margin.Top + this.rect.Height)))
{
retValue = true;
}
return retValue;
}
public int Intersect(AppointmentModel[] modelList)
{
int retValue = -1;
for (int i = 0; i < modelList.Length; i++)
{
if (this.Equals(modelList[i]) == false && this.Intersect(modelList[i]) == true)
{
retValue = i;
}
}
return retValue;
}
private void CalcRect()
{
this.CalcHeight();

View File

@@ -26,9 +26,10 @@ namespace CampusAppWP8.Pages.TimeTable
= 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:20130914T113500Z\r\nDTEND;VALUE=DATE-TIME:20130914T152000Z\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:20130916T110000Z\r\nDTEND:20130916T195900Z\r\nDTSTAMP:20130916T125900Z\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:20130914T170000Z\r\nDTEND:20130915T035959Z\r\nSUMMARY:Bastille Day Party\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:20130914T150000Z\r\nDTEND:20130915T035959Z\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: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")
});
public static int AutoScrollToHour = 7;

View File

@@ -23,7 +23,9 @@ namespace CampusAppWP8.Pages.TimeTable
private readonly double DAY_TABLE_CELL_HEIGHT = AppointmentModel.DAY_HOUR_SPACING;
private readonly double DAY_TABLE_HEAD_THICKNESS = 2;
private readonly double DAY_TABLE_INNER_THICKNESS = 1;
private readonly double DAY_TABLE_ZINDEX_SHIFT = 10;
private readonly int DAY_TABLE_ZINDEX_MAX = 10;
private static readonly int PIVOT_ITEM_PAGES = 5;
//private static readonly int PIVOT_ITEM_PAGES_HALF_UP = 4;
private static readonly int PIVOT_ITEM_PAGES_HALF_DOWN = 2;
@@ -33,6 +35,8 @@ namespace CampusAppWP8.Pages.TimeTable
private DateTime itemPage_0_Day = DateTime.Now.AddDays(PIVOT_ITEM_PAGES_HALF_DOWN * -1);
private int lastSelectedIndex = 0;
private List<List<AppointmentModel>>[] appointmentStackList = new List<List<AppointmentModel>>[PIVOT_ITEM_PAGES];
public TimeTableDay()
{
@@ -40,6 +44,7 @@ namespace CampusAppWP8.Pages.TimeTable
for (int i = 0; i < PIVOT_ITEM_PAGES; i++)
{
this.appointmentStackList[i] = new List<List<AppointmentModel>>();
this.itemPages[i] = new PivotItem();
this.itemDate[i] = itemPage_0_Day.AddDays(i);
this.ThePivot.Items.Add(this.itemPages[i]);
@@ -144,9 +149,12 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
private void EventOnMultiBubbleClick(int stackID)
private void EventOnMultiBubbleClick(object sender, System.Windows.Input.GestureEventArgs e)
{
double width_s_1 = (this.itemPages[this.lastSelectedIndex].Content as ScrollViewer).ActualWidth;
double width_s_2 = (this.itemPages[this.lastSelectedIndex].Content as ScrollViewer).Width;
double width_c_1 = ((this.itemPages[this.lastSelectedIndex].Content as ScrollViewer).Content as Canvas).ActualWidth;
double width_c_2 = ((this.itemPages[this.lastSelectedIndex].Content as ScrollViewer).Content as Canvas).Width;
}
private void EventAutoScroll(object sender, RoutedEventArgs e)
@@ -175,6 +183,8 @@ namespace CampusAppWP8.Pages.TimeTable
private void SetupItemPage(int index, DateTime date)
{
List<AppointmentModel> tempList = new List<AppointmentModel>();
this.itemPages[index].Header = string.Format("{0:ddd dd.MM.yy}", date);
if (this.itemPages[index].Content != null)
@@ -183,25 +193,72 @@ namespace CampusAppWP8.Pages.TimeTable
}
this.SetupItemPageBackground(this.itemPages[index]);
for (int i = 0; i < TimeTable.AppointmentsModel.Appointments.Count(); i++)
{
int appointmentIndex = -1;
if ((appointmentIndex = TimeTable.AppointmentsModel.Appointments[i].IsDate(date)) > -1)
{
TimeTable.AppointmentsModel.Appointments[i].OnClick += new AppointmentModel.OnAppointmentClick(this.EventOnAppointmentClick);
Canvas temp = TimeTable.AppointmentsModel.Appointments[i].GetCanvas();
temp.Margin = new Thickness(DAY_TABLE_HEAD_WIDTH + 2, TimeTable.AppointmentsModel.Appointments[i].GetYOffset, 0, 0);
((this.itemPages[index].Content as ScrollViewer).Content as Canvas).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);
*/
tempList.Add(TimeTable.AppointmentsModel.Appointments[i]);
}
}
// -------------------------------------------------------------
for (int i = 0; i < tempList.Count(); i++)
{
int intersectIndex = tempList[i].Intersect(tempList.ToArray());
if (intersectIndex > -1)
{
int addIndex = -1;
for(int k = 0; k < this.appointmentStackList[index].Count(); k++)
{
if (this.appointmentStackList[index][k].IndexOf(tempList[intersectIndex]) >= 0)
{
addIndex = k;
}
}
if(addIndex >= 0)
{
this.appointmentStackList[index][addIndex].Add(tempList[i]);
}
else
{
List<AppointmentModel> newList = new List<AppointmentModel>();
newList.Add(tempList[i]);
this.appointmentStackList[index].Add(newList);
}
}
else
{
this.DrawAppointmentModel(tempList[i], index);
}
}
for (int i = 0; i < this.appointmentStackList[index].Count(); i++)
{
for (int k = 0; k < this.appointmentStackList[index][i].Count(); k++)
{
if (k > 0)
{
this.DrawAppointmentModel(this.appointmentStackList[index][i][k], index, 0.5, k);
}
else
{
this.DrawAppointmentModel(this.appointmentStackList[index][i][k], index);
}
}
/*
this.DrawMultiBubble(
((this.itemPages[index].Content as ScrollViewer).Content as Canvas),
index,
this.appointmentStackList[index][i].Count(),
this.appointmentStackList[index][i][0].GetPosRight,
this.appointmentStackList[index][i][0].GetYOffset);
*/
}
}
private void SetupItemPageBackground(PivotItem item)
@@ -215,31 +272,46 @@ namespace CampusAppWP8.Pages.TimeTable
item.Content = sv;
}
private void DrawMultiBubble(Canvas dayView, int stackIndex, int number, int yOffset)
private void DrawAppointmentModel(AppointmentModel model, int index, double opacity = 1.0, int zIndex = 0)
{
model.OnClick += new AppointmentModel.OnAppointmentClick(this.EventOnAppointmentClick);
Canvas temp = model.GetCanvas();
temp.Opacity = opacity;
temp.SetValue(Canvas.ZIndexProperty, DAY_TABLE_ZINDEX_MAX - zIndex);
temp.Margin = new Thickness(DAY_TABLE_HEAD_WIDTH + 2 + (zIndex * DAY_TABLE_ZINDEX_SHIFT), model.GetYOffset, 0, 0);
((this.itemPages[index].Content as ScrollViewer).Content as Canvas).Children.Add(temp);
}
private void DrawMultiBubble(Canvas dayView, int stackIndex, int number, double xOffset, double yOffset)
{
Canvas can = new Canvas();
Rectangle rect = new Rectangle();
rect.Width = 50;
rect.Height = 50;
rect.RadiusX = 25;
rect.RadiusY = 25;
rect.Width = DAY_TABLE_CELL_HEIGHT / 2;
rect.Height = DAY_TABLE_CELL_HEIGHT / 2;
rect.RadiusX = DAY_TABLE_CELL_HEIGHT / 4;
rect.RadiusY = DAY_TABLE_CELL_HEIGHT / 4;
rect.StrokeThickness = 1;
rect.Stroke = new SolidColorBrush(Colors.DarkGray);
rect.Fill = new SolidColorBrush(Colors.Blue);
TextBlock block = new TextBlock();
block.Height = DAY_TABLE_CELL_HEIGHT / 2;
block.Width = DAY_TABLE_CELL_HEIGHT / 2;
block.Text = "" + number;
block.HorizontalAlignment = HorizontalAlignment.Center;
block.VerticalAlignment = VerticalAlignment.Center;
block.Height = 50;
block.Width = 50;
block.FontWeight = FontWeights.Bold;
block.FontSize = DAY_TABLE_CELL_HEIGHT / 3;
block.Padding = new Thickness(DAY_TABLE_CELL_HEIGHT / 6.5, 0, 0, 0);
can.Children.Add(rect);
can.Children.Add(block);
// can.
// .DoubleTap += new EventHandler<System.Windows.Input.GestureEventArgs>(this.OnCanvasClick);
can.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(this.EventOnMultiBubbleClick);
can.Tag = stackIndex;
can.SetValue(Canvas.LeftProperty, xOffset - rect.Width);
can.SetValue(Canvas.TopProperty, yOffset);
can.SetValue(Canvas.ZIndexProperty, DAY_TABLE_ZINDEX_MAX + 1);
dayView.Children.Add(can);
}