week view finished & canvas creations
This commit is contained in:
@@ -25,8 +25,6 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
[XmlRoot("root")]
|
||||
public class AppointmentModel
|
||||
{
|
||||
private static double DAY_HOUR_SPACING = 50;
|
||||
|
||||
/// <summary>The Visual object.</summary>
|
||||
//private Rectangle rect = null;
|
||||
//private Canvas canvas = null;
|
||||
@@ -155,126 +153,92 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
public Canvas GetCanvas(double width, double hourSpacing, DateTime date)
|
||||
{
|
||||
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.Width = width;
|
||||
retValue.Margin = new Thickness(0, (hourSpacing * this.Start.TimeOfDay.TotalHours), 0, 0);
|
||||
}
|
||||
|
||||
retValue.Width = width;
|
||||
|
||||
this.CreateRect(retValue);
|
||||
this.CreateContent(retValue, hourSpacing);
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/*
|
||||
private void CalcRect()
|
||||
private void CreateRect(Canvas can)
|
||||
{
|
||||
this.canvas.Children.Clear();
|
||||
// can.Children.Clear();
|
||||
|
||||
this.rect.Width = this.width;
|
||||
this.rect.Height = this.height;
|
||||
Rectangle rect = new Rectangle();
|
||||
rect.Width = can.Width;
|
||||
rect.Height = can.Height;
|
||||
|
||||
this.rect.StrokeThickness = 1;
|
||||
this.rect.Stroke = new SolidColorBrush(Colors.DarkGray);
|
||||
this.rect.Fill = new SolidColorBrush(Colors.Green);
|
||||
this.rect.RadiusX = 10;
|
||||
this.rect.RadiusY = 10;
|
||||
rect.StrokeThickness = 1;
|
||||
rect.Stroke = new SolidColorBrush(Colors.DarkGray);
|
||||
rect.Fill = new SolidColorBrush(Colors.Green);
|
||||
rect.RadiusX = 5;
|
||||
rect.RadiusY = 5;
|
||||
|
||||
this.canvas.Children.Add(this.rect);
|
||||
|
||||
can.Children.Add(rect);
|
||||
}
|
||||
|
||||
private void CreateContent(Canvas can, double hourSpacing)
|
||||
{
|
||||
if (this.icalObj != null)
|
||||
{
|
||||
ICalObject eventObj = this.GetVEventObj();
|
||||
Summary title = eventObj.GetProperty(ICSTag.SUMMARY) as Summary;
|
||||
|
||||
TextBlock txtTitle = new TextBlock();
|
||||
txtTitle.Text = title.Value;
|
||||
txtTitle.FontSize = DAY_HOUR_SPACING / 3;
|
||||
txtTitle.FontSize = hourSpacing / 3;
|
||||
txtTitle.FontWeight = FontWeights.Bold;
|
||||
txtTitle.TextWrapping = TextWrapping.Wrap;
|
||||
txtTitle.Width = this.rect.Width - 4.0;
|
||||
txtTitle.SetValue(Canvas.LeftProperty, 5.0);
|
||||
txtTitle.SetValue(Canvas.TopProperty, 5.0);
|
||||
txtTitle.Width = can.Width - 4.0;
|
||||
txtTitle.SetValue(Canvas.LeftProperty, 3.0);
|
||||
txtTitle.SetValue(Canvas.TopProperty, 3.0);
|
||||
|
||||
this.canvas.Children.Add(txtTitle);
|
||||
//this.canvas.Children.Add(txtDesc);
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
private void CalcYOffset()
|
||||
{
|
||||
ICalObject eventObj = this.GetVEventObj();
|
||||
|
||||
DTStart startTimeObj = eventObj.GetProperty(ICSTag.DT_START) as DTStart;
|
||||
|
||||
if (startTimeObj == null)
|
||||
{
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
|
||||
DateTime startTimeValue = startTimeObj.Value;
|
||||
|
||||
this.offsetY = (startTimeValue.Hour * AppointmentModel.DAY_HOUR_SPACING) + (startTimeValue.Minute / 60.0 * AppointmentModel.DAY_HOUR_SPACING);
|
||||
}
|
||||
*/
|
||||
/*
|
||||
private void CalcHeight()
|
||||
{
|
||||
ICalObject eventObj = this.GetVEventObj();
|
||||
|
||||
DTStart startTimeObj = eventObj.GetProperty(ICSTag.DT_START) as DTStart;
|
||||
DTEnd endTimeObj = eventObj.GetProperty(ICSTag.DT_END) as DTEnd;
|
||||
CampusAppWP8.Utility.ICSProperties.Duration durObj = eventObj.GetProperty(ICSTag.DURATION) as CampusAppWP8.Utility.ICSProperties.Duration;
|
||||
|
||||
if (startTimeObj == null
|
||||
|| (endTimeObj == null && durObj == null))
|
||||
{
|
||||
throw new NullReferenceException();
|
||||
}
|
||||
|
||||
if (endTimeObj != null)
|
||||
{
|
||||
DateTime startTimeValue = startTimeObj.Value;
|
||||
DateTime endTimeValue = endTimeObj.Value;
|
||||
|
||||
TimeSpan span = endTimeValue.Subtract(startTimeValue);
|
||||
|
||||
this.height = span.TotalHours * AppointmentModel.DAY_HOUR_SPACING;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.height = durObj.Value.TotalHours * AppointmentModel.DAY_HOUR_SPACING;
|
||||
}
|
||||
|
||||
if (this.height < (AppointmentModel.DAY_HOUR_SPACING / 4))
|
||||
{
|
||||
this.height = AppointmentModel.DAY_HOUR_SPACING / 4;
|
||||
}
|
||||
}
|
||||
*/
|
||||
/*
|
||||
public void SetWidth(double newWidth)
|
||||
{
|
||||
if (this.width != newWidth)
|
||||
{
|
||||
this.width = newWidth;
|
||||
|
||||
if (this.width < 10)
|
||||
if (can.Height >= ((hourSpacing / 2)))
|
||||
{
|
||||
this.width = 10;
|
||||
txtTitle.Margin = new Thickness(0, -2, 0, 0);
|
||||
txtTitle.Text = title.Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtTitle.Height = can.Height;
|
||||
txtTitle.VerticalAlignment = VerticalAlignment.Center;
|
||||
txtTitle.Margin = new Thickness(0, -10, 0, 0);
|
||||
txtTitle.Text = "...";
|
||||
}
|
||||
|
||||
this.CalcRect();
|
||||
can.Children.Add(txtTitle);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
private ICalObject GetVEventObj(bool create = false)
|
||||
{
|
||||
ICalObject retValue = this.icalObj.GetProperty(ICSTag.VEVENT) as ICalObject;
|
||||
@@ -298,7 +262,7 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/*
|
||||
private void OnCanvasClick(object sender, EventArgs e)
|
||||
{
|
||||
if (this.OnClick != null)
|
||||
@@ -309,9 +273,9 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
|
||||
private void OnCanvasSizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
//this.CalcRect();
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
// ------------------------------------------------------
|
||||
public string Title
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
FontFamily="{StaticResource PhoneFontFamilyNormal}"
|
||||
FontSize="{StaticResource PhoneFontSizeNormal}"
|
||||
Foreground="{StaticResource PhoneForegroundBrush}"
|
||||
SupportedOrientations="Portrait" Orientation="Portrait"
|
||||
SupportedOrientations="PortraitOrLandscape" Orientation="Portrait"
|
||||
mc:Ignorable="d"
|
||||
shell:SystemTray.IsVisible="True">
|
||||
|
||||
|
||||
@@ -227,8 +227,6 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
newItem.Calc();
|
||||
|
||||
if (this.appointmentIndex >= 0)
|
||||
{
|
||||
TimeTable.AppointmentsModel.Appointments.RemoveAt(this.appointmentIndex);
|
||||
|
||||
@@ -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:20130930T113500Z\r\nDTEND;VALUE=DATE-TIME:20130930T152000Z\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:20131002T195900Z\r\nDTSTAMP:20131002T125900Z\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: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: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")
|
||||
|
||||
@@ -32,34 +32,41 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
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;
|
||||
|
||||
private PivotItem[] itemPages = new PivotItem[PIVOT_ITEM_PAGES];
|
||||
private DateTime[] itemDate = new DateTime[PIVOT_ITEM_PAGES];
|
||||
private DateTime itemPage_0_Day = DateTime.Now.AddDays(PIVOT_ITEM_PAGES_HALF_DOWN * -1);
|
||||
private struct PageItem
|
||||
{
|
||||
public Canvas Content { get; set; }
|
||||
public DateTime Date { get; set; }
|
||||
public List<List<AppointmentModel>> Stacks { get; set; }
|
||||
}
|
||||
|
||||
private PageItem[] itemPages = new PageItem[PIVOT_ITEM_PAGES];
|
||||
|
||||
private int lastSelectedIndex = 0;
|
||||
private List<List<AppointmentModel>>[] appointmentStackList = new List<List<AppointmentModel>>[PIVOT_ITEM_PAGES];
|
||||
|
||||
public TimeTableDay()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
AppointmentModel.HourSpacing = DAY_TABLE_CELL_HEIGHT;
|
||||
|
||||
DateTime firstDay = DateTime.Now.Date.AddDays(PIVOT_ITEM_PAGES_HALF_DOWN * -1);
|
||||
|
||||
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]);
|
||||
this.itemPages[i].Stacks = new List<List<AppointmentModel>>();
|
||||
this.CreatePage(i, firstDay.AddDays(i));
|
||||
}
|
||||
|
||||
this.ThePivot.SelectedIndex = PIVOT_ITEM_PAGES_HALF_DOWN;
|
||||
this.lastSelectedIndex = this.ThePivot.SelectedIndex;
|
||||
this.ThePivot.SelectionChanged += new SelectionChangedEventHandler(this.EventPivotSelectionChanged);
|
||||
|
||||
ApplicationBarIconButton weekBtn = new ApplicationBarIconButton();
|
||||
weekBtn.IconUri = new Uri(Icons.Link, UriKind.Relative);
|
||||
weekBtn.Text = AppResources.WeekView;
|
||||
weekBtn.Click += new EventHandler(this.OnClickWeek);
|
||||
ApplicationBar.Buttons.Add(weekBtn);
|
||||
|
||||
ApplicationBarIconButton editBtn = new ApplicationBarIconButton();
|
||||
editBtn.IconUri = new Uri(Icons.Link, UriKind.Relative);
|
||||
editBtn.Text = AppResources.ToDay;
|
||||
@@ -89,14 +96,8 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
else
|
||||
{
|
||||
double maxW = Application.Current.Host.Content.ActualWidth;
|
||||
|
||||
maxW -= (DAY_TABLE_HEAD_WIDTH + 6.0);
|
||||
|
||||
for(int i = 0; i < PIVOT_ITEM_PAGES; i++)
|
||||
{
|
||||
this.SetupItemPage(i, this.itemDate[i]);
|
||||
}
|
||||
this.lastSelectedIndex = PIVOT_ITEM_PAGES_HALF_DOWN;
|
||||
this.ThePivot.SelectedIndex = PIVOT_ITEM_PAGES_HALF_DOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,31 +115,28 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
int delta = this.ThePivot.SelectedIndex - this.lastSelectedIndex;
|
||||
|
||||
if ((this.ThePivot.SelectedIndex == 0) && (this.lastSelectedIndex == (PIVOT_ITEM_PAGES - 1)))
|
||||
{
|
||||
delta = 1;
|
||||
}
|
||||
else if ((this.ThePivot.SelectedIndex == (PIVOT_ITEM_PAGES - 1)) && (this.lastSelectedIndex == 0))
|
||||
{
|
||||
delta = -1;
|
||||
}
|
||||
|
||||
if (Math.Abs(delta) > 1)
|
||||
{
|
||||
delta = (delta < 0) ? -1 : 1;
|
||||
}
|
||||
if(delta < -1) delta = 1;
|
||||
else if(delta > 1) delta = -1;
|
||||
|
||||
indexToChange = (this.ThePivot.SelectedIndex + PIVOT_ITEM_PAGES + (PIVOT_ITEM_PAGES_HALF_DOWN * delta)) % PIVOT_ITEM_PAGES;
|
||||
|
||||
this.itemDate[indexToChange] = this.itemDate[this.ThePivot.SelectedIndex].AddDays(delta * PIVOT_ITEM_PAGES_HALF_DOWN);
|
||||
this.SetupItemPage(indexToChange, this.itemDate[indexToChange]);
|
||||
|
||||
|
||||
if (delta == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.itemPages[indexToChange].Date = this.itemPages[this.ThePivot.SelectedIndex].Date.AddDays(delta * PIVOT_ITEM_PAGES_HALF_DOWN);
|
||||
}
|
||||
|
||||
this.SetupPage(indexToChange);
|
||||
|
||||
this.lastSelectedIndex = this.ThePivot.SelectedIndex;
|
||||
}
|
||||
|
||||
private void EventOnAppointmentClick(AppointmentModel sender)
|
||||
private void OnAppointmentClick(object sender, System.Windows.Input.GestureEventArgs e)
|
||||
{
|
||||
int index = TimeTable.AppointmentsModel.Appointments.IndexOf(sender);
|
||||
int index = TimeTable.AppointmentsModel.Appointments.IndexOf((sender as Canvas).Tag as AppointmentModel);
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
@@ -155,34 +153,37 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
private void EventOnMultiBubbleClick(object sender, System.Windows.Input.GestureEventArgs e)
|
||||
{
|
||||
int indexVal = (int)(sender as Canvas).Tag;
|
||||
int stackIndex = indexVal >> 12;
|
||||
int index = indexVal >> 12;
|
||||
int listIndex = indexVal & 0x00000FFF;
|
||||
|
||||
AppointmentModel tempModel = this.appointmentStackList[stackIndex][listIndex].First();
|
||||
this.appointmentStackList[stackIndex][listIndex].Remove(tempModel);
|
||||
this.appointmentStackList[stackIndex][listIndex].Add(tempModel);
|
||||
AppointmentModel tempModelCan = this.itemPages[index].Stacks[listIndex].First();
|
||||
this.itemPages[index].Stacks[listIndex].Remove(tempModelCan);
|
||||
this.itemPages[index].Stacks[listIndex].Add(tempModelCan);
|
||||
|
||||
for (int i = 0; i < this.appointmentStackList[stackIndex][listIndex].Count(); i++)
|
||||
for (int i = 0; i < this.itemPages[index].Stacks[listIndex].Count(); i++)
|
||||
{
|
||||
this.RemoveContentUIElement(stackIndex, this.appointmentStackList[stackIndex][listIndex][i].Canvas);
|
||||
this.RemoveContentUIElement(index, this.itemPages[index].Stacks[listIndex][i]);
|
||||
|
||||
if (i > 0)
|
||||
{
|
||||
this.DrawAppointmentModel(this.appointmentStackList[stackIndex][listIndex][i], stackIndex, 0.5, i, this.appointmentStackList[stackIndex][listIndex].Count() - 1 - i);
|
||||
this.DrawAppointmentModel(this.itemPages[index].Stacks[listIndex][i], index, 0.5, i, this.itemPages[index].Stacks[listIndex].Count() - 1 - i);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DrawAppointmentModel(this.appointmentStackList[stackIndex][listIndex][i], stackIndex, 1.0, i, this.appointmentStackList[stackIndex][listIndex].Count() - 1 - i);
|
||||
this.DrawAppointmentModel(this.itemPages[index].Stacks[listIndex][i], index, 1.0, i, this.itemPages[index].Stacks[listIndex].Count() - 1 - i);
|
||||
}
|
||||
}
|
||||
|
||||
this.RemoveContentUIElement(stackIndex, sender as Canvas);
|
||||
this.RemoveContentUIElement(index, sender as Canvas);
|
||||
|
||||
Canvas tempCan = this.GetModelCanvasFromContent(index, this.itemPages[index].Stacks[listIndex][0]);
|
||||
|
||||
this.DrawMultiBubble(
|
||||
stackIndex,
|
||||
index,
|
||||
listIndex,
|
||||
this.appointmentStackList[stackIndex][listIndex].Count(),
|
||||
this.appointmentStackList[stackIndex][listIndex][0].GetPosRight,
|
||||
this.appointmentStackList[stackIndex][listIndex][0].GetYOffset);
|
||||
this.itemPages[index].Stacks[listIndex].Count(),
|
||||
tempCan.Width + tempCan.Margin.Left,
|
||||
tempCan.Margin.Top);
|
||||
}
|
||||
|
||||
private void EventAutoScroll(object sender, RoutedEventArgs e)
|
||||
@@ -193,15 +194,23 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickWeek(object sender, EventArgs e)
|
||||
{
|
||||
Uri url = new Uri("/Pages/TimeTable/TimeTableWeek.xaml", UriKind.Relative);
|
||||
Page page = App.RootFrame.Content as Page;
|
||||
page.NavigationService.Navigate(url);
|
||||
}
|
||||
|
||||
private void OnClickToDay(object sender, EventArgs e)
|
||||
{
|
||||
this.itemPage_0_Day = DateTime.Now.AddDays(PIVOT_ITEM_PAGES_HALF_DOWN * -1);
|
||||
DateTime firstDay = DateTime.Now.Date.AddDays(PIVOT_ITEM_PAGES_HALF_DOWN * -1);
|
||||
this.ThePivot.SelectedIndex = PIVOT_ITEM_PAGES_HALF_DOWN;
|
||||
|
||||
for (int i = 0; i < PIVOT_ITEM_PAGES; i++)
|
||||
{
|
||||
this.itemDate[i] = this.itemPage_0_Day.AddDays(i);
|
||||
this.SetupItemPage(i, this.itemDate[i]);
|
||||
this.itemPages[i].Date = firstDay.AddDays(i);
|
||||
|
||||
this.SetupPage(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,9 +247,9 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
{
|
||||
for (int i = 0; i < PIVOT_ITEM_PAGES; i++)
|
||||
{
|
||||
if (tempModel.IsDate(this.itemDate[i]) > -1)
|
||||
if (tempModel.IsDate(this.itemPages[i].Date.Date) > -1)
|
||||
{
|
||||
this.SetupItemPage(i, this.itemDate[i]);
|
||||
this.SetupPage(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -248,29 +257,60 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
private void AddContentUIElement(int index, UIElement elem)
|
||||
{
|
||||
(((this.itemPages[index].Content as ScrollViewer).Content as Canvas).Children[1] as Canvas).Children.Add(elem);
|
||||
this.itemPages[index].Content.Children.Add(elem);
|
||||
}
|
||||
|
||||
private void RemoveContentUIElement(int index, UIElement elem)
|
||||
{
|
||||
(((this.itemPages[index].Content as ScrollViewer).Content as Canvas).Children[1] as Canvas).Children.Remove(elem);
|
||||
this.itemPages[index].Content.Children.Remove(elem);
|
||||
}
|
||||
|
||||
private void SetupItemPage(int index, DateTime date)
|
||||
private void RemoveContentUIElement(int index, AppointmentModel model)
|
||||
{
|
||||
Canvas tempCan = this.GetModelCanvasFromContent(index, model);
|
||||
|
||||
if (tempCan != null)
|
||||
{
|
||||
this.RemoveContentUIElement(index, tempCan);
|
||||
}
|
||||
}
|
||||
|
||||
private Canvas GetModelCanvasFromContent(int index, AppointmentModel model)
|
||||
{
|
||||
Canvas retValue = null;
|
||||
|
||||
foreach (Canvas tempCan in this.itemPages[index].Content.Children)
|
||||
{
|
||||
if (tempCan.Tag.GetType().Equals(typeof(AppointmentModel)))
|
||||
{
|
||||
if ((tempCan.Tag as AppointmentModel).Equals(model))
|
||||
{
|
||||
retValue = tempCan;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return retValue;
|
||||
}
|
||||
|
||||
private void SetupPage(int index)
|
||||
{
|
||||
// Header
|
||||
|
||||
(this.ThePivot.Items[index] as PivotItem).Header = string.Format("{0:ddd dd.MM.yy}", this.itemPages[index].Date);
|
||||
|
||||
// Items
|
||||
|
||||
List<AppointmentModel> tempList = new List<AppointmentModel>();
|
||||
|
||||
this.appointmentStackList[index].Clear();
|
||||
|
||||
this.itemPages[index].Header = string.Format("{0:ddd dd.MM.yy}", date);
|
||||
this.itemPages[index].Stacks.Clear();
|
||||
this.itemPages[index].Content.Children.Clear();
|
||||
|
||||
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)
|
||||
if ((appointmentIndex = TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemPages[index].Date)) > -1)
|
||||
{
|
||||
tempList.Add(TimeTable.AppointmentsModel.Appointments[i]);
|
||||
}
|
||||
@@ -288,9 +328,9 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
{
|
||||
int addIndex = -1;
|
||||
|
||||
for (int k = 0; k < this.appointmentStackList[index].Count(); k++)
|
||||
for (int k = 0; k < this.itemPages[index].Stacks.Count(); k++)
|
||||
{
|
||||
if (this.appointmentStackList[index][k].IndexOf(tempList[intersectIndex[0]]) >= 0)
|
||||
if(this.itemPages[index].Stacks[k].IndexOf(tempList[intersectIndex[0]]) > -1)
|
||||
{
|
||||
addIndex = k;
|
||||
}
|
||||
@@ -298,13 +338,13 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
if (addIndex >= 0)
|
||||
{
|
||||
this.appointmentStackList[index][addIndex].Add(tempList[i]);
|
||||
this.itemPages[index].Stacks[addIndex].Add(tempList[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<AppointmentModel> newList = new List<AppointmentModel>();
|
||||
newList.Add(tempList[i]);
|
||||
this.appointmentStackList[index].Add(newList);
|
||||
this.itemPages[index].Stacks.Add(newList);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -313,13 +353,13 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
for (int k = 0; k < intersectIndex.Count(); k++)
|
||||
{
|
||||
for (int m = 0; m < this.appointmentStackList[index].Count(); m++)
|
||||
for (int m = 0; m < this.itemPages[index].Stacks.Count(); m++)
|
||||
{
|
||||
if (this.appointmentStackList[index][m].IndexOf(tempList[intersectIndex[k]]) > -1)
|
||||
if (this.itemPages[index].Stacks[m].IndexOf(tempList[intersectIndex[k]]) > -1)
|
||||
{
|
||||
if(intersectLists.IndexOf(this.appointmentStackList[index][m]) < 0)
|
||||
if(intersectLists.IndexOf(this.itemPages[index].Stacks[m]) < 0)
|
||||
{
|
||||
intersectLists.Add(this.appointmentStackList[index][m]);
|
||||
intersectLists.Add(this.itemPages[index].Stacks[m]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -329,7 +369,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
{
|
||||
List<AppointmentModel> newList = new List<AppointmentModel>();
|
||||
newList.Add(tempList[i]);
|
||||
this.appointmentStackList[index].Add(newList);
|
||||
this.itemPages[index].Stacks.Add(newList);
|
||||
}
|
||||
else if(intersectLists.Count() == 1)
|
||||
{
|
||||
@@ -340,7 +380,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
for(int k = 1; k < intersectLists.Count(); k++)
|
||||
{
|
||||
intersectLists[0].AddRange(intersectLists[k].ToArray());
|
||||
this.appointmentStackList[index].Remove(intersectLists[k]);
|
||||
this.itemPages[index].Stacks.Remove(intersectLists[k]);
|
||||
}
|
||||
|
||||
intersectLists[0].Add(tempList[i]);
|
||||
@@ -348,81 +388,101 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < this.appointmentStackList[index].Count(); i++)
|
||||
for (int i = 0; i < this.itemPages[index].Stacks.Count(); i++)
|
||||
{
|
||||
for (int k = 0; k < this.appointmentStackList[index][i].Count(); k++)
|
||||
for (int k = 0; k < this.itemPages[index].Stacks[i].Count(); k++)
|
||||
{
|
||||
if (k > 0)
|
||||
{
|
||||
this.DrawAppointmentModel(this.appointmentStackList[index][i][k], index, 0.5, k, this.appointmentStackList[index][i].Count() - 1 - k);
|
||||
this.DrawAppointmentModel(this.itemPages[index].Stacks[i][k], index, 0.5, k, this.itemPages[index].Stacks[i].Count() - 1 - k);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DrawAppointmentModel(this.appointmentStackList[index][i][k], index, 1.0, k, this.appointmentStackList[index][i].Count() - 1 - k);
|
||||
this.DrawAppointmentModel(this.itemPages[index].Stacks[i][k], index, 1.0, k, this.itemPages[index].Stacks[i].Count() - 1 - k);
|
||||
}
|
||||
}
|
||||
|
||||
Canvas tempCan = this.GetModelCanvasFromContent(index, this.itemPages[index].Stacks[i][0]);
|
||||
|
||||
this.DrawMultiBubble(
|
||||
index,
|
||||
i,
|
||||
this.appointmentStackList[index][i].Count(),
|
||||
this.appointmentStackList[index][i][0].GetPosRight,
|
||||
this.appointmentStackList[index][i][0].GetYOffset);
|
||||
index,
|
||||
i,
|
||||
this.itemPages[index].Stacks[i].Count(),
|
||||
tempCan.Width + tempCan.Margin.Left,
|
||||
tempCan.Margin.Top);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetupItemPageBackground(PivotItem item)
|
||||
private void OnCanvasSizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
ScrollViewer sv = null;
|
||||
Canvas caContainer = null;
|
||||
Canvas caContent = null;
|
||||
Canvas caBackground = null;
|
||||
|
||||
if ((item.Content != null) && (item.Content.GetType().Equals(typeof(ScrollViewer)) == true)
|
||||
&& ((item.Content as ScrollViewer).Content != null) && ((item.Content as ScrollViewer).Content.GetType().Equals(typeof(Canvas)) == true))
|
||||
if (e.NewSize.Width.Equals(e.PreviousSize.Width) == false)
|
||||
{
|
||||
sv = item.Content as ScrollViewer;
|
||||
caContainer = sv.Content as Canvas;
|
||||
sv.ScrollToVerticalOffset(0);
|
||||
caContent = caContainer.Children[1] as Canvas;
|
||||
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;
|
||||
|
||||
caContent.Children.Clear();
|
||||
this.EventAutoScroll(sv, null);
|
||||
PivotItem pvItem = ((tempContainer.Parent as ScrollViewer).Parent as PivotItem);
|
||||
int index = this.ThePivot.Items.IndexOf(pvItem);
|
||||
|
||||
this.DrawBackground(tempBG);
|
||||
|
||||
this.SetupPage(index);
|
||||
}
|
||||
else
|
||||
{
|
||||
sv = new ScrollViewer();
|
||||
caContainer = new Canvas();
|
||||
caContainer.Height = DAY_TABLE_CELL_HEIGHT * 24;
|
||||
caContainer.Tag = "caContainer";
|
||||
caContent = new Canvas();
|
||||
caContent.Tag = "caContent";
|
||||
caBackground = new Canvas();
|
||||
caBackground.Tag = "caBackground";
|
||||
}
|
||||
|
||||
this.DrawDayViewBackground(caBackground);
|
||||
private void CreatePage(int index, DateTime date)
|
||||
{
|
||||
this.itemPages[index].Content = new Canvas();
|
||||
this.itemPages[index].Content.Height = DAY_TABLE_CELL_HEIGHT * 24;
|
||||
this.itemPages[index].Date = date;
|
||||
|
||||
caContainer.Children.Add(caBackground);
|
||||
caContainer.Children.Add(caContent);
|
||||
sv.Content = caContainer;
|
||||
sv.Loaded += new RoutedEventHandler(this.EventAutoScroll);
|
||||
item.Content = sv;
|
||||
}
|
||||
ScrollViewer sv = new ScrollViewer();
|
||||
sv.Loaded += new RoutedEventHandler(this.EventAutoScroll);
|
||||
Canvas container = new Canvas();
|
||||
container.Height = DAY_TABLE_CELL_HEIGHT * 24;
|
||||
Canvas canBG = new Canvas();
|
||||
canBG.Height = DAY_TABLE_CELL_HEIGHT * 24;
|
||||
PivotItem pvItem = new PivotItem();
|
||||
|
||||
container.Children.Add(canBG);
|
||||
container.Children.Add(this.itemPages[index].Content);
|
||||
container.SizeChanged += new SizeChangedEventHandler(this.OnCanvasSizeChanged);
|
||||
sv.Content = container;
|
||||
pvItem.Content = sv;
|
||||
|
||||
this.ThePivot.Items.Add(pvItem);
|
||||
}
|
||||
|
||||
private void DrawAppointmentCanvas(Canvas modelCan, int index, double opacity = 1.0, int zIndex = 0, int modelCount = 0)
|
||||
{
|
||||
modelCan.Opacity = opacity;
|
||||
modelCan.SetValue(Canvas.ZIndexProperty, DAY_TABLE_ZINDEX_MAX - zIndex);
|
||||
modelCan.Margin = new Thickness(
|
||||
(DAY_TABLE_HEAD_WIDTH + 2 + (zIndex * DAY_TABLE_ZINDEX_SHIFT)),
|
||||
modelCan.Margin.Top,
|
||||
0,
|
||||
0);
|
||||
this.AddContentUIElement(index, modelCan);
|
||||
}
|
||||
|
||||
private void DrawAppointmentModel(AppointmentModel model, int index, double opacity = 1.0, int zIndex = 0, int modelCount = 0)
|
||||
{
|
||||
model.OnClick += new AppointmentModel.OnAppointmentClick(this.EventOnAppointmentClick);
|
||||
model.Canvas.Opacity = opacity;
|
||||
model.Canvas.SetValue(Canvas.ZIndexProperty, DAY_TABLE_ZINDEX_MAX - zIndex);
|
||||
model.Canvas.Margin = new Thickness(DAY_TABLE_HEAD_WIDTH + 2 + (zIndex * DAY_TABLE_ZINDEX_SHIFT), model.GetYOffset, 0, 0);
|
||||
model.SetWidth(this.itemPages[index].ActualWidth - (modelCount * DAY_TABLE_ZINDEX_SHIFT) - 6.0);
|
||||
this.AddContentUIElement(index, model.Canvas);
|
||||
Canvas modelCan = model.GetCanvas(
|
||||
((this.itemPages[index].Content.Width - DAY_TABLE_HEAD_WIDTH) - 2 - 2 - (modelCount * DAY_TABLE_ZINDEX_SHIFT)),
|
||||
DAY_TABLE_CELL_HEIGHT,
|
||||
this.itemPages[index].Date.Date);
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
Canvas can = new Canvas();
|
||||
|
||||
Rectangle rect = new Rectangle();
|
||||
@@ -455,10 +515,8 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
this.AddContentUIElement(stackIndex, can);
|
||||
}
|
||||
|
||||
private void DrawDayViewBackground(Canvas dayView)
|
||||
private void DrawBackground(Canvas dayView)
|
||||
{
|
||||
dayView.Height = DAY_TABLE_CELL_HEIGHT * 24;
|
||||
|
||||
Line vertLine = new Line();
|
||||
vertLine.X1 = 0;
|
||||
vertLine.Y1 = 0;
|
||||
@@ -520,7 +578,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
TextBlock timeStamp = new TextBlock();
|
||||
timeStamp.Text = i.ToString("00") + ":00";
|
||||
timeStamp.Margin = new Thickness(0, (DAY_TABLE_CELL_HEIGHT * i) + 2, 0, 0);
|
||||
timeStamp.FontSize = 16;
|
||||
timeStamp.FontSize = DAY_TABLE_CELL_HEIGHT / 4;
|
||||
|
||||
dayView.Children.Add(timeStamp);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,9 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
private static readonly double WEEK_TABLE_INNER_THICKNESS = 1;
|
||||
private static readonly int WEEK_TABLE_ZINDEX_MAX = 10;
|
||||
private static readonly double WEEK_TABLE_ZINDEX_SHIFT = 3;
|
||||
|
||||
|
||||
//private static readonly int WEEK_DAYS_IN_WEEK = 5;
|
||||
|
||||
private struct PageItem
|
||||
{
|
||||
public Canvas Content { get; set; }
|
||||
@@ -38,6 +40,7 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
public DateTime DateTo { get; set; }
|
||||
public char WeekChar { get; set; }
|
||||
public int WeekNumber { get; set; }
|
||||
public List<List<AppointmentModel>>[] Stacks { get; set; }
|
||||
}
|
||||
|
||||
private static readonly int PIVOT_PAGES = 3;
|
||||
@@ -56,10 +59,20 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
for (int i = 0; i < PIVOT_PAGES; i++)
|
||||
{
|
||||
this.itemPages[i].Stacks = new List<List<AppointmentModel>>[5]
|
||||
{
|
||||
new List<List<AppointmentModel>>(),
|
||||
new List<List<AppointmentModel>>(),
|
||||
new List<List<AppointmentModel>>(),
|
||||
new List<List<AppointmentModel>>(),
|
||||
new List<List<AppointmentModel>>()
|
||||
};
|
||||
|
||||
this.CreatePage(i, firstDay);
|
||||
firstDay = firstDay.AddDays(7);
|
||||
}
|
||||
|
||||
this.ThePivot.SelectionChanged += new SelectionChangedEventHandler(this.OnPivotSelectionChanged);
|
||||
|
||||
ApplicationBarIconButton dayViewBtn = new ApplicationBarIconButton();
|
||||
dayViewBtn.Text = AppResources.DayView;
|
||||
@@ -98,9 +111,8 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
else
|
||||
{
|
||||
this.lastSelectedIndex = PIVOT_PAGES_HALF_DOWN;
|
||||
this.ThePivot.SelectedIndex = PIVOT_PAGES_HALF_DOWN;
|
||||
this.lastSelectedIndex = this.ThePivot.SelectedIndex;
|
||||
this.ThePivot.SelectionChanged += new SelectionChangedEventHandler(this.OnPivotSelectionChanged);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,7 +155,23 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
private void OnClickToday(object sender, EventArgs e)
|
||||
{
|
||||
DateTime firstDay = this.GetFirstDayOfWeek(DateTime.Now).AddDays(-7 * PIVOT_PAGES_HALF_DOWN);
|
||||
this.ThePivot.SelectedIndex = PIVOT_PAGES_HALF_DOWN;
|
||||
|
||||
for (int i = 0; i < PIVOT_PAGES; i++)
|
||||
{
|
||||
this.itemPages[i].DateFrom = firstDay;
|
||||
this.itemPages[i].DateTo = this.itemPages[i].DateFrom.AddDays(6);
|
||||
this.itemPages[i].WeekNumber = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(
|
||||
this.itemPages[i].DateFrom,
|
||||
System.Globalization.CalendarWeekRule.FirstDay,
|
||||
DayOfWeek.Monday);
|
||||
this.itemPages[i].WeekChar = ((this.itemPages[i].WeekNumber % 2) == 0) ? 'B' : 'A';
|
||||
|
||||
firstDay = firstDay.AddDays(7);
|
||||
|
||||
this.SetupPage(i);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnClickProperties(object sender, EventArgs e)
|
||||
@@ -167,49 +195,28 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
int delta = this.ThePivot.SelectedIndex - this.lastSelectedIndex;
|
||||
|
||||
/*
|
||||
<-
|
||||
-1 = 0 - 1 -> 2
|
||||
-1 = 1 - 2 -> 0
|
||||
2 = 2 - 0 -> 1
|
||||
|
||||
->
|
||||
1 = 1 - 0 -> 2
|
||||
1 = 2 - 1 -> 0
|
||||
-2 = 0 - 2 -> 1
|
||||
*/
|
||||
|
||||
if (delta < -1) delta = 1;
|
||||
else if (delta > 1) delta = -1;
|
||||
|
||||
int index = (this.ThePivot.SelectedIndex + delta + PIVOT_PAGES) % PIVOT_PAGES;
|
||||
int index = (this.ThePivot.SelectedIndex + (delta * PIVOT_PAGES_HALF_DOWN) + PIVOT_PAGES) % PIVOT_PAGES;
|
||||
|
||||
if (delta < 0)
|
||||
{
|
||||
this.itemPages[index].DateFrom = this.itemPages[this.ThePivot.SelectedIndex].DateFrom.AddDays(-7);
|
||||
this.itemPages[index].DateTo = this.itemPages[this.ThePivot.SelectedIndex].DateTo.AddDays(-7);
|
||||
}
|
||||
else if (delta == 0)
|
||||
if (delta == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.itemPages[index].DateFrom = this.itemPages[this.ThePivot.SelectedIndex].DateFrom.AddDays(7);
|
||||
this.itemPages[index].DateTo = this.itemPages[this.ThePivot.SelectedIndex].DateTo.AddDays(7);
|
||||
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.itemPages[index].Content.Children.Clear();
|
||||
//this.itemPages[index].Content.Children.Clear();
|
||||
this.itemPages[index].WeekNumber = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(
|
||||
this.itemPages[index].DateFrom,
|
||||
System.Globalization.CalendarWeekRule.FirstDay,
|
||||
DayOfWeek.Monday);
|
||||
this.itemPages[index].WeekChar = ((this.itemPages[index].WeekNumber % 2) == 0) ? 'B' : 'A';
|
||||
|
||||
((this.ThePivot.Items[index] as PivotItem).Header as Grid).Children.Clear();
|
||||
|
||||
this.DrawHeader(((this.ThePivot.Items[index] as PivotItem).Header as Grid), string.Format("{0:dd.MM.yyyy} < {1:c} > {2:dd.MM.yyyy}", this.itemPages[index].DateFrom, this.itemPages[index].WeekChar, this.itemPages[index].DateTo));
|
||||
|
||||
this.SetupPage(index);
|
||||
|
||||
this.lastSelectedIndex = this.ThePivot.SelectedIndex;
|
||||
@@ -223,9 +230,9 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
private void OnAppointmentClick(AppointmentModel sender)
|
||||
private void OnAppointmentClick(object sender, System.Windows.Input.GestureEventArgs e)
|
||||
{
|
||||
int index = TimeTable.AppointmentsModel.Appointments.IndexOf(sender);
|
||||
int index = TimeTable.AppointmentsModel.Appointments.IndexOf((sender as Canvas).Tag as AppointmentModel);
|
||||
|
||||
if (index >= 0)
|
||||
{
|
||||
@@ -239,6 +246,53 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMultiBubbleClick(object sender, System.Windows.Input.GestureEventArgs e)
|
||||
{
|
||||
int indexVal = (int)(sender as Canvas).Tag;
|
||||
int dayIndex = (indexVal >> 24) & 0xF;
|
||||
int index = (indexVal >> 12) & 0xFFF;
|
||||
int listIndex = (indexVal) & 0xFFF;
|
||||
|
||||
AppointmentModel tempModel = this.itemPages[index].Stacks[dayIndex][listIndex].First();
|
||||
this.itemPages[index].Stacks[dayIndex][listIndex].Remove(tempModel);
|
||||
this.itemPages[index].Stacks[dayIndex][listIndex].Add(tempModel);
|
||||
|
||||
for (int i = 0; i < this.itemPages[index].Stacks[dayIndex][listIndex].Count(); i++)
|
||||
{
|
||||
tempModel = this.itemPages[index].Stacks[dayIndex][listIndex][i];
|
||||
|
||||
this.RemoveContentUIElement(index, tempModel);
|
||||
|
||||
for (int day = 0; day < 5; day++)
|
||||
{
|
||||
if (tempModel.IsDate(this.itemPages[index].DateFrom.Date.AddDays(day)) > -1)
|
||||
{
|
||||
if (i > 0)
|
||||
{
|
||||
this.DrawAppointment(this.itemPages[index].Stacks[dayIndex][listIndex][i], index, day, 0.5, i, this.itemPages[index].Stacks[dayIndex][listIndex].Count - 1 - i);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DrawAppointment(this.itemPages[index].Stacks[dayIndex][listIndex][i], index, day, 1.0, i, this.itemPages[index].Stacks[dayIndex][listIndex].Count - 1 - i);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.RemoveContentUIElement(index, sender as Canvas);
|
||||
|
||||
Canvas[] tempCan = this.GetModelCanvasFromContent(index, this.itemPages[index].Stacks[dayIndex][listIndex][0]);
|
||||
|
||||
// FIXME: tempCan[0] -> to correct tempCan
|
||||
this.DrawMultiBubble(
|
||||
index,
|
||||
dayIndex,
|
||||
listIndex,
|
||||
this.itemPages[index].Stacks[dayIndex][listIndex].Count(),
|
||||
tempCan[0].Width + tempCan[0].Margin.Left,
|
||||
tempCan[0].Margin.Top);
|
||||
}
|
||||
|
||||
private void OnListChanged(object sender, NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
AppointmentModel tempModel = null;
|
||||
@@ -281,7 +335,6 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
int index = this.ThePivot.Items.IndexOf(pvItem);
|
||||
|
||||
headGrid.Width = e.NewSize.Width;
|
||||
this.DrawHeader(headGrid, string.Format("{0:dd.MM.yyyy} < {1:c} > {2:dd.MM.yyyy}", this.itemPages[index].DateFrom, this.itemPages[index].WeekChar, this.itemPages[index].DateTo));
|
||||
|
||||
this.DrawBackground(tempBG);
|
||||
|
||||
@@ -291,10 +344,23 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
private void SetupPage(int index)
|
||||
{
|
||||
this.itemPages[index].Content.Children.Clear();
|
||||
// Header
|
||||
|
||||
((this.ThePivot.Items[index] as PivotItem).Header as Grid).Children.Clear();
|
||||
|
||||
this.DrawHeader(index);
|
||||
|
||||
// Items
|
||||
|
||||
List<AppointmentModel>[] tempList = new List<AppointmentModel>[5];
|
||||
|
||||
for(int i = 0; i < 5; i++)
|
||||
{
|
||||
this.itemPages[index].Stacks[i].Clear();
|
||||
}
|
||||
|
||||
this.itemPages[index].Content.Children.Clear();
|
||||
|
||||
for(int i = 0; i < 5; i++)
|
||||
{
|
||||
tempList[i] = new List<AppointmentModel>();
|
||||
@@ -302,19 +368,116 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
for (int i = 0; i < TimeTable.AppointmentsModel.Appointments.Count(); i++)
|
||||
{
|
||||
int appointmentIndex = -1;
|
||||
|
||||
if ((appointmentIndex = TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemPages[index].DateFrom, 4)) > -1)
|
||||
for (int k = 0; k < 5; k++)
|
||||
{
|
||||
tempList[appointmentIndex].Add(TimeTable.AppointmentsModel.Appointments[i]);
|
||||
if (TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemPages[index].DateFrom.Date.AddDays(k)) > -1)
|
||||
{
|
||||
tempList[k].Add(TimeTable.AppointmentsModel.Appointments[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
// -------------------------------------------------------
|
||||
for(int k = 0; k < 5; k++)
|
||||
for (int day = 0; day < 5; day++)
|
||||
{
|
||||
for (int i = 0; i < tempList[k].Count(); i++)
|
||||
for (int i = 0; i < tempList[day].Count(); i++)
|
||||
{
|
||||
this.DrawAppointment(tempList[k][i], index, k, 1.0, 0, 0);
|
||||
int[] intersectIndex = tempList[day][i].IntersectArray(tempList[day].ToArray());
|
||||
|
||||
if (intersectIndex.Count() == 0)
|
||||
{
|
||||
this.DrawAppointment(tempList[day][i], index, day);
|
||||
}
|
||||
else if (intersectIndex.Count() == 1)
|
||||
{
|
||||
int addIndex = -1;
|
||||
|
||||
for (int k = 0; k < this.itemPages[index].Stacks[day].Count(); k++)
|
||||
{
|
||||
if (this.itemPages[index].Stacks[day][k].IndexOf(tempList[day][intersectIndex[0]]) > -1)
|
||||
{
|
||||
addIndex = k;
|
||||
}
|
||||
}
|
||||
|
||||
if (addIndex >= 0)
|
||||
{
|
||||
this.itemPages[index].Stacks[day][addIndex].Add(tempList[day][i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<AppointmentModel> newList = new List<AppointmentModel>();
|
||||
newList.Add(tempList[day][i]);
|
||||
this.itemPages[index].Stacks[day].Add(newList);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
List<List<AppointmentModel>> intersectLists = new List<List<AppointmentModel>>();
|
||||
|
||||
for (int k = 0; k < intersectIndex.Count(); k++)
|
||||
{
|
||||
for (int m = 0; m < this.itemPages[index].Stacks[day].Count(); m++)
|
||||
{
|
||||
if (this.itemPages[index].Stacks[day][m].IndexOf(tempList[day][intersectIndex[k]]) > -1)
|
||||
{
|
||||
if (intersectLists.IndexOf(this.itemPages[index].Stacks[day][m]) < 0)
|
||||
{
|
||||
intersectLists.Add(this.itemPages[index].Stacks[day][m]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (intersectLists.Count() == 0)
|
||||
{
|
||||
List<AppointmentModel> newList = new List<AppointmentModel>();
|
||||
newList.Add(tempList[day][i]);
|
||||
this.itemPages[index].Stacks[day].Add(newList);
|
||||
}
|
||||
else if (intersectLists.Count() == 1)
|
||||
{
|
||||
intersectLists[0].Add(tempList[day][i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int k = 1; k < intersectLists.Count(); k++)
|
||||
{
|
||||
intersectLists[0].AddRange(intersectLists[k].ToArray());
|
||||
this.itemPages[index].Stacks[day].Remove(intersectLists[k]);
|
||||
}
|
||||
|
||||
intersectLists[0].Add(tempList[day][i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// stack draw
|
||||
for (int day = 0; day < 5; day++)
|
||||
{
|
||||
for (int i = 0; i < this.itemPages[index].Stacks[day].Count(); i++)
|
||||
{
|
||||
for (int k = 0; k < this.itemPages[index].Stacks[day][i].Count(); k++)
|
||||
{
|
||||
if (k > 0)
|
||||
{
|
||||
this.DrawAppointment(this.itemPages[index].Stacks[day][i][k], index, day, 0.5, k, this.itemPages[index].Stacks[day][i].Count() - 1 - k);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.DrawAppointment(this.itemPages[index].Stacks[day][i][k], index, day, 1.0, k, this.itemPages[index].Stacks[day][i].Count() - 1 - k);
|
||||
}
|
||||
}
|
||||
|
||||
Canvas[] tempCan = this.GetModelCanvasFromContent(index, this.itemPages[index].Stacks[day][i][0]);
|
||||
// FIXME: tempCan[0] ->
|
||||
this.DrawMultiBubble(
|
||||
index,
|
||||
day,
|
||||
i,
|
||||
this.itemPages[index].Stacks[day][i].Count(),
|
||||
tempCan[0].Width + tempCan[0].Margin.Left,
|
||||
tempCan[0].Margin.Top);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -355,18 +518,101 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
|
||||
}
|
||||
|
||||
private void DrawAppointment(AppointmentModel model, int index, int xIndex, double opacity = 1.0, int zIndex = 0, int modelCount = 0)
|
||||
private void RemoveContentUIElement(int index, UIElement elem)
|
||||
{
|
||||
model.OnClick += new AppointmentModel.OnAppointmentClick(this.OnAppointmentClick);
|
||||
model.Canvas.Opacity = opacity;
|
||||
model.Canvas.SetValue(Canvas.ZIndexProperty, WEEK_TABLE_ZINDEX_MAX - zIndex);
|
||||
model.Canvas.Margin = new Thickness(WEEK_TABLE_HEAD_WIDTH + 2 + (zIndex * WEEK_TABLE_ZINDEX_SHIFT) + (xIndex * ((this.itemPages[index].Content.Width - WEEK_TABLE_HEAD_WIDTH) / 5)), model.GetYOffset, 0, 0);
|
||||
model.SetWidth(((this.itemPages[index].Content.Width - WEEK_TABLE_HEAD_WIDTH) / 5) - 2 - 2 - (modelCount * WEEK_TABLE_ZINDEX_SHIFT));
|
||||
this.itemPages[index].Content.Children.Add(model.Canvas);
|
||||
this.itemPages[index].Content.Children.Remove(elem);
|
||||
}
|
||||
|
||||
private void DrawHeader(Grid grid, string text)
|
||||
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)
|
||||
{
|
||||
Canvas modelCan = model.GetCanvas(
|
||||
((this.itemPages[index].Content.Width - WEEK_TABLE_HEAD_WIDTH) / 5) - 2 - 2 - (modelCount * WEEK_TABLE_ZINDEX_SHIFT),
|
||||
WEEK_TABLE_CELL_HEIGHT,
|
||||
this.itemPages[index].DateFrom.Date.AddDays(xIndex));
|
||||
|
||||
modelCan.DoubleTap += new EventHandler<System.Windows.Input.GestureEventArgs>(this.OnAppointmentClick);
|
||||
modelCan.Opacity = opacity;
|
||||
modelCan.SetValue(Canvas.ZIndexProperty, WEEK_TABLE_ZINDEX_MAX - zIndex);
|
||||
modelCan.Margin = new Thickness(
|
||||
(WEEK_TABLE_HEAD_WIDTH + 2 + (zIndex * WEEK_TABLE_ZINDEX_SHIFT) + (xIndex * ((this.itemPages[index].Content.Width - WEEK_TABLE_HEAD_WIDTH) / 5))),
|
||||
modelCan.Margin.Top,
|
||||
0,
|
||||
0);
|
||||
|
||||
this.itemPages[index].Content.Children.Add(modelCan);
|
||||
}
|
||||
|
||||
private void DrawMultiBubble(int index, int dayIndex, int listIndex, int number, double xOffset, double yOffset)
|
||||
{
|
||||
Canvas can = new Canvas();
|
||||
|
||||
Rectangle rect = new Rectangle();
|
||||
rect.Width = WEEK_TABLE_CELL_HEIGHT / 2;
|
||||
rect.Height = WEEK_TABLE_CELL_HEIGHT / 2;
|
||||
rect.RadiusX = WEEK_TABLE_CELL_HEIGHT / 4;
|
||||
rect.RadiusY = WEEK_TABLE_CELL_HEIGHT / 4;
|
||||
rect.StrokeThickness = 1;
|
||||
rect.Stroke = new SolidColorBrush(Colors.DarkGray);
|
||||
rect.Fill = new SolidColorBrush(Colors.Black);
|
||||
|
||||
TextBlock block = new TextBlock();
|
||||
block.Height = WEEK_TABLE_CELL_HEIGHT / 2;
|
||||
block.Width = WEEK_TABLE_CELL_HEIGHT / 2;
|
||||
block.Text = "" + number;
|
||||
block.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
block.VerticalAlignment = VerticalAlignment.Center;
|
||||
block.FontWeight = FontWeights.Bold;
|
||||
block.FontSize = WEEK_TABLE_CELL_HEIGHT / 3;
|
||||
block.Padding = new Thickness(WEEK_TABLE_CELL_HEIGHT / 6.5, 0, 0, 0);
|
||||
|
||||
can.Children.Add(rect);
|
||||
can.Children.Add(block);
|
||||
can.Tap += new EventHandler<System.Windows.Input.GestureEventArgs>(this.OnMultiBubbleClick);
|
||||
can.Tag = ((dayIndex & 0xF) << 24) | ((index & 0xFFF) << 12) | (listIndex & 0xFFF);
|
||||
can.SetValue(Canvas.LeftProperty, xOffset - rect.Width);
|
||||
can.SetValue(Canvas.TopProperty, yOffset);
|
||||
can.SetValue(Canvas.ZIndexProperty, WEEK_TABLE_ZINDEX_MAX + 1);
|
||||
|
||||
this.itemPages[index].Content.Children.Add(can);
|
||||
}
|
||||
|
||||
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;
|
||||
@@ -392,16 +638,23 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
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);
|
||||
|
||||
TextBlock dayTB = new TextBlock();
|
||||
dayTB.Text = dayStr[i];
|
||||
dayTB.TextAlignment = TextAlignment.Center;
|
||||
dayTB.HorizontalAlignment = HorizontalAlignment.Center;
|
||||
|
||||
Reference in New Issue
Block a user