diff --git a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs
index 9f166c89..2131a7d8 100644
--- a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs
+++ b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs
@@ -1,7 +1,13 @@
-
+//-----------------------------------------------------------------------
+//
+// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
+//
+// Fiedler
+// 06.11.2013
+// Implements the appointment feed class
+//-----------------------------------------------------------------------
namespace CampusAppWP8.Feed.TimeTable
{
- using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@@ -12,9 +18,14 @@ namespace CampusAppWP8.Feed.TimeTable
using CampusAppWP8.Model.TimeTable;
using CampusAppWPortalLib8.Model;
+ /// An appointment feed.
+ /// Fiedler, 06.11.2013.
+ ///
public class AppointmentFeed : XmlModel
{
-
+ /// Initializes a new instance of the AppointmentFeed class.
+ /// Fiedler, 06.11.2013.
+ /// (Optional) the automatic load.
public AppointmentFeed(bool autoLoad = true)
: base(ModelType.File, Constants.FileAppointments_Name)
{
@@ -28,6 +39,10 @@ namespace CampusAppWP8.Feed.TimeTable
}
}
+ /// Check is model up to date.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// true if it succeeds, false if it fails.
private bool CheckIsModelUpToDate(AppointmentListModel model)
{
bool retValue = true;
@@ -40,6 +55,11 @@ namespace CampusAppWP8.Feed.TimeTable
return retValue;
}
+ /// Check is file up to date on load.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// The information.
+ /// true if it succeeds, false if it fails.
private bool CheckIsFileUpToDateOnLoad(AppointmentListModel model, FileInfo info)
{
bool retValue = true;
@@ -47,6 +67,11 @@ namespace CampusAppWP8.Feed.TimeTable
return retValue;
}
+ /// Check is file up to date on save.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// The information.
+ /// true if it succeeds, false if it fails.
private bool CheckIsFileUpToDateOnSave(AppointmentListModel model, FileInfo info)
{
bool retValue = true;
@@ -66,6 +91,10 @@ namespace CampusAppWP8.Feed.TimeTable
return retValue;
}
+ /// Deserialize model.
+ /// Fiedler, 06.11.2013.
+ /// Information describing the model.
+ /// true if it succeeds, false if it fails.
protected override bool DeserializeModel(byte[] modelData)
{
if (this.Model == null)
@@ -91,6 +120,9 @@ namespace CampusAppWP8.Feed.TimeTable
return true;
}
+ /// Gets the serialize model.
+ /// Fiedler, 06.11.2013.
+ /// A byte[].
protected override byte[] SerializeModel()
{
List retValue = new List();
diff --git a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs
index 3ca3ad88..bc731c58 100644
--- a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs
+++ b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs
@@ -10,26 +10,25 @@ namespace CampusAppWP8.Model.TimeTable
{
using System;
using System.Collections.Generic;
- using System.Text.RegularExpressions;
- using System.Windows.Shapes;
- using System.Xml.Serialization;
- using System.Windows.Controls;
- using System.Windows.Media;
- using System.Windows;
using CampusAppWP8.Utility;
using CampusAppWP8.Utility.ICSProperties;
- ///
- /// Model for appointments.
- ///
+ /// Model for appointments.
+ /// Fiedler, 06.11.2013.
public class AppointmentModel
{
+ /// The ical object.
private ICalObject icalObj = null;
-
+
+ /// Executes the appointment click action.
+ /// Fiedler, 06.11.2013.
+ /// The sender.
public delegate void OnAppointmentClick(AppointmentModel sender);
+ /// Occurs when On Click.
public event OnAppointmentClick OnClick = null;
-
- /// Initializes a new instance of the class.
+
+ /// Initializes a new instance of the class.
+ /// Fiedler, 06.11.2013.
public AppointmentModel()
{
this.icalObj = new ICalObject();
@@ -46,11 +45,16 @@ namespace CampusAppWP8.Model.TimeTable
this.icalObj.AddProperty(newProdID);
}
+ /// Initializes a new instance of the AppointmentModel class.
+ /// Fiedler, 06.11.2013.
+ /// Information describing the ics.
public AppointmentModel(string icsData) : this()
{
this.icalObj = ICSManager.ImportFromICS(icsData);
}
+ /// Gets or sets the calendar object.
+ /// The calendar object.
public ICalObject CalendarObj
{
get
@@ -64,6 +68,11 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ /// Is date.
+ /// Fiedler, 06.11.2013.
+ /// The date Date/Time.
+ /// (Optional) the day span.
+ /// An int.
public int IsDate(DateTime date, int daySpan = 0)
{
int retValue = -1;
@@ -92,6 +101,10 @@ namespace CampusAppWP8.Model.TimeTable
return retValue;
}
+ /// Intersects the given model.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// true if it succeeds, false if it fails.
public bool Intersect(AppointmentModel model)
{
bool retValue = false;
@@ -112,6 +125,10 @@ namespace CampusAppWP8.Model.TimeTable
return retValue;
}
+ /// Intersects the given model.
+ /// Fiedler, 06.11.2013.
+ /// List of models.
+ /// true if it succeeds, false if it fails.
public int Intersect(AppointmentModel[] modelList)
{
int retValue = -1;
@@ -127,6 +144,10 @@ namespace CampusAppWP8.Model.TimeTable
return retValue;
}
+ /// Intersect array.
+ /// Fiedler, 06.11.2013.
+ /// List of models.
+ /// An int[].
public int[] IntersectArray(AppointmentModel[] modelList)
{
List retValue = new List();
@@ -142,6 +163,9 @@ namespace CampusAppWP8.Model.TimeTable
return retValue.ToArray();
}
+ /// Sets a value.
+ /// Fiedler, 06.11.2013.
+ /// The value.
public void SetValue(object value)
{
ICalObject vevent = this.GetVEventObj(true);
@@ -149,6 +173,10 @@ namespace CampusAppWP8.Model.TimeTable
vevent.AddProperty(value);
}
+ /// Gets a value.
+ /// Fiedler, 06.11.2013.
+ /// Name of the property.
+ /// The value.
public object GetValue(string propertyName)
{
object retValue = this.GetVEventObj().GetProperty(propertyName);
@@ -156,11 +184,18 @@ namespace CampusAppWP8.Model.TimeTable
return retValue;
}
+ /// Gets total hours.
+ /// Fiedler, 06.11.2013.
+ /// The total hours.
public double GetTotalHours()
{
return this.End.Subtract(this.Start).TotalHours;
}
+ /// Gets total hours.
+ /// Fiedler, 06.11.2013.
+ /// The date Date/Time.
+ /// The total hours.
public double GetTotalHours(DateTime date)
{
double retValue = 0;
@@ -195,6 +230,13 @@ namespace CampusAppWP8.Model.TimeTable
return retValue;
}
+ /// Gets v event object.
+ /// Fiedler, 06.11.2013.
+ ///
+ /// Thrown when a value was unexpectedly null.
+ ///
+ /// (Optional) the create.
+ /// The v event object.
private ICalObject GetVEventObj(bool create = false)
{
ICalObject retValue = this.icalObj.GetProperty(ICSTag.VEVENT) as ICalObject;
@@ -219,6 +261,10 @@ namespace CampusAppWP8.Model.TimeTable
return retValue;
}
+ /// Raises the canvas click event.
+ /// Fiedler, 06.11.2013.
+ /// Source of the event.
+ /// Event information to send to registered event handlers.
public void OnCanvasClick(object sender, EventArgs e)
{
if (this.OnClick != null)
@@ -228,6 +274,9 @@ namespace CampusAppWP8.Model.TimeTable
}
// ------------------------------------------------------
+
+ /// Gets the title.
+ /// The title.
public string Title
{
get
@@ -239,6 +288,8 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ /// Gets the date.
+ /// The date.
public string Date
{
get
@@ -265,6 +316,8 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ /// Gets the location.
+ /// The location.
public string Location
{
get
@@ -283,6 +336,8 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ /// Gets the description.
+ /// The description.
public string Description
{
get
@@ -301,6 +356,8 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ /// Gets the Date/Time of the start.
+ /// The start.
public DateTime Start
{
get
@@ -317,6 +374,8 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ /// Gets the Date/Time of the end.
+ /// The end.
public DateTime End
{
get
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs
index 5d23d8e8..526ef841 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs
@@ -8,28 +8,29 @@
namespace CampusAppWP8.Pages.TimeTable
{
using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Net;
- using System.Windows;
using System.Windows.Media;
- using System.Windows.Controls;
- using System.Windows.Navigation;
using Microsoft.Phone.Controls;
- using Microsoft.Phone.Shell;
- using CampusAppWP8.Resources;
- using CampusAppWP8.Utility;
using CampusAppWP8.Model.TimeTable;
using CampusAppWP8.Feed.TimeTable;
+ /// A time table.
+ /// Fiedler, 06.11.2013.
+ ///
public partial class TimeTable : PhoneApplicationPage
{
+ /// The setting automatic scroll to hour.
public static int Setting_AutoScrollToHour = 7;
- public static int Setting_VisualScale = 0; //0 - small, 1 - medium, 2 - large UNUSED ATM
+ /// 0 - small, 1 - medium, 2 - large UNUSED ATM.
+ public static int Setting_VisualScale = 0;
+ /// The setting hour spacing.
public static double Setting_Hour_Spacing = 40;
+ /// Height of the setting view.
public static double Setting_View_Height = Setting_Hour_Spacing * 24;
+ /// Zero-based index of the setting maximum z coordinate.
public static int Setting_Max_Z_Index = 10;
+ /// The setting z coordinate spacing.
public static double Setting_Z_Spacing = 10;
+ /// List of colors of the setting priorities.
public static SolidColorBrush[] Setting_Priority_Colors = new SolidColorBrush[]
{
new SolidColorBrush(Colors.Green),
@@ -45,8 +46,11 @@ namespace CampusAppWP8.Pages.TimeTable
};
+ /// The feed.
private static AppointmentFeed feed = null;
+ /// Gets the feed.
+ /// The feed.
public static AppointmentFeed Feed
{
get
@@ -60,6 +64,8 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
+ /// Initialises the feed.
+ /// Fiedler, 06.11.2013.
public static void InitFeed()
{
if(TimeTable.feed == null)
@@ -70,6 +76,8 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
+ /// Executes the load failed action.
+ /// Fiedler, 06.11.2013.
private static void OnLoadFailed()
{
if (TimeTable.feed.Model == null)
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs
index 2d4a0c76..8f9aa30e 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs
@@ -8,10 +8,8 @@
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;
using System.Windows.Media;
@@ -21,9 +19,6 @@ namespace CampusAppWP8.Pages.TimeTable
using Microsoft.Phone.Shell;
using CampusAppWP8.Model.TimeTable;
using CampusAppWP8.Resources;
- using CampusAppWP8.Utility.Lui.Templates;
- using CampusAppWP8.Utility.Lui.Header;
- using System.Windows.Data;
public partial class TimeTableWeek : PhoneApplicationPage
{
@@ -156,19 +151,39 @@ 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;
+ DateTime firstDay = this.GetFirstDayOfWeek(DateTime.Now);
+ int testIndex = -1;
- for (int i = 0; i < PIVOT_PAGES; i++)
+ for (int i = 0; i < this.itemList.Count; i++)
{
- this.itemList[i].FromDT = firstDay;
- this.itemList[i].ToDT = this.itemList[i].FromDT.AddDays(6);
- this.itemList[i].WeekNr = this.GetWeekNumber(this.itemList[i].FromDT);
- this.itemList[i].WeekStr = ((this.itemList[i].WeekNr % 2) == 0) ? "B" : "A";
-
- firstDay = firstDay.AddDays(7);
+ if (this.itemList[i].FromDT.Equals(firstDay) == true)
+ {
+ testIndex = i;
+ }
+ }
+
+ if (testIndex < 0)
+ {
+ this.ThePivot.SelectedIndex = PIVOT_PAGES_HALF_DOWN;
+ firstDay = firstDay.AddDays(-7 * PIVOT_PAGES_HALF_DOWN);
+
+ for (int i = 0; i < PIVOT_PAGES; i++)
+ {
+ this.itemList[i].FromDT = firstDay;
+ this.itemList[i].ToDT = this.itemList[i].FromDT.AddDays(6);
+ this.itemList[i].WeekNr = this.GetWeekNumber(this.itemList[i].FromDT);
+ this.itemList[i].WeekStr = ((this.itemList[i].WeekNr % 2) != 0) ? "A" : "B";
+ this.itemList[i].AppointmentList.Clear();
+
+ this.CheckAppointments(i);
+
+ firstDay = firstDay.AddDays(7);
+ }
+ }
+ else
+ {
+ this.ThePivot.SelectedIndex = testIndex;
}
- //maybe FIXME
}
private void OnClickProperties(object sender, EventArgs e)
@@ -190,7 +205,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;
@@ -200,32 +215,19 @@ namespace CampusAppWP8.Pages.TimeTable
{
return;
}
- else
- {
- 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,
-// System.Globalization.CalendarWeekRule.FirstDay,
-// DayOfWeek.Monday);
-// this.itemPages[index].WeekChar = ((this.itemPages[index].WeekNumber % 2) == 0) ? 'B' : 'A';
+
+ 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.itemList[index].WeekNr = this.GetWeekNumber(this.itemList[index].FromDT);
+ this.itemList[index].WeekStr = ((this.itemList[index].WeekNr % 2) != 0) ? "A" : "B";
- //this.SetupPage(index);
+ this.itemList[index].AppointmentList.Clear();
+
+ this.CheckAppointments(index);
this.lastSelectedIndex = this.ThePivot.SelectedIndex;
}
-/*
- private void OnAutoScroll(object sender, RoutedEventArgs e)
- {
- if ((sender as ScrollViewer).VerticalOffset == 0.0)
- {
- (sender as ScrollViewer).ScrollToVerticalOffset(WEEK_TABLE_CELL_HEIGHT * TimeTable.AutoScrollToHour);
- }
- }
-*/
+
private void OnAppointmentClick(AppointmentModel model)
{
int index = TimeTable.Feed.Model.Appointments.IndexOf(model);
@@ -302,7 +304,7 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
*/
-}
+ }
private void OnListChanged(object sender, NotifyCollectionChangedEventArgs e)
{
@@ -336,7 +338,7 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
- private void CheckAppointments()
+ private void CheckAppointments(int pageIndex = -1)
{
if (TimeTable.Feed == null)
{
@@ -351,294 +353,37 @@ namespace CampusAppWP8.Pages.TimeTable
throw new NullReferenceException("Appointments == null");
}
- for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++)
+ if (pageIndex < 0)
{
- AppointmentModel temp = TimeTable.Feed.Model.Appointments[m];
-
- for (int i = 0; i < PIVOT_PAGES; i++)
+ for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++)
{
- if (temp.IsDate(this.itemList[i].FromDT, 4) >= 0)
+ AppointmentModel temp = TimeTable.Feed.Model.Appointments[m];
+
+ for (int i = 0; i < PIVOT_PAGES; i++)
+ {
+ if (temp.IsDate(this.itemList[i].FromDT, 4) >= 0)
+ {
+ temp.OnClick += this.OnAppointmentClick;
+ this.itemList[i].AppointmentList.Add(temp);
+ }
+ }
+ }
+ }
+ else
+ {
+ for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++)
+ {
+ AppointmentModel temp = TimeTable.Feed.Model.Appointments[m];
+
+ if (temp.IsDate(this.itemList[pageIndex].FromDT, 4) >= 0)
{
temp.OnClick += this.OnAppointmentClick;
- this.itemList[i].AppointmentList.Add(temp);
+ this.itemList[pageIndex].AppointmentList.Add(temp);
}
}
}
}
-
- private void SetupPage(int index)
- {
- // Header
-
- //((this.ThePivot.Items[index] as PivotItem).Header as Grid).Children.Clear();
-
- //this.DrawHeader(index);
-
- // Items
-
-// List[] tempList = new List[5];
- List tempList = new List();
-
- /*
- for(int i = 0; i < 5; i++)
- {
- this.itemPages[index].Stacks[i].Clear();
- }
- /**/
-// this.itemPages[index].Stacks.Clear();
-
-// this.itemPages[index].Content.Children.Clear();
-/*
- for(int i = 0; i < 5; i++)
- {
- tempList[i] = new List();
- }
-*/
- for (int i = 0; i < TimeTable.Feed.Model.Appointments.Count(); i++)
- {
-/*
- for (int k = 0; k < 5; k++)
- {
- if (TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemPages[index].DateFrom.Date.AddDays(k)) > -1)
- {
- tempList[k].Add(TimeTable.AppointmentsModel.Appointments[i]);
- }
- }
-*/
- if (TimeTable.Feed.Model.Appointments[i].IsDate(this.itemList[index].FromDT.Date, 4) > -1)
- {
- tempList.Add(TimeTable.Feed.Model.Appointments[i]);
- }
- }
- // -------------------------------------------------------
-/*
- for (int i = 0; i < tempList.Count(); i++)
- {
- int[] intersectIndex = tempList[i].IntersectArray(tempList.ToArray());
-
- if (intersectIndex.Count() == 0)
- {
- for (int day = 0; day < 5; day++)
- {
- if (tempList[i].IsDate(this.itemPages[index].DateFrom.Date.AddDays(day)) > -1)
- {
- this.DrawAppointment(tempList[i], index, day);
- }
- }
- }
- else if (intersectIndex.Count() == 1)
- {
- int addIndex = -1;
-
- for (int k = 0; k < this.itemPages[index].Stacks.Count(); k++)
- {
- //if (this.itemPages[index].Stacks[day][k].IndexOf(tempList[day][intersectIndex[0]]) > -1)
- if(this.itemPages[index].Stacks[k].IndexOf(tempList[intersectIndex[0]]) > -1)
- {
- addIndex = k;
- }
- }
-
- if (addIndex >= 0)
- {
- //this.itemPages[index].Stacks[day][addIndex].Add(tempList[day][i]);
- this.itemPages[index].Stacks[addIndex].Add(tempList[i]);
- }
- else
- {
- List newList = new List();
- //newList.Add(tempList[day][i]);
- //this.itemPages[index].Stacks[day].Add(newList);
- newList.Add(tempList[i]);
- this.itemPages[index].Stacks.Add(newList);
- }
- }
- else
- {
- List> intersectLists = new List>();
-
- for (int k = 0; k < intersectIndex.Count(); k++)
- {
- //for (int m = 0; m < this.itemPages[index].Stacks[day].Count(); m++)
- for(int m = 0; m < this.itemPages[index].Stacks.Count(); m++)
- {
- //if (this.itemPages[index].Stacks[day][m].IndexOf(tempList[day][intersectIndex[k]]) > -1)
- if(this.itemPages[index].Stacks[m].IndexOf(tempList[intersectIndex[k]]) > -1)
- {
- //if (intersectLists.IndexOf(this.itemPages[index].Stacks[day][m]) < 0)
- if(intersectLists.IndexOf(this.itemPages[index].Stacks[m]) < 0)
- {
- //intersectLists.Add(this.itemPages[index].Stacks[day][m]);
- intersectLists.Add(this.itemPages[index].Stacks[m]);
- }
- }
- }
- }
-
- if (intersectLists.Count() == 0)
- {
- List newList = new List();
- //newList.Add(tempList[day][i]);
- //this.itemPages[index].Stacks[day].Add(newList);
- newList.Add(tempList[i]);
- this.itemPages[index].Stacks.Add(newList);
- }
- else if (intersectLists.Count() == 1)
- {
- //intersectLists[0].Add(tempList[day][i]);
- intersectLists[0].Add(tempList[i]);
- }
- else
- {
- for (int k = 1; k < intersectLists.Count(); k++)
- {
- intersectLists[0].AddRange(intersectLists[k].ToArray());
- //this.itemPages[index].Stacks[day].Remove(intersectLists[k]);
- this.itemPages[index].Stacks.Remove(intersectLists[k]);
- }
-
- //intersectLists[0].Add(tempList[day][i]);
- intersectLists[0].Add(tempList[i]);
- }
- }
- }
-*/
-/*
- for (int day = 0; day < 5; day++)
- {
- for (int i = 0; i < tempList[day].Count(); i++)
- {
- 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 newList = new List();
- newList.Add(tempList[day][i]);
- this.itemPages[index].Stacks[day].Add(newList);
- }
- }
- else
- {
- List> intersectLists = new List>();
-
- 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 newList = new List();
- 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 i = 0; i < this.itemPages[index].Stacks.Count(); i++)
- {
- //for (int k = 0; k < this.itemPages[index].Stacks[day][i].Count(); k++)
- for(int k = 0; k < this.itemPages[index].Stacks[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);
- for (int day = 0; day < 5; day++)
- {
- this.DrawAppointment(this.itemPages[index].Stacks[i][k], index, day, 0.5, k, this.itemPages[index].Stacks[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);
- for (int day = 0; day < 5; day++)
- {
- this.DrawAppointment(this.itemPages[index].Stacks[i][k], index, day, 1.0, k, this.itemPages[index].Stacks[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);
-*/
-/*
- for (int day = 0; day < 5; day++)
- {
- if (this.itemPages[index].Stacks[i][0].IsDate(this.itemPages[index].DateFrom.Date.AddDays(day)) > -1)
- {
- Canvas[] tempCan = this.GetModelCanvasFromContent(index, this.itemPages[index].Stacks[i][0]);
- this.DrawMultiBubble(
- index,
- day,
- i,
- this.itemPages[index].Stacks[i].Count(),
- tempCan[0].Width + tempCan[0].Margin.Left,
- tempCan[0].Margin.Top);
- }
- }
- }
- }
-*/
- }
-
private void DrawMultiBubble(int index, int dayIndex, int listIndex, int number, double xOffset, double yOffset)
{
Canvas can = new Canvas();
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs
index b56d75b8..a5564e04 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs
@@ -1,28 +1,48 @@
-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;
-
+//-----------------------------------------------------------------------
+//
+// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
+//
+// Fiedler
+// 06.11.2013
+// Implements the week view page item class
+//-----------------------------------------------------------------------
namespace CampusAppWP8.Pages.TimeTable
{
+ using System;
+ using System.Collections.ObjectModel;
+ using System.ComponentModel;
+ using CampusAppWP8.Model.TimeTable;
+ using CampusAppWP8.Utility.Lui.Templates;
+
+ /// A week view page item.
+ /// Fiedler, 06.11.2013.
+ ///
public class WeekViewPageItem : INotifyPropertyChanged
{
+ /// from dt Date/Time.
private DateTime fromDT;
+ /// to dt Date/Time.
private DateTime toDT;
+ /// The days.
private int days;
+ /// The week string.
private string weekStr = string.Empty;
+ /// The week number.
private int weekNumber = -1;
+ /// The week view.
private WeekView weekView = null;
+ /// List of appointments.
private ObservableCollection appointmentList = null;
+ /// Tritt ein, wenn sich ein Eigenschaftswert ändert.
public event PropertyChangedEventHandler PropertyChanged;
-
+ /// Initializes a new instance of the WeekViewPageItem class.
+ /// Fiedler, 06.11.2013.
+ /// from Date/Time.
+ /// The.
+ /// Number of.
+ /// The days.
public WeekViewPageItem(DateTime from, string str, int number, int days)
{
this.fromDT = from;
@@ -33,6 +53,8 @@ namespace CampusAppWP8.Pages.TimeTable
this.appointmentList = new ObservableCollection();
}
+ /// Gets or sets the Date/Time of from dt.
+ /// from dt.
public DateTime FromDT
{
get
@@ -47,6 +69,8 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
+ /// Gets or sets the Date/Time of to dt.
+ /// to dt.
public DateTime ToDT
{
get
@@ -61,6 +85,8 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
+ /// Gets or sets the week string.
+ /// The week string.
public string WeekStr
{
get
@@ -75,6 +101,8 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
+ /// Gets or sets the week nr.
+ /// The week nr.
public int WeekNr
{
get
@@ -89,6 +117,8 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
+ /// Gets or sets the view.
+ /// The view.
public WeekView View
{
get
@@ -103,6 +133,8 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
+ /// Gets or sets a list of appointments.
+ /// A List of appointments.
public ObservableCollection AppointmentList
{
get
@@ -117,6 +149,9 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
+ /// Notifies a property changed.
+ /// Fiedler, 06.11.2013.
+ /// The information.
private void NotifyPropertyChanged(string info)
{
if (this.PropertyChanged != null)
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs
index 3c7cb3f2..371b8f8f 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs
@@ -12,33 +12,42 @@ namespace CampusAppWP8.Utility.Lui.Templates
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
- using System.Net;
using System.Windows;
using System.Windows.Controls;
- using System.Windows.Navigation;
using System.Windows.Media;
- using Microsoft.Phone.Controls;
- using Microsoft.Phone.Shell;
using CampusAppWP8.Model.TimeTable;
using CampusAppWP8.Pages.TimeTable;
-
-
+
+ /// A week view.
+ /// Fiedler, 06.11.2013.
+ ///
public partial class WeekView : UserControl
{
+ /// The date from property.
public static readonly DependencyProperty DateFromProperty = DependencyProperty.Register("DateFrom", typeof(DateTime), typeof(WeekView), new PropertyMetadata(new DateTime(0), OnDateFromChanged));
+ /// The date to property.
public static readonly DependencyProperty DateToProperty = DependencyProperty.Register("DateTo", typeof(DateTime), typeof(WeekView), new PropertyMetadata(new DateTime(0)));
+ /// The days property.
public static readonly DependencyProperty DaysProperty = DependencyProperty.Register("Days", typeof(int), typeof(WeekView), new PropertyMetadata(5));
+ /// The appointments property.
public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(ObservableCollection), typeof(WeekView), new PropertyMetadata(null, OnAppointmentsChanged));
+ /// The week name property.
public static readonly DependencyProperty WeekNameProperty = DependencyProperty.Register("WeekName", typeof(string), typeof(WeekView), new PropertyMetadata("T-Woche"));
+ /// The week number property.
public static readonly DependencyProperty WeekNumberProperty = DependencyProperty.Register("WeekNumber", typeof(int), typeof(WeekView), new PropertyMetadata(-1));
+ /// List of borders.
private List borderList = new List();
+ /// List of days.
private List dayList = new List();
+ /// The time strings.
private string[] timeStrings = new string[24];
+ /// The monitor strings.
private string[] monStrings = new string[24];
-
+ /// Initializes a new instance of the WeekView class.
+ /// Fiedler, 06.11.2013.
public WeekView()
{
this.InitializeComponent();
@@ -46,6 +55,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
this.InitLayout();
}
+ /// Raises the dependency property changed event.
+ /// Fiedler, 06.11.2013.
+ /// The DependencyObject to process.
+ /// Event information to send to registered event handlers.
private static void OnDateFromChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
(o as WeekView).SetValue(DateToProperty, ((DateTime)e.NewValue).AddDays(6));
@@ -61,8 +74,16 @@ namespace CampusAppWP8.Utility.Lui.Templates
{
(o as WeekView).SetColumnBackground(diff.Days, new SolidColorBrush(Colors.Orange));
}
+ else
+ {
+ (o as WeekView).ClearBackground();
+ }
}
+ /// Raises the dependency property changed event.
+ /// Fiedler, 06.11.2013.
+ /// The DependencyObject to process.
+ /// Event information to send to registered event handlers.
private static void OnAppointmentsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
if (e.NewValue != null)
@@ -77,6 +98,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Raises the notify collection changed event.
+ /// Fiedler, 06.11.2013.
+ /// The object to process.
+ /// Event information to send to registered event handlers.
private void OnAppointmentListChanged(object s, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
@@ -93,8 +118,25 @@ namespace CampusAppWP8.Utility.Lui.Templates
this.SeperateAppointments(e.OldItems[i] as AppointmentModel, e.Action);
}
}
+ else if (e.Action == NotifyCollectionChangedAction.Reset)
+ {
+ this.ClearDays();
+ }
}
+ /// Clears the days.
+ /// Fiedler, 06.11.2013.
+ private void ClearDays()
+ {
+ for (int i = 0; i < this.dayList.Count; i++)
+ {
+ this.dayList[i].Appointments.Clear();
+ }
+ }
+
+ /// Seperate appointments.
+ /// Fiedler, 06.11.2013.
+ /// The list.
private void SeperateAppointments(ObservableCollection list)
{
foreach (AppointmentModel m in list)
@@ -103,9 +145,13 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Seperate appointments.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// The action.
private void SeperateAppointments(AppointmentModel model, NotifyCollectionChangedAction action)
{
- for(int i = 0; i < this.Days; i++)
+ for(int i = 0; i < this.dayList.Count; i++)
{
if (model.IsDate(this.DateFrom.AddDays(i)) == 0)
{
@@ -121,6 +167,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Gets or sets the Date/Time of the date from.
+ /// The date from.
public DateTime DateFrom
{
get
@@ -134,6 +182,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Gets or sets the Date/Time of the date to.
+ /// The date to.
public DateTime DateTo
{
get
@@ -147,6 +197,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Gets or sets the days.
+ /// The days.
public int Days
{
get
@@ -160,6 +212,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Gets or sets the appointments.
+ /// The appointments.
public ObservableCollection Appointments
{
get
@@ -173,6 +227,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Gets or sets the name of the week.
+ /// The name of the week.
public string WeekName
{
get
@@ -187,6 +243,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Gets or sets the week number.
+ /// The week number.
public int WeekNumber
{
get
@@ -200,6 +258,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Sets column background.
+ /// Fiedler, 06.11.2013.
+ /// The column.
+ /// (Optional) the brush.
public void SetColumnBackground(int column, Brush brush = null)
{
if (column < this.borderList.Count())
@@ -208,6 +270,20 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Clears the background.
+ /// Fiedler, 06.11.2013.
+ public void ClearBackground()
+ {
+ SolidColorBrush newBrush = new SolidColorBrush(Colors.Transparent);
+
+ for (int i = 0; i < this.borderList.Count; i++)
+ {
+ this.borderList[i].Background = newBrush;
+ }
+ }
+
+ /// Initialises the layout.
+ /// Fiedler, 06.11.2013.
private void InitLayout()
{
for (int i = 0; i < 24; i++)
@@ -231,6 +307,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
this.TimeList.ItemsSource = this.timeStrings;
}
+ /// Automatic scroll.
+ /// Fiedler, 06.11.2013.
+ /// Source of the event.
+ /// Routed event information.
private void AutoScroll(object sender, RoutedEventArgs e)
{
this.TheScrollView.ScrollToVerticalOffset((TimeTable.Setting_Hour_Spacing * 7) + 2);
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs
index 4d67b4ce..f6df4edc 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs
@@ -23,17 +23,27 @@ namespace CampusAppWP8.Utility.Lui.Templates
using System.Windows.Media;
using System.Windows.Data;
using CampusAppWP8.Model.TimeTable;
-
+
+ /// A week view day.
+ /// Fiedler, 06.11.2013.
+ ///
public partial class WeekViewDay : UserControl
{
+ /// The background list elements property.
public static readonly DependencyProperty BgListElementsProperty = DependencyProperty.Register("BgListElements", typeof(int), typeof(WeekViewDay), new PropertyMetadata(null));
+
+ /// The background list element height property.
public static readonly DependencyProperty BgListElementHeightProperty = DependencyProperty.Register("BgListElementHeight", typeof(double), typeof(WeekViewDay), new PropertyMetadata(null));
+
+ /// The date property.
public static readonly DependencyProperty DateProperty = DependencyProperty.Register("Date", typeof(DateTime), typeof(WeekViewDay), new PropertyMetadata(DateTime.Today));
+
+ /// The appointments property.
public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(ObservableCollection), typeof(WeekViewDay), new PropertyMetadata(null, OnAppointmentsChanged));
+ /// The stacks.
private List> stacks = new List>();
-
/// Initializes a new instance of the WeekViewDay class.
/// Fiedler, 22.10.2013.
public WeekViewDay()
@@ -43,6 +53,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
this.InitializeComponent();
}
+ /// Raises the dependency property changed event.
+ /// Fiedler, 06.11.2013.
+ /// The DependencyObject to process.
+ /// Event information to send to registered event handlers.
private static void OnAppointmentsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
{
if(e.NewValue != null)
@@ -56,6 +70,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Raises the notify collection changed event.
+ /// Fiedler, 06.11.2013.
+ /// The object to process.
+ /// Event information to send to registered event handlers.
private void OnAppointmentListChanged(object s, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
@@ -72,8 +90,15 @@ namespace CampusAppWP8.Utility.Lui.Templates
this.CheckStackRemove(e.OldItems[i] as AppointmentModel);
}
}
+ else if (e.Action == NotifyCollectionChangedAction.Reset)
+ {
+ this.UserCanvas.Children.Clear();
+ this.stacks.Clear();
+ }
}
+ /// Gets or sets the appointments.
+ /// The appointments.
public ObservableCollection Appointments
{
get
@@ -87,6 +112,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Gets or sets the Date/Time of the date.
+ /// The date.
public DateTime Date
{
get
@@ -99,7 +126,7 @@ namespace CampusAppWP8.Utility.Lui.Templates
this.SetValue(DateProperty, value);
}
}
-
+
/// Gets or sets the background list elements.
/// The background list elements.
public int BgListElements
@@ -140,6 +167,9 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Check stack add.
+ /// Fiedler, 06.11.2013.
+ /// The model.
private void CheckStackAdd(AppointmentModel model)
{
int[] intersect = model.IntersectArray(this.Appointments.ToArray());
@@ -207,6 +237,9 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Check stack remove.
+ /// Fiedler, 06.11.2013.
+ /// The model.
private void CheckStackRemove(AppointmentModel model)
{
int stackIndex = -1;
@@ -247,6 +280,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Draw stack.
+ /// Fiedler, 06.11.2013.
+ /// The new model.
+ /// The stack.
private void DrawStack(AppointmentModel newModel, List stack)
{
for (int i = 0; i < stack.Count; i++)
@@ -262,6 +299,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Manipulate application canvas.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// Zero-based index of the stack.
private void ManipulateAppCanvas(AppointmentModel model, int stackIndex)
{
if (stackIndex < this.stacks.Count)
@@ -270,6 +311,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Manipulate application canvas.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// The list.
private void ManipulateAppCanvas(AppointmentModel model, List list)
{
int index = list.IndexOf(model);
@@ -280,6 +325,11 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Manipulate application canvas.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// Zero-based index of the.
+ /// Number of.
private void ManipulateAppCanvas(AppointmentModel model, int index, int count)
{
AppointmentCanvas can = null;
@@ -298,6 +348,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Draw application.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// (Optional) Zero-based index of the stack.
private void DrawApp(AppointmentModel model, int stackIndex = -1)
{
if (stackIndex >= 0)
@@ -310,6 +364,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
}
}
+ /// Draw application.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// (Optional) The stack.
private void DrawApp(AppointmentModel model, List stack = null)
{
AppointmentCanvas newCan = new AppointmentCanvas(model, this.Date);
@@ -329,6 +387,9 @@ namespace CampusAppWP8.Utility.Lui.Templates
this.UserCanvas.Children.Add(newCan);
}
+ /// Un draw application.
+ /// Fiedler, 06.11.2013.
+ /// The model.
private void UnDrawApp(AppointmentModel model)
{
int index = -1;