TimeTableWeek done
This commit is contained in:
@@ -1,7 +1,13 @@
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="AppointmentFeed.cs" company="BTU/IIT">
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>Fiedler</author>
|
||||
// <date>06.11.2013</date>
|
||||
// <summary>Implements the appointment feed class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
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;
|
||||
|
||||
/// <summary> An appointment feed. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <seealso cref="T:CampusAppWP8.Model.XmlModel{CampusAppWP8.Model.TimeTable.AppointmentListModel}"/>
|
||||
public class AppointmentFeed : XmlModel<AppointmentListModel>
|
||||
{
|
||||
|
||||
/// <summary> Initializes a new instance of the AppointmentFeed class. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="autoLoad"> (Optional) the automatic load. </param>
|
||||
public AppointmentFeed(bool autoLoad = true)
|
||||
: base(ModelType.File, Constants.FileAppointments_Name)
|
||||
{
|
||||
@@ -28,6 +39,10 @@ namespace CampusAppWP8.Feed.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Check is model up to date. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
/// <returns> true if it succeeds, false if it fails. </returns>
|
||||
private bool CheckIsModelUpToDate(AppointmentListModel model)
|
||||
{
|
||||
bool retValue = true;
|
||||
@@ -40,6 +55,11 @@ namespace CampusAppWP8.Feed.TimeTable
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary> Check is file up to date on load. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
/// <param name="info"> The information. </param>
|
||||
/// <returns> true if it succeeds, false if it fails. </returns>
|
||||
private bool CheckIsFileUpToDateOnLoad(AppointmentListModel model, FileInfo info)
|
||||
{
|
||||
bool retValue = true;
|
||||
@@ -47,6 +67,11 @@ namespace CampusAppWP8.Feed.TimeTable
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary> Check is file up to date on save. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
/// <param name="info"> The information. </param>
|
||||
/// <returns> true if it succeeds, false if it fails. </returns>
|
||||
private bool CheckIsFileUpToDateOnSave(AppointmentListModel model, FileInfo info)
|
||||
{
|
||||
bool retValue = true;
|
||||
@@ -66,6 +91,10 @@ namespace CampusAppWP8.Feed.TimeTable
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary> Deserialize model. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="modelData"> Information describing the model. </param>
|
||||
/// <returns> true if it succeeds, false if it fails. </returns>
|
||||
protected override bool DeserializeModel(byte[] modelData)
|
||||
{
|
||||
if (this.Model == null)
|
||||
@@ -91,6 +120,9 @@ namespace CampusAppWP8.Feed.TimeTable
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary> Gets the serialize model. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <returns> A byte[]. </returns>
|
||||
protected override byte[] SerializeModel()
|
||||
{
|
||||
List<byte> retValue = new List<byte>();
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary>
|
||||
/// Model for appointments.
|
||||
/// </summary>
|
||||
/// <summary> Model for appointments. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
public class AppointmentModel
|
||||
{
|
||||
/// <summary> The ical object. </summary>
|
||||
private ICalObject icalObj = null;
|
||||
|
||||
|
||||
/// <summary> Executes the appointment click action. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="sender"> The sender. </param>
|
||||
public delegate void OnAppointmentClick(AppointmentModel sender);
|
||||
/// <summary> Occurs when On Click. </summary>
|
||||
public event OnAppointmentClick OnClick = null;
|
||||
|
||||
/// <summary>Initializes a new instance of the <see cref="AppointmentModel" /> class. </summary>
|
||||
|
||||
/// <summary> Initializes a new instance of the <see cref="AppointmentModel" /> class. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
public AppointmentModel()
|
||||
{
|
||||
this.icalObj = new ICalObject();
|
||||
@@ -46,11 +45,16 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
this.icalObj.AddProperty(newProdID);
|
||||
}
|
||||
|
||||
/// <summary> Initializes a new instance of the AppointmentModel class. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="icsData"> Information describing the ics. </param>
|
||||
public AppointmentModel(string icsData) : this()
|
||||
{
|
||||
this.icalObj = ICSManager.ImportFromICS(icsData);
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the calendar object. </summary>
|
||||
/// <value> The calendar object. </value>
|
||||
public ICalObject CalendarObj
|
||||
{
|
||||
get
|
||||
@@ -64,6 +68,11 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Is date. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="date"> The date Date/Time. </param>
|
||||
/// <param name="daySpan"> (Optional) the day span. </param>
|
||||
/// <returns> An int. </returns>
|
||||
public int IsDate(DateTime date, int daySpan = 0)
|
||||
{
|
||||
int retValue = -1;
|
||||
@@ -92,6 +101,10 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary> Intersects the given model. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
/// <returns> true if it succeeds, false if it fails. </returns>
|
||||
public bool Intersect(AppointmentModel model)
|
||||
{
|
||||
bool retValue = false;
|
||||
@@ -112,6 +125,10 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary> Intersects the given model. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="modelList"> List of models. </param>
|
||||
/// <returns> true if it succeeds, false if it fails. </returns>
|
||||
public int Intersect(AppointmentModel[] modelList)
|
||||
{
|
||||
int retValue = -1;
|
||||
@@ -127,6 +144,10 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary> Intersect array. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="modelList"> List of models. </param>
|
||||
/// <returns> An int[]. </returns>
|
||||
public int[] IntersectArray(AppointmentModel[] modelList)
|
||||
{
|
||||
List<int> retValue = new List<int>();
|
||||
@@ -142,6 +163,9 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
return retValue.ToArray();
|
||||
}
|
||||
|
||||
/// <summary> Sets a value. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="value"> The value. </param>
|
||||
public void SetValue(object value)
|
||||
{
|
||||
ICalObject vevent = this.GetVEventObj(true);
|
||||
@@ -149,6 +173,10 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
vevent.AddProperty(value);
|
||||
}
|
||||
|
||||
/// <summary> Gets a value. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="propertyName"> Name of the property. </param>
|
||||
/// <returns> The value. </returns>
|
||||
public object GetValue(string propertyName)
|
||||
{
|
||||
object retValue = this.GetVEventObj().GetProperty(propertyName);
|
||||
@@ -156,11 +184,18 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary> Gets total hours. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <returns> The total hours. </returns>
|
||||
public double GetTotalHours()
|
||||
{
|
||||
return this.End.Subtract(this.Start).TotalHours;
|
||||
}
|
||||
|
||||
/// <summary> Gets total hours. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="date"> The date Date/Time. </param>
|
||||
/// <returns> The total hours. </returns>
|
||||
public double GetTotalHours(DateTime date)
|
||||
{
|
||||
double retValue = 0;
|
||||
@@ -195,6 +230,13 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/// <summary> Gets v event object. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <exception cref="NullReferenceException">
|
||||
/// Thrown when a value was unexpectedly null.
|
||||
/// </exception>
|
||||
/// <param name="create"> (Optional) the create. </param>
|
||||
/// <returns> The v event object. </returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary> Raises the canvas click event. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="sender"> Source of the event. </param>
|
||||
/// <param name="e"> Event information to send to registered event handlers. </param>
|
||||
public void OnCanvasClick(object sender, EventArgs e)
|
||||
{
|
||||
if (this.OnClick != null)
|
||||
@@ -228,6 +274,9 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
}
|
||||
|
||||
// ------------------------------------------------------
|
||||
|
||||
/// <summary> Gets the title. </summary>
|
||||
/// <value> The title. </value>
|
||||
public string Title
|
||||
{
|
||||
get
|
||||
@@ -239,6 +288,8 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the date. </summary>
|
||||
/// <value> The date. </value>
|
||||
public string Date
|
||||
{
|
||||
get
|
||||
@@ -265,6 +316,8 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the location. </summary>
|
||||
/// <value> The location. </value>
|
||||
public string Location
|
||||
{
|
||||
get
|
||||
@@ -283,6 +336,8 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the description. </summary>
|
||||
/// <value> The description. </value>
|
||||
public string Description
|
||||
{
|
||||
get
|
||||
@@ -301,6 +356,8 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the Date/Time of the start. </summary>
|
||||
/// <value> The start. </value>
|
||||
public DateTime Start
|
||||
{
|
||||
get
|
||||
@@ -317,6 +374,8 @@ namespace CampusAppWP8.Model.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets the Date/Time of the end. </summary>
|
||||
/// <value> The end. </value>
|
||||
public DateTime End
|
||||
{
|
||||
get
|
||||
|
||||
@@ -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;
|
||||
|
||||
/// <summary> A time table. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <seealso cref="T:Microsoft.Phone.Controls.PhoneApplicationPage"/>
|
||||
public partial class TimeTable : PhoneApplicationPage
|
||||
{
|
||||
/// <summary> The setting automatic scroll to hour. </summary>
|
||||
public static int Setting_AutoScrollToHour = 7;
|
||||
public static int Setting_VisualScale = 0; //0 - small, 1 - medium, 2 - large UNUSED ATM
|
||||
/// <summary> 0 - small, 1 - medium, 2 - large UNUSED ATM. </summary>
|
||||
public static int Setting_VisualScale = 0;
|
||||
/// <summary> The setting hour spacing. </summary>
|
||||
public static double Setting_Hour_Spacing = 40;
|
||||
/// <summary> Height of the setting view. </summary>
|
||||
public static double Setting_View_Height = Setting_Hour_Spacing * 24;
|
||||
/// <summary> Zero-based index of the setting maximum z coordinate. </summary>
|
||||
public static int Setting_Max_Z_Index = 10;
|
||||
/// <summary> The setting z coordinate spacing. </summary>
|
||||
public static double Setting_Z_Spacing = 10;
|
||||
/// <summary> List of colors of the setting priorities. </summary>
|
||||
public static SolidColorBrush[] Setting_Priority_Colors = new SolidColorBrush[]
|
||||
{
|
||||
new SolidColorBrush(Colors.Green),
|
||||
@@ -45,8 +46,11 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
};
|
||||
|
||||
|
||||
/// <summary> The feed. </summary>
|
||||
private static AppointmentFeed feed = null;
|
||||
|
||||
/// <summary> Gets the feed. </summary>
|
||||
/// <value> The feed. </value>
|
||||
public static AppointmentFeed Feed
|
||||
{
|
||||
get
|
||||
@@ -60,6 +64,8 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Initialises the feed. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
public static void InitFeed()
|
||||
{
|
||||
if(TimeTable.feed == null)
|
||||
@@ -70,6 +76,8 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Executes the load failed action. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
private static void OnLoadFailed()
|
||||
{
|
||||
if (TimeTable.feed.Model == null)
|
||||
|
||||
@@ -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<AppointmentModel>[] tempList = new List<AppointmentModel>[5];
|
||||
List<AppointmentModel> tempList = new List<AppointmentModel>();
|
||||
|
||||
/*
|
||||
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<AppointmentModel>();
|
||||
}
|
||||
*/
|
||||
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<AppointmentModel> newList = new List<AppointmentModel>();
|
||||
//newList.Add(tempList[day][i]);
|
||||
//this.itemPages[index].Stacks[day].Add(newList);
|
||||
newList.Add(tempList[i]);
|
||||
this.itemPages[index].Stacks.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++)
|
||||
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<AppointmentModel> newList = new List<AppointmentModel>();
|
||||
//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<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 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();
|
||||
|
||||
@@ -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;
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
// <copyright file="WeekViewPageItem.cs" company="BTU/IIT">
|
||||
// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
|
||||
// </copyright>
|
||||
// <author>Fiedler</author>
|
||||
// <date>06.11.2013</date>
|
||||
// <summary>Implements the week view page item class</summary>
|
||||
//-----------------------------------------------------------------------
|
||||
namespace CampusAppWP8.Pages.TimeTable
|
||||
{
|
||||
using System;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using CampusAppWP8.Model.TimeTable;
|
||||
using CampusAppWP8.Utility.Lui.Templates;
|
||||
|
||||
/// <summary> A week view page item. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <seealso cref="T:System.ComponentModel.INotifyPropertyChanged"/>
|
||||
public class WeekViewPageItem : INotifyPropertyChanged
|
||||
{
|
||||
/// <summary> from dt Date/Time. </summary>
|
||||
private DateTime fromDT;
|
||||
/// <summary> to dt Date/Time. </summary>
|
||||
private DateTime toDT;
|
||||
/// <summary> The days. </summary>
|
||||
private int days;
|
||||
/// <summary> The week string. </summary>
|
||||
private string weekStr = string.Empty;
|
||||
/// <summary> The week number. </summary>
|
||||
private int weekNumber = -1;
|
||||
/// <summary> The week view. </summary>
|
||||
private WeekView weekView = null;
|
||||
/// <summary> List of appointments. </summary>
|
||||
private ObservableCollection<AppointmentModel> appointmentList = null;
|
||||
|
||||
/// <summary> Tritt ein, wenn sich ein Eigenschaftswert ändert. </summary>
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
|
||||
/// <summary> Initializes a new instance of the WeekViewPageItem class. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="from"> from Date/Time. </param>
|
||||
/// <param name="str"> The. </param>
|
||||
/// <param name="number"> Number of. </param>
|
||||
/// <param name="days"> The days. </param>
|
||||
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<AppointmentModel>();
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the Date/Time of from dt. </summary>
|
||||
/// <value> from dt. </value>
|
||||
public DateTime FromDT
|
||||
{
|
||||
get
|
||||
@@ -47,6 +69,8 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the Date/Time of to dt. </summary>
|
||||
/// <value> to dt. </value>
|
||||
public DateTime ToDT
|
||||
{
|
||||
get
|
||||
@@ -61,6 +85,8 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the week string. </summary>
|
||||
/// <value> The week string. </value>
|
||||
public string WeekStr
|
||||
{
|
||||
get
|
||||
@@ -75,6 +101,8 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the week nr. </summary>
|
||||
/// <value> The week nr. </value>
|
||||
public int WeekNr
|
||||
{
|
||||
get
|
||||
@@ -89,6 +117,8 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the view. </summary>
|
||||
/// <value> The view. </value>
|
||||
public WeekView View
|
||||
{
|
||||
get
|
||||
@@ -103,6 +133,8 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets a list of appointments. </summary>
|
||||
/// <value> A List of appointments. </value>
|
||||
public ObservableCollection<AppointmentModel> AppointmentList
|
||||
{
|
||||
get
|
||||
@@ -117,6 +149,9 @@ namespace CampusAppWP8.Pages.TimeTable
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Notifies a property changed. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="info"> The information. </param>
|
||||
private void NotifyPropertyChanged(string info)
|
||||
{
|
||||
if (this.PropertyChanged != null)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
|
||||
/// <summary> A week view. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <seealso cref="T:System.Windows.Controls.UserControl"/>
|
||||
public partial class WeekView : UserControl
|
||||
{
|
||||
/// <summary> The date from property. </summary>
|
||||
public static readonly DependencyProperty DateFromProperty = DependencyProperty.Register("DateFrom", typeof(DateTime), typeof(WeekView), new PropertyMetadata(new DateTime(0), OnDateFromChanged));
|
||||
/// <summary> The date to property. </summary>
|
||||
public static readonly DependencyProperty DateToProperty = DependencyProperty.Register("DateTo", typeof(DateTime), typeof(WeekView), new PropertyMetadata(new DateTime(0)));
|
||||
/// <summary> The days property. </summary>
|
||||
public static readonly DependencyProperty DaysProperty = DependencyProperty.Register("Days", typeof(int), typeof(WeekView), new PropertyMetadata(5));
|
||||
/// <summary> The appointments property. </summary>
|
||||
public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(ObservableCollection<AppointmentModel>), typeof(WeekView), new PropertyMetadata(null, OnAppointmentsChanged));
|
||||
/// <summary> The week name property. </summary>
|
||||
public static readonly DependencyProperty WeekNameProperty = DependencyProperty.Register("WeekName", typeof(string), typeof(WeekView), new PropertyMetadata("T-Woche"));
|
||||
/// <summary> The week number property. </summary>
|
||||
public static readonly DependencyProperty WeekNumberProperty = DependencyProperty.Register("WeekNumber", typeof(int), typeof(WeekView), new PropertyMetadata(-1));
|
||||
|
||||
/// <summary> List of borders. </summary>
|
||||
private List<Border> borderList = new List<Border>();
|
||||
/// <summary> List of days. </summary>
|
||||
private List<WeekViewDay> dayList = new List<WeekViewDay>();
|
||||
|
||||
/// <summary> The time strings. </summary>
|
||||
private string[] timeStrings = new string[24];
|
||||
/// <summary> The monitor strings. </summary>
|
||||
private string[] monStrings = new string[24];
|
||||
|
||||
|
||||
/// <summary> Initializes a new instance of the WeekView class. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
public WeekView()
|
||||
{
|
||||
this.InitializeComponent();
|
||||
@@ -46,6 +55,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
this.InitLayout();
|
||||
}
|
||||
|
||||
/// <summary> Raises the dependency property changed event. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="o"> The DependencyObject to process. </param>
|
||||
/// <param name="e"> Event information to send to registered event handlers. </param>
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Raises the dependency property changed event. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="o"> The DependencyObject to process. </param>
|
||||
/// <param name="e"> Event information to send to registered event handlers. </param>
|
||||
private static void OnAppointmentsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.NewValue != null)
|
||||
@@ -77,6 +98,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Raises the notify collection changed event. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="s"> The object to process. </param>
|
||||
/// <param name="e"> Event information to send to registered event handlers. </param>
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Clears the days. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
private void ClearDays()
|
||||
{
|
||||
for (int i = 0; i < this.dayList.Count; i++)
|
||||
{
|
||||
this.dayList[i].Appointments.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Seperate appointments. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="list"> The list. </param>
|
||||
private void SeperateAppointments(ObservableCollection<AppointmentModel> list)
|
||||
{
|
||||
foreach (AppointmentModel m in list)
|
||||
@@ -103,9 +145,13 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Seperate appointments. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
/// <param name="action"> The action. </param>
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the Date/Time of the date from. </summary>
|
||||
/// <value> The date from. </value>
|
||||
public DateTime DateFrom
|
||||
{
|
||||
get
|
||||
@@ -134,6 +182,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the Date/Time of the date to. </summary>
|
||||
/// <value> The date to. </value>
|
||||
public DateTime DateTo
|
||||
{
|
||||
get
|
||||
@@ -147,6 +197,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the days. </summary>
|
||||
/// <value> The days. </value>
|
||||
public int Days
|
||||
{
|
||||
get
|
||||
@@ -160,6 +212,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the appointments. </summary>
|
||||
/// <value> The appointments. </value>
|
||||
public ObservableCollection<AppointmentModel> Appointments
|
||||
{
|
||||
get
|
||||
@@ -173,6 +227,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the name of the week. </summary>
|
||||
/// <value> The name of the week. </value>
|
||||
public string WeekName
|
||||
{
|
||||
get
|
||||
@@ -187,6 +243,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the week number. </summary>
|
||||
/// <value> The week number. </value>
|
||||
public int WeekNumber
|
||||
{
|
||||
get
|
||||
@@ -200,6 +258,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Sets column background. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="column"> The column. </param>
|
||||
/// <param name="brush"> (Optional) the brush. </param>
|
||||
public void SetColumnBackground(int column, Brush brush = null)
|
||||
{
|
||||
if (column < this.borderList.Count())
|
||||
@@ -208,6 +270,20 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Clears the background. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
public void ClearBackground()
|
||||
{
|
||||
SolidColorBrush newBrush = new SolidColorBrush(Colors.Transparent);
|
||||
|
||||
for (int i = 0; i < this.borderList.Count; i++)
|
||||
{
|
||||
this.borderList[i].Background = newBrush;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Initialises the layout. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
private void InitLayout()
|
||||
{
|
||||
for (int i = 0; i < 24; i++)
|
||||
@@ -231,6 +307,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
this.TimeList.ItemsSource = this.timeStrings;
|
||||
}
|
||||
|
||||
/// <summary> Automatic scroll. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="sender"> Source of the event. </param>
|
||||
/// <param name="e"> Routed event information. </param>
|
||||
private void AutoScroll(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.TheScrollView.ScrollToVerticalOffset((TimeTable.Setting_Hour_Spacing * 7) + 2);
|
||||
|
||||
@@ -23,17 +23,27 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Data;
|
||||
using CampusAppWP8.Model.TimeTable;
|
||||
|
||||
|
||||
/// <summary> A week view day. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <seealso cref="T:System.Windows.Controls.UserControl"/>
|
||||
public partial class WeekViewDay : UserControl
|
||||
{
|
||||
/// <summary> The background list elements property. </summary>
|
||||
public static readonly DependencyProperty BgListElementsProperty = DependencyProperty.Register("BgListElements", typeof(int), typeof(WeekViewDay), new PropertyMetadata(null));
|
||||
|
||||
/// <summary> The background list element height property. </summary>
|
||||
public static readonly DependencyProperty BgListElementHeightProperty = DependencyProperty.Register("BgListElementHeight", typeof(double), typeof(WeekViewDay), new PropertyMetadata(null));
|
||||
|
||||
/// <summary> The date property. </summary>
|
||||
public static readonly DependencyProperty DateProperty = DependencyProperty.Register("Date", typeof(DateTime), typeof(WeekViewDay), new PropertyMetadata(DateTime.Today));
|
||||
|
||||
/// <summary> The appointments property. </summary>
|
||||
public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(ObservableCollection<AppointmentModel>), typeof(WeekViewDay), new PropertyMetadata(null, OnAppointmentsChanged));
|
||||
|
||||
/// <summary> The stacks. </summary>
|
||||
private List<List<AppointmentModel>> stacks = new List<List<AppointmentModel>>();
|
||||
|
||||
|
||||
/// <summary> Initializes a new instance of the WeekViewDay class. </summary>
|
||||
/// <remarks> Fiedler, 22.10.2013. </remarks>
|
||||
public WeekViewDay()
|
||||
@@ -43,6 +53,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
this.InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary> Raises the dependency property changed event. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="o"> The DependencyObject to process. </param>
|
||||
/// <param name="e"> Event information to send to registered event handlers. </param>
|
||||
private static void OnAppointmentsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
|
||||
{
|
||||
if(e.NewValue != null)
|
||||
@@ -56,6 +70,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Raises the notify collection changed event. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="s"> The object to process. </param>
|
||||
/// <param name="e"> Event information to send to registered event handlers. </param>
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the appointments. </summary>
|
||||
/// <value> The appointments. </value>
|
||||
public ObservableCollection<AppointmentModel> Appointments
|
||||
{
|
||||
get
|
||||
@@ -87,6 +112,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Gets or sets the Date/Time of the date. </summary>
|
||||
/// <value> The date. </value>
|
||||
public DateTime Date
|
||||
{
|
||||
get
|
||||
@@ -99,7 +126,7 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
this.SetValue(DateProperty, value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary> Gets or sets the background list elements. </summary>
|
||||
/// <value> The background list elements. </value>
|
||||
public int BgListElements
|
||||
@@ -140,6 +167,9 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Check stack add. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
private void CheckStackAdd(AppointmentModel model)
|
||||
{
|
||||
int[] intersect = model.IntersectArray(this.Appointments.ToArray<AppointmentModel>());
|
||||
@@ -207,6 +237,9 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Check stack remove. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
private void CheckStackRemove(AppointmentModel model)
|
||||
{
|
||||
int stackIndex = -1;
|
||||
@@ -247,6 +280,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Draw stack. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="newModel"> The new model. </param>
|
||||
/// <param name="stack"> The stack. </param>
|
||||
private void DrawStack(AppointmentModel newModel, List<AppointmentModel> stack)
|
||||
{
|
||||
for (int i = 0; i < stack.Count; i++)
|
||||
@@ -262,6 +299,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Manipulate application canvas. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
/// <param name="stackIndex"> Zero-based index of the stack. </param>
|
||||
private void ManipulateAppCanvas(AppointmentModel model, int stackIndex)
|
||||
{
|
||||
if (stackIndex < this.stacks.Count)
|
||||
@@ -270,6 +311,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Manipulate application canvas. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
/// <param name="list"> The list. </param>
|
||||
private void ManipulateAppCanvas(AppointmentModel model, List<AppointmentModel> list)
|
||||
{
|
||||
int index = list.IndexOf(model);
|
||||
@@ -280,6 +325,11 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Manipulate application canvas. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
/// <param name="index"> Zero-based index of the. </param>
|
||||
/// <param name="count"> Number of. </param>
|
||||
private void ManipulateAppCanvas(AppointmentModel model, int index, int count)
|
||||
{
|
||||
AppointmentCanvas can = null;
|
||||
@@ -298,6 +348,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Draw application. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
/// <param name="stackIndex"> (Optional) Zero-based index of the stack. </param>
|
||||
private void DrawApp(AppointmentModel model, int stackIndex = -1)
|
||||
{
|
||||
if (stackIndex >= 0)
|
||||
@@ -310,6 +364,10 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Draw application. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
/// <param name="stack"> (Optional) The stack. </param>
|
||||
private void DrawApp(AppointmentModel model, List<AppointmentModel> stack = null)
|
||||
{
|
||||
AppointmentCanvas newCan = new AppointmentCanvas(model, this.Date);
|
||||
@@ -329,6 +387,9 @@ namespace CampusAppWP8.Utility.Lui.Templates
|
||||
this.UserCanvas.Children.Add(newCan);
|
||||
}
|
||||
|
||||
/// <summary> Un draw application. </summary>
|
||||
/// <remarks> Fiedler, 06.11.2013. </remarks>
|
||||
/// <param name="model"> The model. </param>
|
||||
private void UnDrawApp(AppointmentModel model)
|
||||
{
|
||||
int index = -1;
|
||||
|
||||
Reference in New Issue
Block a user