diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
index 698e02d7..00e17b16 100644
--- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
+++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj
@@ -102,6 +102,7 @@
App.xaml
+
@@ -142,6 +143,7 @@
AppointmentEdit.xaml
+
TimeTableDay.xaml
@@ -152,6 +154,8 @@
TimeTableWeek.xaml
+
+
@@ -249,6 +253,9 @@
WeekViewPivotHeader.xaml
+
+ AppointmentCanvas.xaml
+
MultiValueTextBlock.xaml
@@ -535,6 +542,7 @@
Designer
MSBuild:Compile
+
Designer
MSBuild:Compile
diff --git a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs
new file mode 100644
index 00000000..50259e02
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs
@@ -0,0 +1,171 @@
+//-----------------------------------------------------------------------
+//
+// 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;
+ using System.Text.RegularExpressions;
+ using CampusAppWP8.Model;
+ using CampusAppWP8.Resources;
+ using CampusAppWP8.Utility;
+ using CampusAppWP8.Model.TimeTable;
+ using CampusAppWPortalLib8.Model;
+
+ /// An appointment feed.
+ /// Fiedler, 06.11.2013.
+ ///
+ public class AppointmentFeed : XmlModel
+ {
+ private TimeSpan span = TimeSpan.Zero;
+
+ /// 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)
+ {
+ this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
+ this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
+ this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
+
+ if (autoLoad == true)
+ {
+ this.LoadData();
+ }
+ }
+
+ public AppointmentFeed(TimeSpan span, bool autoLoad = true)
+ : base(ModelType.File, Constants.FileAppointments_Name)
+ {
+ this.span = span;
+
+ this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDateOnLoad);
+ this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDateOnSave);
+ this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate);
+
+ if (autoLoad == true)
+ {
+ this.LoadData();
+ }
+ }
+
+ /// 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;
+
+ if (model == null)
+ {
+ retValue = false;
+ }
+
+ 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;
+
+ 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;
+
+ if ((info == null)
+ || (info.Exists == false)
+ || (info.Length == 0))
+ {
+ retValue = false;
+ }
+
+ if (model != null && model.HasChanged(true))
+ {
+ retValue = false;
+ }
+
+ 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)
+ {
+ this.Model = new AppointmentListModel();
+ }
+
+ string temp = Encoding.UTF8.GetString(modelData, 0, modelData.Length);
+ string[] appStr = Regex.Split(temp, "");
+
+ for (int i = 0; i < appStr.Length; i++)
+ {
+ if (appStr[i].Length > 0)
+ {
+ appStr[i] = appStr[i].Replace("", string.Empty);
+
+ AppointmentModel newAppModel = new AppointmentModel(appStr[i]);
+
+ if (this.span.Equals(TimeSpan.Zero))
+ {
+ this.Model.Appointments.Add(newAppModel);
+ }
+ else
+ {
+ if (newAppModel.IsInRange(DateTime.Today, this.span))
+ {
+ this.Model.Appointments.Add(newAppModel);
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+ /// Gets the serialize model.
+ /// Fiedler, 06.11.2013.
+ /// A byte[].
+ protected override byte[] SerializeModel()
+ {
+ List retValue = new List();
+
+ if (this.Model != null)
+ {
+ for (int i = 0; i < this.Model.Appointments.Count; i++)
+ {
+ retValue.AddRange(Encoding.UTF8.GetBytes(""));
+ retValue.AddRange(ICSManager.ExportToICSByte(this.Model.Appointments[i].CalendarObj));
+ retValue.AddRange(Encoding.UTF8.GetBytes(""));
+ }
+ }
+
+ return retValue.ToArray();
+ }
+ }
+}
diff --git a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentListModel.cs b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentListModel.cs
index 19feec4c..34db3d0d 100644
--- a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentListModel.cs
+++ b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentListModel.cs
@@ -24,17 +24,17 @@ namespace CampusAppWP8.Model.TimeTable
///
/// Model for appointments.
///
- [XmlRoot("root")]
public class AppointmentListModel
{
private ObservableCollection appointmentList;
private int hasChangedIndex = -1;
+ private bool hasChanged = false;
/// Initializes a new instance of the class.
public AppointmentListModel()
{
this.appointmentList = new ObservableCollection();
- this.appointmentList.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnCollectionChanged);
+ this.appointmentList.CollectionChanged += this.OnCollectionChanged;
}
// for testing
@@ -50,7 +50,6 @@ namespace CampusAppWP8.Model.TimeTable
}
}
-
public ObservableCollection Appointments
{
get
@@ -60,7 +59,17 @@ namespace CampusAppWP8.Model.TimeTable
set
{
+ if(this.appointmentList != null)
+ {
+ this.appointmentList.CollectionChanged -= this.OnCollectionChanged;
+ }
+
this.appointmentList = value;
+
+ if(this.appointmentList != null)
+ {
+ this.appointmentList.CollectionChanged += this.OnCollectionChanged;
+ }
}
}
@@ -74,12 +83,28 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ public bool HasChanged(bool reset = false)
+ {
+ bool retValue = false;
+
+ retValue = this.hasChanged;
+
+ if(reset == true)
+ {
+ this.hasChanged = false;
+ }
+
+ return retValue;
+ }
+
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
{
this.hasChangedIndex = e.NewStartingIndex;
}
+
+ this.hasChanged = true;
}
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs
index b4aaaca5..912fab57 100644
--- a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs
+++ b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs
@@ -10,35 +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.
- ///
- [XmlRoot("root")]
+ /// Model for appointments.
+ /// Fiedler, 06.11.2013.
public class AppointmentModel
{
- /// The Visual object.
- //private Rectangle rect = null;
- //private Canvas canvas = null;
- //private double offsetY = 0;
- //private double height = 0;
- //private double width = 100;
-
+ /// The ical object.
private ICalObject icalObj = null;
- //private ICalObject eventICalObj = 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();
@@ -53,18 +43,36 @@ namespace CampusAppWP8.Model.TimeTable
this.icalObj.Header = newBegin;
this.icalObj.AddProperty(newVersion);
this.icalObj.AddProperty(newProdID);
-
- //this.rect = new Rectangle();
- //this.canvas = new Canvas();
- //this.canvas.DoubleTap += new EventHandler(this.OnCanvasClick);
- //this.canvas.SizeChanged += new SizeChangedEventHandler(this.OnCanvasSizeChanged);
}
+ /// 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
+ {
+ return this.icalObj;
+ }
+
+ set
+ {
+ this.icalObj = value;
+ }
+ }
+
+ /// 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;
@@ -93,6 +101,27 @@ namespace CampusAppWP8.Model.TimeTable
return retValue;
}
+ /// Query if 'date' is in range.
+ /// Fiedler, 11.11.2013.
+ /// The date Date/Time.
+ /// The span.
+ /// true if in range, false if not.
+ public bool IsInRange(DateTime date, TimeSpan span)
+ {
+ bool retValue = false;
+
+ if ((this.Start.Subtract(date) <= span) || (this.End.Subtract(date) <= span))
+ {
+ retValue = true;
+ }
+
+ 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;
@@ -113,6 +142,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;
@@ -128,6 +161,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();
@@ -143,6 +180,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);
@@ -150,95 +190,70 @@ namespace CampusAppWP8.Model.TimeTable
vevent.AddProperty(value);
}
- public Canvas GetCanvas(double width, double hourSpacing, DateTime date)
+ /// Gets a value.
+ /// Fiedler, 06.11.2013.
+ /// Name of the property.
+ /// The value.
+ public object GetValue(string propertyName)
{
- Canvas retValue = new Canvas();
- //retValue.DoubleTap += new EventHandler()
- retValue.Tag = this;
-
- if (this.End.Date.Equals(this.Start.Date) == false)
- {
- DateTime realDate = date.Date;
-
- if (realDate.Equals(this.Start.Date))
- {
- TimeSpan span = this.Start.Date.AddDays(1).Subtract(this.Start);
- retValue.Height = span.TotalHours * hourSpacing;
- retValue.Margin = new Thickness(0, (hourSpacing * this.Start.TimeOfDay.TotalHours), 0, 0);
- }
- else if (realDate.Equals(this.End.Date))
- {
- retValue.Height = this.End.TimeOfDay.TotalHours * hourSpacing;
- }
- else
- {
- retValue.Height = hourSpacing * 24;
- }
- }
- else
- {
- TimeSpan span = this.End.Subtract(this.Start);
- retValue.Height = span.TotalHours * hourSpacing;
- retValue.Margin = new Thickness(0, (hourSpacing * this.Start.TimeOfDay.TotalHours), 0, 0);
- }
-
- retValue.Width = width;
-
- this.CreateRect(retValue);
- this.CreateContent(retValue, hourSpacing);
+ object retValue = this.GetVEventObj().GetProperty(propertyName);
return retValue;
}
- private void CreateRect(Canvas can)
+ /// Gets total hours.
+ /// Fiedler, 06.11.2013.
+ /// The total hours.
+ public double GetTotalHours()
{
-// can.Children.Clear();
-
- Rectangle rect = new Rectangle();
- rect.Width = can.Width;
- rect.Height = can.Height;
-
- rect.StrokeThickness = 1;
- rect.Stroke = new SolidColorBrush(Colors.DarkGray);
- rect.Fill = new SolidColorBrush(Colors.Green);
- rect.RadiusX = 5;
- rect.RadiusY = 5;
-
- can.Children.Add(rect);
+ return this.End.Subtract(this.Start).TotalHours;
}
- private void CreateContent(Canvas can, double hourSpacing)
+ /// Gets total hours.
+ /// Fiedler, 06.11.2013.
+ /// The date Date/Time.
+ /// The total hours.
+ public double GetTotalHours(DateTime date)
{
- if (this.icalObj != null)
+ double retValue = 0;
+
+ if (date.Date.Equals(this.Start.Date))
{
- ICalObject eventObj = this.GetVEventObj();
- Summary title = eventObj.GetProperty(ICSTag.SUMMARY) as Summary;
-
- TextBlock txtTitle = new TextBlock();
- txtTitle.FontSize = hourSpacing / 3;
- txtTitle.FontWeight = FontWeights.Bold;
- txtTitle.TextWrapping = TextWrapping.Wrap;
- txtTitle.Width = can.Width - 4.0;
- txtTitle.SetValue(Canvas.LeftProperty, 3.0);
- txtTitle.SetValue(Canvas.TopProperty, 3.0);
-
- if (can.Height >= ((hourSpacing / 2)))
+ if (this.End.Date.Equals(this.Start.Date))
{
- txtTitle.Margin = new Thickness(0, -2, 0, 0);
- txtTitle.Text = title.Value;
+ retValue = this.GetTotalHours();
}
else
{
- txtTitle.Height = can.Height;
- txtTitle.VerticalAlignment = VerticalAlignment.Center;
- txtTitle.Margin = new Thickness(0, -10, 0, 0);
- txtTitle.Text = "...";
+ retValue = date.Date.AddDays(1).Subtract(this.Start).TotalHours;
}
-
- can.Children.Add(txtTitle);
}
+ else if (date.Date.Equals(this.End.Date))
+ {
+ retValue = this.End.Subtract(date.Date).TotalHours;
+ }
+ else
+ {
+ if (this.Start.Date <= date && date <= this.End.Date)
+ {
+ retValue = 24;
+ }
+ else
+ {
+ retValue = 0;
+ }
+ }
+
+ return retValue;
}
+ /// 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;
@@ -262,8 +277,12 @@ namespace CampusAppWP8.Model.TimeTable
return retValue;
}
-/*
- private void OnCanvasClick(object sender, EventArgs e)
+
+ /// 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)
{
@@ -271,12 +290,10 @@ namespace CampusAppWP8.Model.TimeTable
}
}
- private void OnCanvasSizeChanged(object sender, SizeChangedEventArgs e)
- {
-
- }
-*/
// ------------------------------------------------------
+
+ /// Gets the title.
+ /// The title.
public string Title
{
get
@@ -288,6 +305,8 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ /// Gets the date.
+ /// The date.
public string Date
{
get
@@ -314,6 +333,8 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ /// Gets the location.
+ /// The location.
public string Location
{
get
@@ -332,6 +353,8 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ /// Gets the description.
+ /// The description.
public string Description
{
get
@@ -350,6 +373,8 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ /// Gets the Date/Time of the start.
+ /// The start.
public DateTime Start
{
get
@@ -366,6 +391,8 @@ namespace CampusAppWP8.Model.TimeTable
}
}
+ /// Gets the Date/Time of the end.
+ /// The end.
public DateTime End
{
get
diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml
index 06f98638..99b2348a 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml
@@ -276,6 +276,8 @@
+
+
diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs
index 27858c92..972a122b 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs
@@ -17,6 +17,7 @@ namespace CampusAppWP8.Pages
using CampusAppWP8.Feed.Utility;
using CampusAppWP8.File.Places;
using CampusAppWP8.Model.Setting;
+ using CampusAppWP8.Pages.TimeTable;
using CampusAppWP8.Resources;
using CampusAppWP8.Utility;
using CampusAppWP8.Utility.Lui.MessageBoxes;
@@ -58,6 +59,7 @@ namespace CampusAppWP8.Pages
ApplicationBarMenuItem menuItem3 = ApplicationBar.MenuItems[2] as ApplicationBarMenuItem;
ApplicationBarMenuItem menuItem4 = ApplicationBar.MenuItems[3] as ApplicationBarMenuItem;
ApplicationBarMenuItem menuItem5 = ApplicationBar.MenuItems[4] as ApplicationBarMenuItem;
+ ApplicationBarMenuItem menuItem6 = ApplicationBar.MenuItems[5] as ApplicationBarMenuItem;
if (menuItem1 != null)
{
@@ -85,10 +87,22 @@ namespace CampusAppWP8.Pages
}
else
{
+ /*
ApplicationBar.MenuItems.RemoveAt(ApplicationBar.MenuItems.Count - 1);
ApplicationBar.MenuItems.RemoveAt(ApplicationBar.MenuItems.Count - 1);
+ */
+ ApplicationBar.MenuItems.Remove(menuItem3);
+ ApplicationBar.MenuItems.Remove(menuItem4);
}
+ if (menuItem6 != null)
+ {
+ menuItem6.Text = AppResources.TimeTableApp_Title;
+ }
+
+ TimeTable.TimeTable.InitFeed();
+
+
if (!Settings.AppSetting.InitApp)
{
this.InitPlaceFile();
@@ -423,6 +437,8 @@ namespace CampusAppWP8.Pages
}
else
{
+ this.GoToAppointment(nfcContent);
+ /* removed for testing
if (AppSettings.BTUTagDefaultHandler.CampusMap == Settings.AppSetting.TagDefaultHandler)
{
// search for placeId
@@ -439,6 +455,7 @@ namespace CampusAppWP8.Pages
this.ShowBtuTagMessageBox();
}
}
+ */
}
this.ndefId = this.device.SubscribeForMessage(Constants.NCFMessageType_NDEF, this.NDEFHandler);
@@ -450,9 +467,27 @@ namespace CampusAppWP8.Pages
private void GoToCampusMappage(string tagContent)
{
string pid = Wp8StringManager.FilterPlaceIdinNFCResultString(tagContent);
- string urlString = Constants.PathCampusmap_Campusmap;
- urlString += "?" + Constants.ParamModelMap_SearchTermAlias + "=" + pid;
- Uri url = new Uri(urlString as string, UriKind.Relative);
+ string urlString = Constants.PathCampusmap_Campusmap + "?" + Constants.ParamModelMap_SearchTermAlias + "=" + pid;
+ Uri url = new Uri(urlString, UriKind.Relative);
+
+ if (this.Dispatcher != null)
+ {
+ this.Dispatcher.BeginInvoke(new Action(() => NavigationService.Navigate(url)));
+ }
+ else
+ {
+ NavigationService.Navigate(url);
+ }
+ }
+
+ /// Go to appointment.
+ /// Fiedler, 15.11.2013.
+ /// The tag content.
+ private void GoToAppointment(string tagContent)
+ {
+ string pid = Wp8StringManager.FilterPlaceIdinNFCResultString(tagContent);
+ string urlStr = Constants.PathTimeTable_AppointmentEdit + "?" + Constants.ParamPID + "=" + pid;
+ Uri url = new Uri(urlStr, UriKind.Relative);
if (this.Dispatcher != null)
{
@@ -480,6 +515,18 @@ namespace CampusAppWP8.Pages
#endregion
+ private void ApplicationBarMenuItem_Click_1(object sender, EventArgs e)
+ {
+ Uri url = new Uri(Constants.PathTimeTable_Day, UriKind.Relative);
+ NavigationService.Navigate(url);
+ }
+
#endregion
+
+ private void ApplicationBarMenuItem_Click_2(object sender, EventArgs e)
+ {
+ Uri url = new Uri("/Pages/Dev/NFC.xaml", UriKind.Relative);
+ NavigationService.Navigate(url);
+ }
}
}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/Appointment.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/Appointment.xaml.cs
index 156c2612..2fb521e9 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/Appointment.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/Appointment.xaml.cs
@@ -48,7 +48,7 @@ namespace CampusAppWP8.Pages.TimeTable
if (e.NavigationMode == NavigationMode.Back)
{
- TimeTable.AppointmentsModel.Appointments.CollectionChanged -= this.OnListChanged;
+ TimeTable.Feed.Model.Appointments.CollectionChanged -= this.OnListChanged;
this.DataContext = this.appModel;
}
else
@@ -61,10 +61,10 @@ namespace CampusAppWP8.Pages.TimeTable
int appointmentIndex = int.Parse(appointmentIndexStr);
// if the index is in the range of the array
- if ((appointmentIndex >= 0) && (appointmentIndex < TimeTable.AppointmentsModel.Appointments.Count()))
+ if ((appointmentIndex >= 0) && (appointmentIndex < TimeTable.Feed.Model.Appointments.Count()))
{
- this.appModel = TimeTable.AppointmentsModel.Appointments[appointmentIndex];
- this.DataContext = TimeTable.AppointmentsModel.Appointments[appointmentIndex];
+ this.appModel = TimeTable.Feed.Model.Appointments[appointmentIndex];
+ this.DataContext = TimeTable.Feed.Model.Appointments[appointmentIndex];
}
else
{
@@ -93,9 +93,9 @@ namespace CampusAppWP8.Pages.TimeTable
{
if (this.appModel != null)
{
- TimeTable.AppointmentsModel.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged);
+ TimeTable.Feed.Model.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged);
- string urlString = "/Pages/TimeTable/AppointmentEdit.xaml?" + Constants.Param_Appointment_Index + "=" + TimeTable.AppointmentsModel.Appointments.IndexOf(this.appModel);
+ string urlString = "/Pages/TimeTable/AppointmentEdit.xaml?" + Constants.Param_Appointment_Index + "=" + TimeTable.Feed.Model.Appointments.IndexOf(this.appModel);
Uri url = new Uri(urlString, UriKind.Relative);
Page page = App.RootFrame.Content as Page;
@@ -105,7 +105,7 @@ namespace CampusAppWP8.Pages.TimeTable
private void OnClickDelete(object sender, EventArgs e)
{
- TimeTable.AppointmentsModel.Appointments.Remove(this.appModel);
+ TimeTable.Feed.Model.Appointments.Remove(this.appModel);
this.NavigationService.GoBack();
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml
index 6f74a2c0..7bc208a8 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml
@@ -1,4 +1,4 @@
-
-
+
-
-
\ No newline at end of file
+
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs
index 94233db0..952a1922 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs
@@ -16,13 +16,17 @@ namespace CampusAppWP8.Pages.TimeTable
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
+ using CampusAppWP8.File.Places;
using CampusAppWP8.Resources;
using CampusAppWP8.Model.TimeTable;
using CampusAppWP8.Utility;
using CampusAppWP8.Utility.ICSProperties;
+ using CampusAppWP8.Utility.Lui.Page;
- public partial class AppointmentEdit : PhoneApplicationPage
+ public partial class AppointmentEdit : PortraitLandscapePage
{
+ private PlacesFile placeFile = null;
+
private readonly string[] DurationListText = new string[] { "15 Minuten", "30 Minuten", "1 Stunde", "90 Minuten", "2 Stunden", "Ganztägig", "Benutzerdefiniert" };
private readonly string[] RepeatListText = new string[] { "Einmal", "Täglich", "Jeden Mo-Fr", "Wöchentlich", "Monatlich", "Jährlich" };
private readonly string[] AccessClassListText = new string[] { "Öffentlich", "Privat", "Vertraulich" };
@@ -41,6 +45,11 @@ namespace CampusAppWP8.Pages.TimeTable
this.InCategories.ItemsSource = CategoriesListText;
this.InPriority.ItemsSource = PriorityListText;
+ this.placeFile = new PlacesFile();
+ this.placeFile.OnLoaded += this.PlaceFileIsReady;
+ this.placeFile.OnFailedLoad += this.PlaceFileIsFailed;
+ this.placeFile.LoadData();
+
ApplicationBarIconButton saveBtn = new ApplicationBarIconButton();
saveBtn.IconUri = new Uri(Icons.Link, UriKind.Relative);
saveBtn.Text = AppResources.Save;
@@ -60,18 +69,20 @@ namespace CampusAppWP8.Pages.TimeTable
base.OnNavigatedTo(e);
string appointmentIndexStr = string.Empty;
+ string pid = string.Empty;
// Navigate to the selected pivotitem
+
if (NavigationContext.QueryString.TryGetValue(Constants.Param_Appointment_Index, out appointmentIndexStr))
{
this.appointmentIndex = int.Parse(appointmentIndexStr);
// if the index is in the range of the array
- if ((this.appointmentIndex >= 0) && (this.appointmentIndex < TimeTable.AppointmentsModel.Appointments.Count()))
+ if ((this.appointmentIndex >= 0) && (this.appointmentIndex < TimeTable.Feed.Model.Appointments.Count()))
{
this.HeadLine.Text = AppResources.Edit;
//this.DataContext = TimeTable.AppointmentsModel.Appointments[this.appointmentIndex];
- AppointmentModel tempModel = TimeTable.AppointmentsModel.Appointments[this.appointmentIndex];
+ AppointmentModel tempModel = TimeTable.Feed.Model.Appointments[this.appointmentIndex];
this.InTitle.Text = tempModel.Title;
this.InLocation.Text = tempModel.Location;
@@ -88,12 +99,51 @@ namespace CampusAppWP8.Pages.TimeTable
MessageBox.Show("ERROR: appointment index out of range!!! (" + o + ")");
}
}
+ else if(NavigationContext.QueryString.TryGetValue(Constants.ParamPID, out pid))
+ {
+ this.HeadLine.Text = AppResources.Creating;
+ CampusAppWPortalLib8.Model.GeoDb.PlaceModel m = this.placeFile.Model.GetPlaceById(pid);
+
+ if (m != null)
+ {
+ CampusAppWPortalLib8.Model.GeoDb.PlaceModel mParent = this.placeFile.Model.GetPlaceById(m.ParentId);
+
+ string roomStr = m.GetInformationsValue(Constants.PisInformationName_Room);
+
+ if (mParent != null)
+ {
+ string buildingStr = mParent.GetInformationsValue(Constants.PisInformationName_ShortName);
+
+ if (roomStr != null)
+ {
+ if (buildingStr != null)
+ {
+ roomStr = roomStr.Replace(buildingStr, string.Empty);
+
+ this.InLocation.Text = buildingStr + ", " + roomStr;
+ }
+ else
+ {
+ this.InLocation.Text = roomStr;
+ }
+ }
+ }
+ }
+ }
else
{
this.HeadLine.Text = AppResources.Creating;
}
}
+ private void PlaceFileIsReady()
+ {
+ }
+
+ private void PlaceFileIsFailed()
+ {
+ }
+
private void OnClickSaveBtn(object sender, EventArgs e)
{
AppointmentModel newItem = new AppointmentModel();
@@ -229,10 +279,10 @@ namespace CampusAppWP8.Pages.TimeTable
if (this.appointmentIndex >= 0)
{
- TimeTable.AppointmentsModel.Appointments.RemoveAt(this.appointmentIndex);
+ TimeTable.Feed.Model.Appointments.RemoveAt(this.appointmentIndex);
}
- TimeTable.AppointmentsModel.Appointments.Add(newItem);
+ TimeTable.Feed.Model.Appointments.Add(newItem);
Page page = App.RootFrame.Content as Page;
page.NavigationService.GoBack();
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/DayViewPageItem.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/DayViewPageItem.cs
new file mode 100644
index 00000000..3b37b75c
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/DayViewPageItem.cs
@@ -0,0 +1,73 @@
+namespace CampusAppWP8.Pages.TimeTable
+{
+ using System;
+ using System.Collections.ObjectModel;
+ using System.ComponentModel;
+ using CampusAppWP8.Model.TimeTable;
+ using CampusAppWP8.Utility.Lui.Templates;
+
+ public class DayViewPageItem : INotifyPropertyChanged
+ {
+ private DateTime day;
+ private WeekView weekView = null;
+ private ObservableCollection appointmentList = null;
+
+ public event PropertyChangedEventHandler PropertyChanged;
+
+ public DayViewPageItem(DateTime day)
+ {
+ this.day = day;
+ this.appointmentList = new ObservableCollection();
+ }
+
+ public DateTime Day
+ {
+ get
+ {
+ return this.day;
+ }
+
+ set
+ {
+ this.day = value;
+ this.NotifyPropertyChanged("Day");
+ }
+ }
+
+ public WeekView View
+ {
+ get
+ {
+ return this.weekView;
+ }
+
+ set
+ {
+ this.weekView = value;
+ this.NotifyPropertyChanged("View");
+ }
+ }
+
+ public ObservableCollection AppointmentList
+ {
+ get
+ {
+ return this.appointmentList;
+ }
+
+ set
+ {
+ this.appointmentList = value;
+ this.NotifyPropertyChanged("AppointmentList");
+ }
+ }
+
+ private void NotifyPropertyChanged(string info)
+ {
+ if (this.PropertyChanged != null)
+ {
+ this.PropertyChanged(this, new PropertyChangedEventArgs(info));
+ }
+ }
+ }
+}
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs
index 65f5dded..7cdc525c 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs
@@ -8,45 +8,93 @@
namespace CampusAppWP8.Pages.TimeTable
{
using System;
- using System.Collections.Generic;
- 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.Resources;
- using CampusAppWP8.Utility;
using CampusAppWP8.Model.TimeTable;
+ using CampusAppWP8.Feed.TimeTable;
+ /// A time table.
+ /// Fiedler, 06.11.2013.
+ ///
public partial class TimeTable : PhoneApplicationPage
{
- private static AppointmentListModel appList //= null;
- = new AppointmentListModel(new AppointmentModel[] {
- new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:ownCloud Calendar 0.6.3\r\nX-WR-CALNAME:Das is der Titel\r\nBEGIN:VEVENT\r\nCREATED;VALUE=DATE-TIME:20130827T113216Z\r\nUID:c9904ea73c\r\nLAST-MODIFIED;VALUE=DATE-TIME:20130827T113216Z\r\nDTSTAMP;VALUE=DATE-TIME:20130827T113216Z\r\nSUMMARY:Das is der Titel\r\nDTSTART;VALUE=DATE-TIME:20131002T113500Z\r\nDTEND;VALUE=DATE-TIME:20131002T212000Z\r\nCLASS:PUBLIC\r\nLOCATION:BTU Campus\r\nDESCRIPTION:For Outlook 2003, the behavior is peculiar. It can save the sa\r\n me calendar entry in both .ics and .vcs format, but it only read & displa\r\n y .vcs file correctly. It can read .ics file but it omits some fields and \r\n does not display it in calendar mode. My guess is that back then Microsoft\r\n wanted to provide .ics to be compatible with Mac's iCal but not quite com\r\n mitted to v2.0 yet.\r\nCATEGORIES:Projekte\r\nEND:VEVENT\r\nEND:VCALENDAR"),
- new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:http://www.example.com/calendarapplication/\r\nMETHOD:PUBLISH\r\nBEGIN:VEVENT\r\nUID:461092315540@example.com\r\nORGANIZER:MAILTO:alice@example.com\r\nLOCATION:Somewhere\r\nSUMMARY:Eine Kurzinfo\r\nDESCRIPTION:Beschreibung des Termines\r\nCLASS:PUBLIC\r\nDTSTART:20131002T110000Z\r\nDTEND:20131004T113000Z\r\nDTSTAMP:20131003T125900Z\r\nEND:VEVENT\r\nEND:VCALENDAR"),
- new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//hacksw/handcal//NONSGML v1.0//EN\r\nBEGIN:VEVENT\r\nUID:uid1@example.com\r\nDTSTAMP:19970714T170000Z\r\nORGANIZER;CN=John Doe:MAILTO:john.doe@example.com\r\nDTSTART:20131003T150000Z\r\nDTEND:20131003T170000Z\r\nSUMMARY:Bastille Day Party\r\nEND:VEVENT\r\nEND:VCALENDAR"),
- new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION: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")
- });
+ /// The setting automatic scroll to hour.
+ public static int Setting_AutoScrollToHour = 7;
+ /// 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),
+ new SolidColorBrush(Colors.Orange),
+ new SolidColorBrush(Colors.Blue),
+ new SolidColorBrush(Colors.Brown),
+ new SolidColorBrush(Colors.Cyan),
+ new SolidColorBrush(Colors.DarkGray),
+ new SolidColorBrush(Colors.Magenta),
+ new SolidColorBrush(Colors.Purple),
+ new SolidColorBrush(Colors.Yellow),
+ new SolidColorBrush(Colors.Red)
+ };
- public static int AutoScrollToHour = 7;
- public static int VisualScale = 0; //0 - small, 1 - medium, 2 - large
- public TimeTable()
- {
- //this.InitializeComponent();
+ /// The feed.
+ private static AppointmentFeed feed = null;
- TimeTable.appList = new AppointmentListModel();
- }
-
- public static AppointmentListModel AppointmentsModel
+ /// Gets the feed.
+ /// The feed.
+ public static AppointmentFeed Feed
{
get
{
- return TimeTable.appList;
+ if (TimeTable.feed == null)
+ {
+ throw new NullReferenceException();
+ }
+
+ return TimeTable.feed;
+ }
+ }
+
+ /// Initialises the feed.
+ /// Fiedler, 06.11.2013.
+ public static void InitFeed()
+ {
+ TimeTable.InitFeed(TimeSpan.Zero);
+ }
+
+ public static void InitFeed(TimeSpan span)
+ {
+ if (TimeTable.feed == null)
+ {
+ if (span.Equals(TimeSpan.Zero))
+ {
+ TimeTable.feed = new AppointmentFeed(false);
+ }
+ else
+ {
+ TimeTable.feed = new AppointmentFeed(span, false);
+ }
+ TimeTable.feed.OnFailedFile += new CampusAppWPortalLib8.Model.AbstractMainModel.OnFailed(TimeTable.OnLoadFailed);
+ TimeTable.feed.LoadData();
+ }
+ }
+
+ /// Executes the load failed action.
+ /// Fiedler, 06.11.2013.
+ private static void OnLoadFailed()
+ {
+ if (TimeTable.feed.Model == null)
+ {
+ TimeTable.feed.Model = new AppointmentListModel();
}
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml
index 486811db..4b8a3da3 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml
@@ -6,6 +6,7 @@
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:templ="clr-namespace:CampusAppWP8.Utility.Lui.Templates"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
@@ -16,11 +17,26 @@
+
+
+
+
+
+
+
+
+
+
-
-
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs
index f4f6c819..b7efc4e2 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs
@@ -10,6 +10,7 @@ namespace CampusAppWP8.Pages.TimeTable
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
+ using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
@@ -23,25 +24,10 @@ namespace CampusAppWP8.Pages.TimeTable
public partial class TimeTableDay : PhoneApplicationPage
{
- private readonly double DAY_TABLE_HEAD_WIDTH = 48;// * (1 + (TimeTable.VisualScale / 4));
- private readonly double DAY_TABLE_HEAD_HALF = 8;// * (1 + (TimeTable.VisualScale / 4));
- private readonly double DAY_TABLE_CELL_HEIGHT = 72;// * (1 + (TimeTable.VisualScale / 2));
- private readonly double DAY_TABLE_HEAD_THICKNESS = 2;
- private readonly double DAY_TABLE_INNER_THICKNESS = 1;
- private readonly double DAY_TABLE_ZINDEX_SHIFT = 10;
- private readonly int DAY_TABLE_ZINDEX_MAX = 10;
-
private static readonly int PIVOT_ITEM_PAGES = 5;
private static readonly int PIVOT_ITEM_PAGES_HALF_DOWN = 2;
- private struct PageItem
- {
- public Canvas Content { get; set; }
- public DateTime Date { get; set; }
- public List> Stacks { get; set; }
- }
-
- private PageItem[] itemPages = new PageItem[PIVOT_ITEM_PAGES];
+ private ObservableCollection itemList = new ObservableCollection();
private int lastSelectedIndex = 0;
@@ -53,12 +39,13 @@ namespace CampusAppWP8.Pages.TimeTable
for (int i = 0; i < PIVOT_ITEM_PAGES; i++)
{
- this.itemPages[i].Stacks = new List>();
- this.CreatePage(i, firstDay.AddDays(i));
+ DayViewPageItem newItem = new DayViewPageItem(firstDay);
+
+ this.itemList.Add(newItem);
+
+ firstDay = firstDay.AddDays(1);
}
- this.ThePivot.SelectedIndex = PIVOT_ITEM_PAGES_HALF_DOWN;
- this.lastSelectedIndex = this.ThePivot.SelectedIndex;
this.ThePivot.SelectionChanged += new SelectionChangedEventHandler(this.EventPivotSelectionChanged);
ApplicationBarIconButton weekBtn = new ApplicationBarIconButton();
@@ -92,12 +79,15 @@ namespace CampusAppWP8.Pages.TimeTable
if (e.NavigationMode == NavigationMode.Back)
{
- TimeTable.AppointmentsModel.Appointments.CollectionChanged -= this.OnListChanged;
+ TimeTable.Feed.Model.Appointments.CollectionChanged -= this.OnListChanged;
}
else
{
+ this.ThePivot.ItemsSource = this.itemList;
this.lastSelectedIndex = PIVOT_ITEM_PAGES_HALF_DOWN;
this.ThePivot.SelectedIndex = PIVOT_ITEM_PAGES_HALF_DOWN;
+
+ this.CheckAppointments();
}
}
@@ -112,7 +102,6 @@ namespace CampusAppWP8.Pages.TimeTable
3<->4: 1
4<->0: 2
*/
-
int delta = this.ThePivot.SelectedIndex - this.lastSelectedIndex;
if(delta < -1) delta = 1;
@@ -124,25 +113,24 @@ namespace CampusAppWP8.Pages.TimeTable
{
return;
}
- else
- {
- this.itemPages[indexToChange].Date = this.itemPages[this.ThePivot.SelectedIndex].Date.AddDays(delta * PIVOT_ITEM_PAGES_HALF_DOWN);
- }
- this.SetupPage(indexToChange);
+ this.itemList[indexToChange].Day = this.itemList[this.ThePivot.SelectedIndex].Day.AddDays(delta * PIVOT_ITEM_PAGES_HALF_DOWN);
+ this.itemList[indexToChange].AppointmentList.Clear();
+ this.CheckAppointments(indexToChange);
+
this.lastSelectedIndex = this.ThePivot.SelectedIndex;
}
- private void OnAppointmentClick(object sender, System.Windows.Input.GestureEventArgs e)
+ private void OnAppointmentClick(AppointmentModel model)
{
- int index = TimeTable.AppointmentsModel.Appointments.IndexOf((sender as Canvas).Tag as AppointmentModel);
+ int index = TimeTable.Feed.Model.Appointments.IndexOf(model);
if (index >= 0)
{
- TimeTable.AppointmentsModel.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged);
+ TimeTable.Feed.Model.Appointments.CollectionChanged += this.OnListChanged;
- string urlString = "/Pages/TimeTable/Appointment.xaml?" + Constants.Param_Appointment_Index + "=" + index;
+ string urlString = Constants.PathTimeTable_Appointment + "?" + Constants.Param_Appointment_Index + "=" + index;
Uri url = new Uri(urlString, UriKind.Relative);
Page page = App.RootFrame.Content as Page;
@@ -150,441 +138,135 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
- private void EventOnMultiBubbleClick(object sender, System.Windows.Input.GestureEventArgs e)
- {
- int indexVal = (int)(sender as Canvas).Tag;
- int index = indexVal >> 12;
- int listIndex = indexVal & 0x00000FFF;
-
- 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.itemPages[index].Stacks[listIndex].Count(); i++)
- {
- this.RemoveContentUIElement(index, this.itemPages[index].Stacks[listIndex][i]);
-
- if (i > 0)
- {
- this.DrawAppointmentModel(this.itemPages[index].Stacks[listIndex][i], index, 0.5, i, this.itemPages[index].Stacks[listIndex].Count() - 1 - i);
- }
- else
- {
- this.DrawAppointmentModel(this.itemPages[index].Stacks[listIndex][i], index, 1.0, i, this.itemPages[index].Stacks[listIndex].Count() - 1 - i);
- }
- }
-
- this.RemoveContentUIElement(index, sender as Canvas);
-
- Canvas tempCan = this.GetModelCanvasFromContent(index, this.itemPages[index].Stacks[listIndex][0]);
-
- this.DrawMultiBubble(
- index,
- listIndex,
- this.itemPages[index].Stacks[listIndex].Count(),
- tempCan.Width + tempCan.Margin.Left,
- tempCan.Margin.Top);
- }
-
- private void EventAutoScroll(object sender, RoutedEventArgs e)
- {
- if ((sender as ScrollViewer).VerticalOffset == 0.0)
- {
- (sender as ScrollViewer).ScrollToVerticalOffset(DAY_TABLE_CELL_HEIGHT * TimeTable.AutoScrollToHour);
- }
- }
-
private void OnClickWeek(object sender, EventArgs e)
{
- Uri url = new Uri("/Pages/TimeTable/TimeTableWeek.xaml", UriKind.Relative);
+ Uri url = new Uri(Constants.PathTimeTable_Week, UriKind.Relative);
Page page = App.RootFrame.Content as Page;
page.NavigationService.Navigate(url);
}
private void OnClickToDay(object sender, EventArgs e)
{
- DateTime firstDay = DateTime.Now.Date.AddDays(PIVOT_ITEM_PAGES_HALF_DOWN * -1);
- this.ThePivot.SelectedIndex = PIVOT_ITEM_PAGES_HALF_DOWN;
+ int index = -1;
- for (int i = 0; i < PIVOT_ITEM_PAGES; i++)
+ for (int i = 0; i < this.itemList.Count; i++)
{
- this.itemPages[i].Date = firstDay.AddDays(i);
+ if (this.itemList[i].Day.Date.Equals(DateTime.Today.Date))
+ {
+ index = i;
+ }
+ }
- this.SetupPage(i);
+ if (index < 0)
+ {
+ DateTime firstDay = DateTime.Now;
+ this.ThePivot.SelectedIndex = PIVOT_ITEM_PAGES_HALF_DOWN;
+ firstDay = firstDay.AddDays(-1 * PIVOT_ITEM_PAGES_HALF_DOWN);
+
+ for (int i = 0; i < PIVOT_ITEM_PAGES; i++)
+ {
+ this.itemList[i].Day = firstDay;
+ this.itemList[i].AppointmentList.Clear();
+
+ this.CheckAppointments(i);
+
+ firstDay = firstDay.AddDays(1);
+ }
+ }
+ else
+ {
+ this.ThePivot.SelectedIndex = index;
}
}
private void OnClickProperties(object sender, EventArgs e)
{
- Uri url = new Uri("/Pages/TimeTable/TimeTableProperties.xaml", UriKind.Relative);
+ Uri url = new Uri(Constants.PathTimeTable_Properties, UriKind.Relative);
Page page = App.RootFrame.Content as Page;
page.NavigationService.Navigate(url);
}
private void OnClickAdd(object sender, EventArgs e)
{
- TimeTable.AppointmentsModel.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged);
+ TimeTable.Feed.Model.Appointments.CollectionChanged += this.OnListChanged;
- Uri url = new Uri("/Pages/TimeTable/AppointmentEdit.xaml", UriKind.Relative);
+ Uri url = new Uri(Constants.PathTimeTable_AppointmentEdit, UriKind.Relative);
Page page = App.RootFrame.Content as Page;
page.NavigationService.Navigate(url);
}
private void OnListChanged(object sender, NotifyCollectionChangedEventArgs e)
{
- AppointmentModel tempModel = null;
-
if (e.Action == NotifyCollectionChangedAction.Add)
{
- tempModel = e.NewItems[0] as AppointmentModel;
+ for(int i = 0; i < e.NewItems.Count; i++)
+ {
+ AppointmentModel m = e.NewItems[i] as AppointmentModel;
+
+ for(int a = 0; a < PIVOT_ITEM_PAGES; a++)
+ {
+ if(m.IsDate(this.itemList[a].Day) == 0)
+ {
+ this.itemList[a].AppointmentList.Add(m);
+ }
+ }
+ }
}
else if (e.Action == NotifyCollectionChangedAction.Remove)
{
- tempModel = e.OldItems[0] as AppointmentModel;
- }
+ for (int i = 0; i < e.OldItems.Count; i++)
+ {
+ AppointmentModel m = e.OldItems[i] as AppointmentModel;
- if (tempModel != null)
+ for (int a = 0; a < PIVOT_ITEM_PAGES; a++)
+ {
+ if (m.IsDate(this.itemList[a].Day) == 0)
+ {
+ this.itemList[a].AppointmentList.Remove(m);
+ }
+ }
+ }
+ }
+ else if (e.Action == NotifyCollectionChangedAction.Reset)
{
for (int i = 0; i < PIVOT_ITEM_PAGES; i++)
{
- if (tempModel.IsDate(this.itemPages[i].Date.Date) > -1)
+ this.itemList[i].AppointmentList.Clear();
+ }
+ }
+ }
+
+ private void CheckAppointments(int index = -1)
+ {
+ if (index < 0)
+ {
+ for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++)
+ {
+ AppointmentModel temp = TimeTable.Feed.Model.Appointments[m];
+
+ for (int i = 0; i < PIVOT_ITEM_PAGES; i++)
{
- this.SetupPage(i);
- }
- }
- }
- }
-
- private void AddContentUIElement(int index, UIElement elem)
- {
- this.itemPages[index].Content.Children.Add(elem);
- }
-
- private void RemoveContentUIElement(int index, UIElement elem)
- {
- this.itemPages[index].Content.Children.Remove(elem);
- }
-
- 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 tempList = new List();
-
- this.itemPages[index].Stacks.Clear();
- this.itemPages[index].Content.Children.Clear();
-
- for (int i = 0; i < TimeTable.AppointmentsModel.Appointments.Count(); i++)
- {
- int appointmentIndex = -1;
-
- if ((appointmentIndex = TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemPages[index].Date)) > -1)
- {
- tempList.Add(TimeTable.AppointmentsModel.Appointments[i]);
- }
- }
- // -------------------------------------------------------------
- for (int i = 0; i < tempList.Count(); i++)
- {
- int[] intersectIndex = tempList[i].IntersectArray(tempList.ToArray());
-
- if (intersectIndex.Count() == 0)
- {
- this.DrawAppointmentModel(tempList[i], index);
- }
- else if (intersectIndex.Count() == 1)
- {
- int addIndex = -1;
-
- for (int k = 0; k < this.itemPages[index].Stacks.Count(); k++)
- {
- if(this.itemPages[index].Stacks[k].IndexOf(tempList[intersectIndex[0]]) > -1)
+ if (temp.IsDate(this.itemList[i].Day) == 0)
{
- addIndex = k;
+ temp.OnClick += this.OnAppointmentClick;
+ this.itemList[i].AppointmentList.Add(temp);
}
}
-
- if (addIndex >= 0)
- {
- this.itemPages[index].Stacks[addIndex].Add(tempList[i]);
- }
- else
- {
- List newList = new List();
- 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.Count(); m++)
- {
- if (this.itemPages[index].Stacks[m].IndexOf(tempList[intersectIndex[k]]) > -1)
- {
- if(intersectLists.IndexOf(this.itemPages[index].Stacks[m]) < 0)
- {
- intersectLists.Add(this.itemPages[index].Stacks[m]);
- }
- }
- }
- }
-
- if(intersectLists.Count() == 0)
- {
- List newList = new List();
- newList.Add(tempList[i]);
- this.itemPages[index].Stacks.Add(newList);
- }
- else if(intersectLists.Count() == 1)
- {
- intersectLists[0].Add(tempList[i]);
- }
- else
- {
- for(int k = 1; k < intersectLists.Count(); k++)
- {
- intersectLists[0].AddRange(intersectLists[k].ToArray());
- this.itemPages[index].Stacks.Remove(intersectLists[k]);
- }
-
- intersectLists[0].Add(tempList[i]);
- }
}
}
-
- for (int i = 0; i < this.itemPages[index].Stacks.Count(); i++)
+ else
{
- for (int k = 0; k < this.itemPages[index].Stacks[i].Count(); k++)
+ for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++)
{
- if (k > 0)
+ AppointmentModel temp = TimeTable.Feed.Model.Appointments[m];
+
+ if (temp.IsDate(this.itemList[index].Day) == 0)
{
- this.DrawAppointmentModel(this.itemPages[index].Stacks[i][k], index, 0.5, k, this.itemPages[index].Stacks[i].Count() - 1 - k);
- }
- else
- {
- this.DrawAppointmentModel(this.itemPages[index].Stacks[i][k], index, 1.0, k, this.itemPages[index].Stacks[i].Count() - 1 - k);
+ temp.OnClick += this.OnAppointmentClick;
+ this.itemList[index].AppointmentList.Add(temp);
}
}
-
- Canvas tempCan = this.GetModelCanvasFromContent(index, this.itemPages[index].Stacks[i][0]);
-
- this.DrawMultiBubble(
- index,
- i,
- this.itemPages[index].Stacks[i].Count(),
- tempCan.Width + tempCan.Margin.Left,
- tempCan.Margin.Top);
}
}
-
- private void OnCanvasSizeChanged(object sender, SizeChangedEventArgs e)
- {
- if (e.NewSize.Width.Equals(e.PreviousSize.Width) == false)
- {
- Canvas tempContainer = (sender as Canvas);
- Canvas tempBG = (tempContainer.Children[0] as Canvas);
- Canvas tempContent = (tempContainer.Children[1] as Canvas);
- tempBG.Width = e.NewSize.Width;
- tempBG.Height = e.NewSize.Height;
- tempContent.Width = e.NewSize.Width;
- tempContent.Height = e.NewSize.Height;
-
- PivotItem pvItem = ((tempContainer.Parent as ScrollViewer).Parent as PivotItem);
- int index = this.ThePivot.Items.IndexOf(pvItem);
-
- this.DrawBackground(tempBG);
-
- this.SetupPage(index);
- }
- }
-
- 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;
-
- 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)
- {
- 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(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();
- rect.Width = DAY_TABLE_CELL_HEIGHT / 2;
- rect.Height = DAY_TABLE_CELL_HEIGHT / 2;
- rect.RadiusX = DAY_TABLE_CELL_HEIGHT / 4;
- rect.RadiusY = DAY_TABLE_CELL_HEIGHT / 4;
- rect.StrokeThickness = 1;
- rect.Stroke = new SolidColorBrush(Colors.DarkGray);
- rect.Fill = new SolidColorBrush(Colors.Black);
-
- TextBlock block = new TextBlock();
- block.Height = DAY_TABLE_CELL_HEIGHT / 2;
- block.Width = DAY_TABLE_CELL_HEIGHT / 2;
- block.Text = "" + number;
- block.HorizontalAlignment = HorizontalAlignment.Center;
- block.VerticalAlignment = VerticalAlignment.Center;
- block.FontWeight = FontWeights.Bold;
- block.FontSize = DAY_TABLE_CELL_HEIGHT / 3;
- block.Padding = new Thickness(DAY_TABLE_CELL_HEIGHT / 6.5, 0, 0, 0);
-
- can.Children.Add(rect);
- can.Children.Add(block);
- can.Tap += new EventHandler(this.EventOnMultiBubbleClick);
- can.Tag = (stackIndex << 12) | (listIndex & 0x00000FFF);
- can.SetValue(Canvas.LeftProperty, xOffset - rect.Width);
- can.SetValue(Canvas.TopProperty, yOffset);
- can.SetValue(Canvas.ZIndexProperty, DAY_TABLE_ZINDEX_MAX + 1);
-
- this.AddContentUIElement(stackIndex, can);
- }
-
- private void DrawBackground(Canvas dayView)
- {
- Line vertLine = new Line();
- vertLine.X1 = 0;
- vertLine.Y1 = 0;
- vertLine.X2 = 0;
- vertLine.Y2 = (DAY_TABLE_CELL_HEIGHT * 24);
- vertLine.Stroke = new SolidColorBrush(Colors.White);
- vertLine.Stretch = Stretch.Fill;
- vertLine.HorizontalAlignment = HorizontalAlignment.Left;
- vertLine.Margin = new Thickness(DAY_TABLE_HEAD_WIDTH, 0, 0, 0);
- vertLine.StrokeThickness = DAY_TABLE_HEAD_THICKNESS;
-
- for (int i = 0; i <= 24; i++)
- {
- // lines
- Line hLineHead = new Line();
- hLineHead.X1 = 0;
- hLineHead.Y1 = 0;
- hLineHead.X2 = DAY_TABLE_HEAD_WIDTH;
- hLineHead.Y2 = 0;
- hLineHead.Stroke = new SolidColorBrush(Colors.White);
- hLineHead.Stretch = Stretch.Fill;
- hLineHead.HorizontalAlignment = HorizontalAlignment.Left;
- hLineHead.Margin = new Thickness(0, (DAY_TABLE_CELL_HEIGHT * i), 0, 0);
- hLineHead.StrokeThickness = DAY_TABLE_HEAD_THICKNESS;
-
- Line hLineHalf = new Line();
- hLineHalf.X1 = 0;
- hLineHalf.Y1 = 0;
- hLineHalf.X2 = DAY_TABLE_HEAD_HALF;
- hLineHalf.Y2 = 0;
- hLineHalf.Stroke = new SolidColorBrush(Colors.Gray);
- hLineHalf.Stretch = Stretch.Fill;
- hLineHalf.HorizontalAlignment = HorizontalAlignment.Left;
- hLineHalf.Margin = new Thickness((DAY_TABLE_HEAD_WIDTH - DAY_TABLE_HEAD_HALF), (DAY_TABLE_CELL_HEIGHT * i) + (DAY_TABLE_CELL_HEIGHT / 2), 0, 0);
- hLineHalf.StrokeThickness = DAY_TABLE_HEAD_THICKNESS;
-
- Line hLineInn = new Line();
- hLineInn.X1 = 0;
- hLineInn.Y1 = 0;
- hLineInn.X2 = 1000;
- hLineInn.Y2 = 0;
- hLineInn.Stroke = new SolidColorBrush(Colors.DarkGray);
- hLineInn.Stretch = Stretch.Fill;
- hLineInn.HorizontalAlignment = HorizontalAlignment.Left;
- hLineInn.Margin = new Thickness(DAY_TABLE_HEAD_WIDTH, (DAY_TABLE_CELL_HEIGHT * i), 0, 0);
- hLineInn.StrokeDashArray = new DoubleCollection();
- hLineInn.StrokeDashArray.Add(2);
- hLineInn.StrokeDashArray.Add(4);
- hLineInn.StrokeThickness = DAY_TABLE_INNER_THICKNESS;
-
- dayView.Children.Add(hLineHead);
- dayView.Children.Add(hLineInn);
-
- if (i < 24)
- {
- dayView.Children.Add(hLineHalf);
-
- // text
- 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 = DAY_TABLE_CELL_HEIGHT / 4;
-
- dayView.Children.Add(timeStamp);
- }
- }
-
- dayView.Children.Add(vertLine);
- }
}
}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableProperties.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableProperties.xaml.cs
index 455f5c20..706e6fa0 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableProperties.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableProperties.xaml.cs
@@ -35,19 +35,19 @@ namespace CampusAppWP8.Pages.TimeTable
}
this.AutoScroll.ItemsSource = tempAutoScroll;
- this.AutoScroll.SelectedIndex = TimeTable.AutoScrollToHour;
+ this.AutoScroll.SelectedIndex = TimeTable.Setting_AutoScrollToHour;
// VisualSize
this.VisualScale.ItemsSource = VisualScaleText;
- this.VisualScale.SelectedIndex = TimeTable.VisualScale;
+ this.VisualScale.SelectedIndex = TimeTable.Setting_VisualScale;
}
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
- TimeTable.AutoScrollToHour = this.AutoScroll.SelectedIndex;
- TimeTable.VisualScale = this.VisualScale.SelectedIndex;
+ TimeTable.Setting_AutoScrollToHour = this.AutoScroll.SelectedIndex;
+ TimeTable.Setting_VisualScale = this.VisualScale.SelectedIndex;
}
}
}
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml
index ffa1094b..9a39756a 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml
@@ -5,6 +5,7 @@
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:templ="clr-namespace:CampusAppWP8.Utility.Lui.Templates"
+ xmlns:header="clr-namespace:CampusAppWP8.Utility.Lui.Header"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
@@ -12,21 +13,28 @@
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Landscape" Orientation="Landscape"
mc:Ignorable="d"
- shell:SystemTray.IsVisible="True">
+ shell:SystemTray.IsVisible="True"
+ >
-
+
-
+
-
-
-
+
diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs
index 58ed4163..f259361d 100644
--- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs
@@ -8,9 +8,8 @@
namespace CampusAppWP8.Pages.TimeTable
{
using System;
- using System.Collections.Generic;
using System.Collections.Specialized;
- using System.Linq;
+ using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
@@ -20,48 +19,33 @@ namespace CampusAppWP8.Pages.TimeTable
using Microsoft.Phone.Shell;
using CampusAppWP8.Model.TimeTable;
using CampusAppWP8.Resources;
- using CampusAppWP8.Utility.Lui.Templates;
public partial class TimeTableWeek : PhoneApplicationPage
{
- private static readonly double WEEK_TABLE_CELL_HEIGHT = 40;
- private static readonly double WEEK_TABLE_HEAD_WIDTH = 40;
- private static readonly double WEEK_TABLE_HEAD_THICKNESS = 2;
- private static readonly double WEEK_TABLE_HEAD_HALF = 15;
- private static readonly double WEEK_TABLE_INNER_THICKNESS = 1;
- private static readonly int WEEK_TABLE_ZINDEX_MAX = 10;
-
-
- private struct PageItem
- {
- public DateTime DateFrom { get; set; }
- public DateTime DateTo { get; set; }
- public char WeekChar { get; set; }
- public int WeekNumber { get; set; }
- public WeekView weekView { get; set; }
- //???
- public List appointmentList { get; set; }
- public PivotItem pItemPtr { get; set; }
- }
-
private static readonly int PIVOT_PAGES = 3;
private static readonly int PIVOT_PAGES_HALF_DOWN = 1;
- private static readonly int PIVOT_PAGES_COLUMNS = 5; // days in week
-
- private PageItem[] itemPages = new PageItem[PIVOT_PAGES];
- private int lastSelectedIndex = 0;
- private int loadedWeekView = 0;
+ private int lastSelectedIndex = 0;
+
+ private ObservableCollection itemList = new ObservableCollection();
+
public TimeTableWeek()
{
this.InitializeComponent();
+ TimeTable.InitFeed();
+
DateTime firstDay = this.GetFirstDayOfWeek(DateTime.Now).AddDays(-7 * PIVOT_PAGES_HALF_DOWN);
for (int i = 0; i < PIVOT_PAGES; i++)
{
- this.itemPages[i].DateFrom = firstDay;
- this.itemPages[i].DateTo = firstDay.AddDays(6);
+ int weekNr = this.GetWeekNumber(firstDay);
+ string weekStr = ((weekNr % 2) != 0) ? "A" : "B";
+
+ WeekViewPageItem newItem = new WeekViewPageItem(firstDay, weekStr, weekNr, 6);
+
+ this.itemList.Add(newItem);
+
firstDay = firstDay.AddDays(7);
}
@@ -96,16 +80,25 @@ namespace CampusAppWP8.Pages.TimeTable
if (e.NavigationMode == NavigationMode.Back)
{
- TimeTable.AppointmentsModel.Appointments.CollectionChanged -= this.OnListChanged;
+ TimeTable.Feed.Model.Appointments.CollectionChanged -= this.OnListChanged;
}
else
{
- this.ThePivot.ItemsSource = this.itemPages;
+ this.ThePivot.ItemsSource = this.itemList;
this.lastSelectedIndex = PIVOT_PAGES_HALF_DOWN;
this.ThePivot.SelectedIndex = PIVOT_PAGES_HALF_DOWN;
+
+ this.CheckAppointments();
}
}
+ protected override void OnNavigatedFrom(NavigationEventArgs e)
+ {
+ base.OnNavigatedFrom(e);
+
+ TimeTable.Feed.SaveData();
+ }
+
private DateTime GetFirstDayOfWeek(DateTime dayInWeek)
{
DateTime retValue = dayInWeek.Date;
@@ -118,6 +111,16 @@ namespace CampusAppWP8.Pages.TimeTable
return retValue;
}
+ private int GetWeekNumber(DateTime date)
+ {
+ int retValue = 0;
+
+ var cal = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar;
+ retValue = cal.GetWeekOfYear(date, System.Globalization.CalendarWeekRule.FirstDay, DayOfWeek.Monday);
+
+ return retValue;
+ }
+
private int GetDayOfWeekIndex(DateTime dayInWeek)
{
int retValue = -1;
@@ -138,36 +141,46 @@ namespace CampusAppWP8.Pages.TimeTable
private void OnClickDayView(object sender, EventArgs e)
{
- /********* REMOVED FOR TESTING ********
Uri url = new Uri(Constants.PathTimeTable_Day, UriKind.Relative);
Page page = App.RootFrame.Content as Page;
page.NavigationService.Navigate(url);
- */
-// this.itemPages[this.ThePivot.SelectedIndex].weekView.SetColumnBackground(0, new SolidColorBrush(Colors.Red));
}
private void OnClickToday(object sender, EventArgs e)
{
- /******* REMOVED FOR TESTING ********
- 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.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);
+ 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;
}
- */
- //this.itemPages[this.ThePivot.SelectedIndex].weekView.SetColumnBackground(0);
}
private void OnClickProperties(object sender, EventArgs e)
@@ -179,7 +192,7 @@ namespace CampusAppWP8.Pages.TimeTable
private void OnClickCreate(object sender, EventArgs e)
{
- TimeTable.AppointmentsModel.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged);
+ TimeTable.Feed.Model.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged);
Uri url = new Uri(Constants.PathTimeTable_AppointmentEdit, UriKind.Relative);
Page page = App.RootFrame.Content as Page;
@@ -189,7 +202,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;
@@ -199,39 +212,26 @@ namespace CampusAppWP8.Pages.TimeTable
{
return;
}
- else
- {
- this.itemPages[index].DateFrom = this.itemPages[this.ThePivot.SelectedIndex].DateFrom.AddDays((7 * delta));
- this.itemPages[index].DateTo = this.itemPages[this.ThePivot.SelectedIndex].DateTo.AddDays((7 * delta));
- }
+
+ this.itemList[index].FromDT = this.itemList[this.ThePivot.SelectedIndex].FromDT.AddDays((7 * delta));
+ this.itemList[index].ToDT = this.itemList[this.ThePivot.SelectedIndex].ToDT.AddDays((7 * delta));
+ this.itemList[index].WeekNr = this.GetWeekNumber(this.itemList[index].FromDT);
+ this.itemList[index].WeekStr = ((this.itemList[index].WeekNr % 2) != 0) ? "A" : "B";
- //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.SetupPage(index);
+ this.itemList[index].AppointmentList.Clear();
+
+ this.CheckAppointments(index);
this.lastSelectedIndex = this.ThePivot.SelectedIndex;
}
- private void OnAutoScroll(object sender, RoutedEventArgs e)
+ private void OnAppointmentClick(AppointmentModel model)
{
- if ((sender as ScrollViewer).VerticalOffset == 0.0)
- {
- (sender as ScrollViewer).ScrollToVerticalOffset(WEEK_TABLE_CELL_HEIGHT * TimeTable.AutoScrollToHour);
- }
- }
-
- private void OnAppointmentClick(object sender, System.Windows.Input.GestureEventArgs e)
- {
- int index = TimeTable.AppointmentsModel.Appointments.IndexOf((sender as Canvas).Tag as AppointmentModel);
+ int index = TimeTable.Feed.Model.Appointments.IndexOf(model);
if (index >= 0)
{
- TimeTable.AppointmentsModel.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged);
+ TimeTable.Feed.Model.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged);
string urlString = Constants.PathTimeTable_Appointment + "?" + Constants.Param_Appointment_Index + "=" + index;
@@ -241,68 +241,6 @@ 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);
- AppointmentModel tempModel = this.itemPages[index].Stacks[listIndex].First();
- this.itemPages[index].Stacks[listIndex].Remove(tempModel);
- this.itemPages[index].Stacks[listIndex].Add(tempModel);
-
- //for (int i = 0; i < this.itemPages[index].Stacks[dayIndex][listIndex].Count(); i++)
- for (int i = 0; i < this.itemPages[index].Stacks[listIndex].Count(); i++)
- {
- //tempModel = this.itemPages[index].Stacks[dayIndex][listIndex][i];
- tempModel = this.itemPages[index].Stacks[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);
- this.DrawAppointment(this.itemPages[index].Stacks[listIndex][i], index, day, 0.5, i, this.itemPages[index].Stacks[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.DrawAppointment(this.itemPages[index].Stacks[listIndex][i], index, day, 1.0, i, this.itemPages[index].Stacks[listIndex].Count - 1 - i);
- }
- }
- }
- }
-*/
-// this.RemoveContentUIElement(index, sender as Canvas);
-
- bool bubbleDrawn = false;
-/*
- for (int day = 0; day < 5; day++)
- {
- if (this.itemPages[index].Stacks[listIndex][0].IsDate(this.itemPages[index].DateFrom.Date.AddDays(day)) > -1 && bubbleDrawn == false)
- {
- bubbleDrawn = true;
- Canvas[] tempCan = this.GetModelCanvasFromContent(index, this.itemPages[index].Stacks[listIndex][0]);
- this.DrawMultiBubble(
- index,
- day,
- listIndex,
- this.itemPages[index].Stacks[listIndex].Count(),
- tempCan[0].Width + tempCan[0].Margin.Left,
- tempCan[0].Margin.Top);
- }
- }
-*/
-}
-
private void OnListChanged(object sender, NotifyCollectionChangedEventArgs e)
{
AppointmentModel tempModel = null;
@@ -310,524 +248,75 @@ namespace CampusAppWP8.Pages.TimeTable
if (e.Action == NotifyCollectionChangedAction.Add)
{
tempModel = e.NewItems[0] as AppointmentModel;
+
+ for (int i = 0; i < PIVOT_PAGES; i++)
+ {
+ if (tempModel.IsDate(this.itemList[i].FromDT, 4) >= 0)
+ {
+ tempModel.OnClick += this.OnAppointmentClick;
+ this.itemList[i].AppointmentList.Add(tempModel);
+ }
+ }
}
else if (e.Action == NotifyCollectionChangedAction.Remove)
{
tempModel = e.OldItems[0] as AppointmentModel;
- }
- if (tempModel != null)
- {
for (int i = 0; i < PIVOT_PAGES; i++)
{
- if (tempModel.IsDate(this.itemPages[i].DateFrom, 4) > -1)
+ if (this.itemList[i].AppointmentList.IndexOf(tempModel) >= 0)
{
- this.SetupPage(i);
+ tempModel.OnClick -= this.OnAppointmentClick;
+ this.itemList[i].AppointmentList.Remove(tempModel);
}
}
}
}
- private void OnCanvasSizeChanged(object sender, SizeChangedEventArgs e)
+ private void CheckAppointments(int pageIndex = -1)
{
- /*
- if (e.NewSize.Width.Equals(e.PreviousSize.Width) == false)
+ if (TimeTable.Feed == null)
{
- Canvas tempContainer = (sender as Canvas);
- Canvas tempBG = (tempContainer.Children[0] as Canvas);
- Canvas tempContent = (tempContainer.Children[1] as Canvas);
- tempBG.Width = e.NewSize.Width;
- tempBG.Height = e.NewSize.Height;
- tempContent.Width = e.NewSize.Width;
- tempContent.Height = e.NewSize.Height;
-
- PivotItem pvItem = ((tempContainer.Parent as ScrollViewer).Parent as PivotItem);
- Grid headGrid = pvItem.Header as Grid;
- int index = this.ThePivot.Items.IndexOf(pvItem);
-
- headGrid.Width = e.NewSize.Width;
-
- this.SetupPage(index);
+ throw new NullReferenceException("feed == null");
}
- */
- }
-
- 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++)
+ else if (TimeTable.Feed.Model == null)
{
- this.itemPages[index].Stacks[i].Clear();
+ throw new NullReferenceException("model == null");
}
- /**/
-// this.itemPages[index].Stacks.Clear();
-
-// this.itemPages[index].Content.Children.Clear();
-/*
- for(int i = 0; i < 5; i++)
+ else if (TimeTable.Feed.Model.Appointments == null)
{
- tempList[i] = new List();
+ throw new NullReferenceException("Appointments == null");
}
-*/
- for (int i = 0; i < TimeTable.AppointmentsModel.Appointments.Count(); i++)
+
+ if (pageIndex < 0)
{
-/*
- for (int k = 0; k < 5; k++)
+ for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++)
{
- if (TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemPages[index].DateFrom.Date.AddDays(k)) > -1)
+ AppointmentModel temp = TimeTable.Feed.Model.Appointments[m];
+
+ for (int i = 0; i < PIVOT_PAGES; i++)
{
- tempList[k].Add(TimeTable.AppointmentsModel.Appointments[i]);
+ if (temp.IsDate(this.itemList[i].FromDT, 4) >= 0)
+ {
+ temp.OnClick += this.OnAppointmentClick;
+ this.itemList[i].AppointmentList.Add(temp);
+ }
}
}
-*/
- if (TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemPages[index].DateFrom.Date, 4) > -1)
- {
- tempList.Add(TimeTable.AppointmentsModel.Appointments[i]);
- }
}
- // -------------------------------------------------------
-/*
- for (int i = 0; i < tempList.Count(); i++)
+ else
{
- int[] intersectIndex = tempList[i].IntersectArray(tempList.ToArray());
-
- if (intersectIndex.Count() == 0)
+ for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++)
{
- 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;
+ AppointmentModel temp = TimeTable.Feed.Model.Appointments[m];
- for (int k = 0; k < this.itemPages[index].Stacks.Count(); k++)
+ if (temp.IsDate(this.itemList[pageIndex].FromDT, 4) >= 0)
{
- //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]);
+ temp.OnClick += this.OnAppointmentClick;
+ this.itemList[pageIndex].AppointmentList.Add(temp);
}
}
}
-*/
-/*
- 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 CreatePage(int itemIndex, DateTime weekStart)
- {
-// this.itemPages[itemIndex].Content = new Canvas();
-// this.itemPages[itemIndex].Content.Height = WEEK_TABLE_CELL_HEIGHT * 24;
- this.itemPages[itemIndex].DateFrom = weekStart;
- this.itemPages[itemIndex].DateTo = weekStart.AddDays(6);
-// this.itemPages[itemIndex].WeekNumber = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(
-// weekStart,
-// System.Globalization.CalendarWeekRule.FirstDay,
-// DayOfWeek.Monday);
-// this.itemPages[itemIndex].WeekChar = ((this.itemPages[itemIndex].WeekNumber % 2) == 0) ? 'B' : 'A';
-
- //PivotItem pvItem = new PivotItem();
- //Grid headGrid = new Grid();
- //pvItem.Header = headGrid;
-
- //this.ThePivot.Items.Add(pvItem);
- }
-
- private void RemoveContentUIElement(int index, UIElement elem)
- {
-// if (this.itemPages[index].Content.Children.Remove(elem) == false)
- {
- throw new ArgumentException();
- }
- }
-
- private void RemoveContentUIElement(int index, AppointmentModel model)
- {
- Canvas[] list = this.GetModelCanvasFromContent(index, model);
-
- if (list.Count() > 0)
- {
- foreach (Canvas can in list)
- {
-// this.itemPages[index].Content.Children.Remove(can);
- }
- }
- }
-
- private Canvas[] GetModelCanvasFromContent(int index, AppointmentModel model)
- {
- List
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Header/WeekViewPivotHeader.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Header/WeekViewPivotHeader.xaml.cs
index eb9270bc..c5c3fdd7 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Header/WeekViewPivotHeader.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Header/WeekViewPivotHeader.xaml.cs
@@ -12,11 +12,41 @@
public partial class WeekViewPivotHeader : UserControl
{
-
+ public static readonly DependencyProperty DateFromProperty = DependencyProperty.Register("DateFrom", typeof(DateTime), typeof(WeekViewPivotHeader), new PropertyMetadata(null));
+ public static readonly DependencyProperty DateToProperty = DependencyProperty.Register("DateTo", typeof(DateTime), typeof(WeekViewPivotHeader), new PropertyMetadata(null));
+ public static readonly DependencyProperty DaysProperty = DependencyProperty.Register("Days", typeof(int), typeof(WeekViewPivotHeader), new PropertyMetadata(null));
public WeekViewPivotHeader()
{
+ this.Days = 5;
this.InitializeComponent();
}
+
+ public DateTime DateFrom
+ {
+ get
+ {
+ return (DateTime)this.GetValue(DateFromProperty);
+ }
+
+ set
+ {
+ this.SetValue(DateFromProperty, value);
+ this.SetValue(DateToProperty, value.AddDays(this.Days));
+ }
+ }
+
+ public int Days
+ {
+ get
+ {
+ return (int)this.GetValue(DaysProperty);
+ }
+
+ set
+ {
+ this.SetValue(DaysProperty, value);
+ }
+ }
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml
new file mode 100644
index 00000000..f188b56c
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml.cs
new file mode 100644
index 00000000..6c897d5b
--- /dev/null
+++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml.cs
@@ -0,0 +1,129 @@
+//-----------------------------------------------------------------------
+//
+// The MIT License (MIT). Copyright (c) 2013 BTU/IIT.
+//
+// Fiedler
+// 28.10.2013
+// Implements the appointment canvas.xaml class
+//-----------------------------------------------------------------------
+namespace CampusAppWP8.Utility.Lui.Templates
+{
+ using System;
+ using System.Collections.Generic;
+ using System.Linq;
+ using System.Net;
+ using System.Windows;
+ using System.Windows.Controls;
+ using System.Windows.Navigation;
+ using Microsoft.Phone.Controls;
+ using Microsoft.Phone.Shell;
+ using CampusAppWP8.Model.TimeTable;
+ using CampusAppWP8.Pages.TimeTable;
+ using System.Windows.Data;
+ using System.Windows.Media;
+
+ public partial class AppointmentCanvas : UserControl
+ {
+ private AppointmentModel appPtr = null;
+
+ public AppointmentCanvas() : base()
+ {
+ this.InitializeComponent();
+ }
+
+ public AppointmentCanvas(AppointmentModel model) : this(model, new DateTime(0))
+ {
+ }
+
+ public AppointmentCanvas(AppointmentModel model, DateTime day) : this()
+ {
+ this.appPtr = model;
+
+ double totalHours = model.GetTotalHours(day);
+
+ this.Height = ((totalHours < 0.25) ? 0.25 : totalHours) * TimeTable.Setting_Hour_Spacing;
+ this.SetText(model.Title);
+ this.SetValue(Canvas.TopProperty, (day.Date.Equals(model.Start.Date)) ? (model.Start.TimeOfDay.TotalHours * TimeTable.Setting_Hour_Spacing) : 0);
+
+ object tempProp = null;
+
+ if ((tempProp = model.GetValue(ICSTag.PRIORITY)) != null)
+ {
+ this.SetBGColorByPriority((tempProp as ICSProperties.Priority).Value);
+ }
+ else
+ {
+ this.SetBGColorByPriority(0);
+ }
+ }
+
+ public bool Is(AppointmentModel model)
+ {
+ return (this.appPtr.Equals(model));
+ }
+
+ public void SetListPosition(int index, int count)
+ {
+ this.Margin = new Thickness(
+ (TimeTable.Setting_Z_Spacing * index),
+ 0,
+ (TimeTable.Setting_Z_Spacing * (count - 1)),
+ 0);
+
+ this.SetValue(Canvas.ZIndexProperty, ((TimeTable.Setting_Max_Z_Index - index) < 0) ? 0 : (TimeTable.Setting_Max_Z_Index - index));
+
+ if (index == 0)
+ {
+ this.Opacity = 1;
+ }
+ else
+ {
+ this.Opacity = 0.5;
+ }
+ }
+
+ public void SetListPosition(List list)
+ {
+ int index = list.IndexOf(this.appPtr);
+
+ if (index >= 0)
+ {
+ this.SetListPosition(index, list.Count);
+ }
+ }
+
+ private void TheMainCanvas_SizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ // because Binding did not work, why ever
+ this.TheRect.Width = ((e.NewSize.Width - this.Margin.Right) < 0) ? 0 : (e.NewSize.Width - this.Margin.Right);
+ this.TheRect.Height = e.NewSize.Height;
+ this.TheText.Width = ((e.NewSize.Width - this.Margin.Right) < 0) ? 0 : (e.NewSize.Width - this.Margin.Right);
+ this.TheText.Height = e.NewSize.Height;
+ }
+
+ private void SetText(string text)
+ {
+ if (this.Height < (TimeTable.Setting_Hour_Spacing * 0.5))
+ {
+ this.TheText.Text = "...";
+ this.TheText.Margin = new Thickness(
+ 0,
+ this.Height - (TimeTable.Setting_Hour_Spacing * 0.5),
+ 0,
+ 0);
+ }
+ else
+ {
+ this.TheText.Text = text;
+ }
+ }
+
+ private void SetBGColorByPriority(int prio)
+ {
+ if (prio < TimeTable.Setting_Priority_Colors.Count() && prio >= 0)
+ {
+ this.TheRect.Fill = TimeTable.Setting_Priority_Colors[prio];
+ }
+ }
+ }
+}
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml
index 3194e106..a30baecb 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml
+++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml
@@ -5,70 +5,207 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:weekView="clr-namespace:CampusAppWP8.Utility.Lui.Templates"
xmlns:lui="clr-namespace:CampusAppWP8.Utility.Lui"
+ xmlns:conv="clr-namespace:CampusAppWP8.Utility"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
- >
+ x:Name="root">
+
+
+
+
+
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs
index 395756dd..0dbeb5e8 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs
@@ -9,24 +9,50 @@ namespace CampusAppWP8.Utility.Lui.Templates
{
using System;
using System.Collections.Generic;
+ using System.Collections.ObjectModel;
+ using System.Collections.Specialized;
using System.Linq;
- using System.Net;
using System.Windows;
using System.Windows.Controls;
- using System.Windows.Navigation;
using System.Windows.Media;
- using Microsoft.Phone.Controls;
- using Microsoft.Phone.Shell;
+ using System.Windows.Shapes;
+ using CampusAppWP8.Model.TimeTable;
+ using CampusAppWP8.Pages.TimeTable;
+ /// A week view.
+ /// Fiedler, 06.11.2013.
+ ///
public partial class WeekView : UserControl
{
- public static readonly DependencyProperty StartDateProperty = DependencyProperty.Register("StartDate", typeof(DateTime), typeof(WeekView), new PropertyMetadata(null));
+ /// 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));
- private List borderList = new List();
+ public static readonly DependencyProperty HeadVisibleProperty = DependencyProperty.Register("HeadVisible", typeof(bool), typeof(WeekView), new PropertyMetadata(true));
+
+ public static readonly DependencyProperty ToDayColoringProperty = DependencyProperty.Register("ToDayColoring", typeof(bool), typeof(WeekView), new PropertyMetadata(false));
+ /// 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();
@@ -34,19 +60,340 @@ namespace CampusAppWP8.Utility.Lui.Templates
this.InitLayout();
}
- public DateTime StartDate
+ /// 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));
+
+ for (int i = 0; i < (o as WeekView).dayList.Count; i++)
+ {
+ (o as WeekView).dayList[i].Date = ((DateTime)e.NewValue).AddDays(i);
+ }
+
+ if ((o as WeekView).ToDayColoring == true)
+ {
+ TimeSpan diff = DateTime.Today.Subtract((o as WeekView).DateFrom);
+
+ if (diff.TotalDays >= 0 && diff.TotalDays < 5)
+ {
+ (o as WeekView).SetColumnBackground(diff.Days, new SolidColorBrush(Colors.Orange));
+ }
+ 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)
+ {
+ (e.NewValue as ObservableCollection).CollectionChanged += (o as WeekView).OnAppointmentListChanged;
+ (o as WeekView).SeperateAppointments(e.NewValue as ObservableCollection);
+ }
+
+ if (e.OldValue != null)
+ {
+ (e.OldValue as ObservableCollection).CollectionChanged -= (o as WeekView).OnAppointmentListChanged;
+ }
+ }
+
+ /// 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)
+ {
+ for (int i = 0; i < e.NewItems.Count; i++)
+ {
+ this.SeperateAppointments(e.NewItems[i] as AppointmentModel, e.Action);
+ }
+ }
+ else if (e.Action == NotifyCollectionChangedAction.Remove)
+ {
+ for (int i = 0; i < e.OldItems.Count; i++)
+ {
+ 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)
+ {
+ this.SeperateAppointments(m, NotifyCollectionChangedAction.Add);
+ }
+ }
+
+ /// Seperate appointments.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// The action.
+ private void SeperateAppointments(AppointmentModel model, NotifyCollectionChangedAction action)
+ {
+ for(int i = 0; i < this.dayList.Count; i++)
+ {
+ if (model.IsDate(this.DateFrom.AddDays(i)) == 0)
+ {
+ if (action == NotifyCollectionChangedAction.Add)
+ {
+ this.dayList[i].Appointments.Add(model);
+ }
+ else if (action == NotifyCollectionChangedAction.Remove)
+ {
+ this.dayList[i].Appointments.Remove(model);
+ }
+ }
+ }
+ }
+
+ /// Gets or sets the Date/Time of the date from.
+ /// The date from.
+ public DateTime DateFrom
{
get
{
- return (DateTime)this.GetValue(StartDateProperty);
+ return (DateTime)this.GetValue(DateFromProperty);
}
set
{
- this.SetValue(StartDateProperty, value);
+ this.SetValue(DateFromProperty, value);
}
}
+ /// Gets or sets the Date/Time of the date to.
+ /// The date to.
+ public DateTime DateTo
+ {
+ get
+ {
+ return (DateTime)this.GetValue(DateToProperty);
+ }
+
+ set
+ {
+ this.SetValue(DateToProperty, value);
+ }
+ }
+
+ /// Gets or sets the days.
+ /// The days.
+ public int Days
+ {
+ get
+ {
+ return (int)this.GetValue(DaysProperty);
+ }
+
+ set
+ {
+ this.SetValue(DaysProperty, value);
+ }
+ }
+
+ /// Gets or sets the appointments.
+ /// The appointments.
+ public ObservableCollection Appointments
+ {
+ get
+ {
+ return (ObservableCollection)this.GetValue(AppointmentsProperty);
+ }
+
+ set
+ {
+ this.SetValue(AppointmentsProperty, value);
+ }
+ }
+
+ /// Gets or sets the name of the week.
+ /// The name of the week.
+ public string WeekName
+ {
+ get
+ {
+ return (string)this.GetValue(WeekNameProperty);
+ }
+
+ set
+ {
+ this.SetValue(WeekNameProperty, value);
+
+ }
+ }
+
+ /// Gets or sets the week number.
+ /// The week number.
+ public int WeekNumber
+ {
+ get
+ {
+ return (int)this.GetValue(WeekNumberProperty);
+ }
+
+ set
+ {
+ this.SetValue(WeekNumberProperty, value);
+ }
+ }
+
+ public bool HeadVisible
+ {
+ get
+ {
+ return (bool)this.GetValue(HeadVisibleProperty);
+ }
+
+ set
+ {
+ this.SetValue(HeadVisibleProperty, value);
+ }
+ }
+
+ public bool ToDayColoring
+ {
+ get
+ {
+ return (bool)this.GetValue(ToDayColoringProperty);
+ }
+
+ set
+ {
+ this.SetValue(ToDayColoringProperty, value);
+ }
+ }
+
+ public bool Day_1_Visibility
+ {
+ get
+ {
+ if ((this.Days <= 0) && (this.Col_1.Width.IsAuto == false))
+ {
+ this.Col_1.Width = new GridLength(0, GridUnitType.Auto);
+ this.Col_H_1.Width = new GridLength(0, GridUnitType.Auto);
+ }
+
+ return (this.Days > 0);
+ }
+ }
+
+ public bool Day_2_Visibility
+ {
+ get
+ {
+ if ((this.Days <= 1) && (this.Col_2.Width.IsAuto == false))
+ {
+ this.Col_2.Width = new GridLength(0, GridUnitType.Auto);
+ this.Col_H_2.Width = new GridLength(0, GridUnitType.Auto);
+ }
+
+ return (this.Days > 1);
+ }
+ }
+
+ public bool Day_3_Visibility
+ {
+ get
+ {
+ if ((this.Days <= 2) && (this.Col_3.Width.IsAuto == false))
+ {
+ this.Col_3.Width = new GridLength(0, GridUnitType.Auto);
+ this.Col_H_3.Width = new GridLength(0, GridUnitType.Auto);
+ }
+
+ return (this.Days > 2);
+ }
+ }
+
+ public bool Day_4_Visibility
+ {
+ get
+ {
+ if ((this.Days <= 3) && (this.Col_4.Width.IsAuto == false))
+ {
+ this.Col_4.Width = new GridLength(0, GridUnitType.Auto);
+ this.Col_H_4.Width = new GridLength(0, GridUnitType.Auto);
+ }
+
+ return (this.Days > 3);
+ }
+ }
+
+ public bool Day_5_Visibility
+ {
+ get
+ {
+ if ((this.Days <= 4) && (this.Col_5.Width.IsAuto == false))
+ {
+ this.Col_5.Width = new GridLength(0, GridUnitType.Auto);
+ this.Col_H_5.Width = new GridLength(0, GridUnitType.Auto);
+ }
+
+ return (this.Days > 4);
+ }
+ }
+
+ public bool Day_6_Visibility
+ {
+ get
+ {
+ if ((this.Days <= 5) && (this.Col_6.Width.IsAuto == false))
+ {
+ this.Col_6.Width = new GridLength(0, GridUnitType.Auto);
+ this.Col_H_6.Width = new GridLength(0, GridUnitType.Auto);
+ }
+
+ return (this.Days > 5);
+ }
+ }
+
+ public bool Day_7_Visibility
+ {
+ get
+ {
+ if ((this.Days <= 6) && (this.Col_7.Width.IsAuto == false))
+ {
+ this.Col_7.Width = new GridLength(0, GridUnitType.Auto);
+ this.Col_H_7.Width = new GridLength(0, GridUnitType.Auto);
+ }
+
+ return (this.Days > 6);
+ }
+ }
+
+ /// 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())
@@ -55,6 +402,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++)
@@ -69,13 +430,34 @@ namespace CampusAppWP8.Utility.Lui.Templates
this.borderList.Add(this.ThuBorder);
this.borderList.Add(this.FriBorder);
- this.TimeList.ItemsSource = this.timeStrings;
+ this.dayList.Add(this.MonList);
+ this.dayList.Add(this.TueList);
+ this.dayList.Add(this.WedList);
+ this.dayList.Add(this.ThuList);
+ this.dayList.Add(this.FriList);
+
+ this.TimeList.ItemsSource = this.timeStrings;
+ }
+
+ /// 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);
+ }
+
+ private void DrawMultiBubble()
+ {
+ Rectangle circle = new Rectangle();
+
+ circle.RadiusX = 10;
+ circle.RadiusY = 10;
+ circle.Width = 20;
+ circle.Height = 20;
+
- //this.MonList.ItemsSource = this.monStrings;
- //this.TueList.ItemsSource = this.monStrings;
- //this.WedList.ItemsSource = this.monStrings;
- //this.ThuList.ItemsSource = this.monStrings;
- //this.FriList.ItemsSource = this.monStrings;
}
}
}
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml
index e964d8ec..a85ecd37 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml
+++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml
@@ -3,32 +3,42 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
+ xmlns:utility="clr-namespace:CampusAppWP8.Utility"
mc:Ignorable="d"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
+ x:Name="root"
>
-
+
+
+
+
+
-
-
+
+
diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs
index f7cbf78d..8327b81b 100644
--- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs
+++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs
@@ -10,6 +10,8 @@ namespace CampusAppWP8.Utility.Lui.Templates
{
using System;
using System.Collections.Generic;
+ using System.Collections.ObjectModel;
+ using System.Collections.Specialized;
using System.Linq;
using System.Net;
using System.Windows;
@@ -20,19 +22,119 @@ namespace CampusAppWP8.Utility.Lui.Templates
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows.Data;
-
+ using CampusAppWP8.Model.TimeTable;
+ using CampusAppWP8.Utility;
+
+ /// 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()
{
+ this.Appointments = new ObservableCollection();
+
this.InitializeComponent();
+
+ this.TheGrid.SizeChanged += new SizeChangedEventHandler(this.TheGridSizeChanged);
+ }
+
+ private void TheGridSizeChanged(object sender, SizeChangedEventArgs e)
+ {
+ this.MainCanvas.Width = e.NewSize.Width;
+ }
+
+ /// 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)
+ {
+ (e.NewValue as ObservableCollection).CollectionChanged += (o as WeekViewDay).OnAppointmentListChanged;
+ }
+
+ if (e.OldValue != null)
+ {
+ (e.OldValue as ObservableCollection).CollectionChanged -= (o as WeekViewDay).OnAppointmentListChanged;
+ }
+ }
+
+ /// 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)
+ {
+ for (int i = 0; i < e.NewItems.Count; i++)
+ {
+ this.CheckStackAdd(e.NewItems[i] as AppointmentModel);
+ }
+ }
+ else if (e.Action == NotifyCollectionChangedAction.Remove)
+ {
+ for (int i = 0; i < e.OldItems.Count; i++)
+ {
+ 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
+ {
+ return (ObservableCollection)this.GetValue(AppointmentsProperty);
+ }
+
+ set
+ {
+ this.SetValue(AppointmentsProperty, value);
+ }
+ }
+
+
+
+ /// Gets or sets the Date/Time of the date.
+ /// The date.
+ public DateTime Date
+ {
+ get
+ {
+ return (DateTime)this.GetValue(DateProperty);
+ }
+
+ set
+ {
+ this.SetValue(DateProperty, value);
+ }
}
/// Gets or sets the background list elements.
@@ -75,6 +177,257 @@ 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());
+
+ if (intersect.Count() == 0)
+ {
+ this.DrawApp(model, null);
+ }
+ else
+ {
+ List intersecStack = new List();
+
+ for (int i = 0; i < intersect.Count(); i++)
+ {
+ for (int s = 0; s < this.stacks.Count; s++)
+ {
+ if (this.stacks[s].IndexOf(this.Appointments[i]) >= 0)
+ {
+ intersecStack.Add(s);
+ }
+ }
+ }
+
+ if (intersecStack.Count == 0)
+ {
+ List newStack = new List();
+
+ for (int k = 0; k < intersect.Count(); k++)
+ {
+ newStack.Add(this.Appointments[intersect[k]]);
+ }
+
+ newStack.Add(model);
+ this.stacks.Add(newStack);
+
+ this.DrawStack(model, newStack);
+ }
+ else if (intersecStack.Count == 1)
+ {
+ this.stacks[intersecStack[0]].Add(model);
+ this.DrawStack(model, this.stacks[intersecStack[0]]);
+ }
+ else
+ {
+ List newStack = new List();
+ List> tempStackList = new List>();
+
+ for (int k = 0; k < intersecStack.Count; k++)
+ {
+ tempStackList.Add(this.stacks[intersecStack[k]]);
+ newStack.AddRange(this.stacks[intersecStack[k]]);
+ }
+
+ newStack.Add(model);
+
+ for (int k = 0; k < tempStackList.Count; k++)
+ {
+ this.stacks.Remove(tempStackList[k]);
+ }
+
+ this.stacks.Add(newStack);
+
+ this.DrawStack(model, newStack);
+ }
+ }
+ }
+
+ /// Check stack remove.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ private void CheckStackRemove(AppointmentModel model)
+ {
+ int stackIndex = -1;
+
+ for (int i = 0; i < this.stacks.Count; i++)
+ {
+ if (this.stacks[i].IndexOf(model) >= 0)
+ {
+ stackIndex = i;
+ }
+ }
+
+ if (stackIndex >= 0)
+ {
+ this.stacks[stackIndex].Remove(model);
+
+ this.DrawStack(null, this.stacks[stackIndex]);
+
+ if (this.stacks[stackIndex].Count <= 1)
+ {
+ this.stacks.RemoveAt(stackIndex);
+ }
+ }
+
+ int removeIndex = -1;
+
+ for (int i = 0; i < this.UserCanvas.Children.Count; i++)
+ {
+ if ((this.UserCanvas.Children[i] as AppointmentCanvas).Is(model))
+ {
+ removeIndex = i;
+ }
+ }
+
+ if (removeIndex >= 0)
+ {
+ this.UserCanvas.Children.RemoveAt(removeIndex);
+ }
+ }
+
+ /// 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++)
+ {
+ if (stack[i].Equals(newModel))
+ {
+ this.DrawApp(newModel, stack);
+ }
+ else
+ {
+ this.ManipulateAppCanvas(stack[i], i, stack.Count);
+ }
+ }
+ }
+
+ /// 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)
+ {
+ this.ManipulateAppCanvas(model, this.stacks[stackIndex]);
+ }
+ }
+
+ /// Manipulate application canvas.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ /// The list.
+ private void ManipulateAppCanvas(AppointmentModel model, List list)
+ {
+ int index = list.IndexOf(model);
+
+ if (index >= 0)
+ {
+ this.ManipulateAppCanvas(model, index, list.Count);
+ }
+ }
+
+ /// 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;
+
+ for (int i = 0; i < this.UserCanvas.Children.Count; i++)
+ {
+ if ((this.UserCanvas.Children[i] as AppointmentCanvas).Is(model))
+ {
+ can = this.UserCanvas.Children[i] as AppointmentCanvas;
+ }
+ }
+
+ if (can != null)
+ {
+ can.SetListPosition(index, count);
+ }
+ }
+
+ /// 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)
+ {
+ this.DrawApp(model, this.stacks[stackIndex]);
+ }
+ else
+ {
+ this.DrawApp(model, null);
+ }
+ }
+
+ /// 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);
+
+ newCan.DoubleTap += new EventHandler(model.OnCanvasClick);
+
+ Binding widthBind = new Binding("Width");
+ widthBind.ElementName = "UserCanvas";
+ widthBind.Converter = new DoubleNaNConverter();
+ widthBind.Mode = BindingMode.OneWay;
+ newCan.SetBinding(WidthProperty, widthBind);
+
+ if (stack != null)
+ {
+ newCan.SetListPosition(stack);
+ }
+
+ this.UserCanvas.Children.Add(newCan);
+ }
+
+
+
+ /// Un draw application.
+ /// Fiedler, 06.11.2013.
+ /// The model.
+ private void UnDrawApp(AppointmentModel model)
+ {
+ int index = -1;
+
+ for (int i = 0; i < this.UserCanvas.Children.Count; i++)
+ {
+ if ((this.UserCanvas.Children[i] as AppointmentCanvas).Is(model))
+ {
+ index = i;
+ }
+ }
+
+ if (index >= 0)
+ {
+ this.UserCanvas.Children.RemoveAt(index);
+ }
+ }
+
+ /*
+ protected override void OnDoubleTap(System.Windows.Input.GestureEventArgs e)
+ {
+ base.OnDoubleTap(e);
+ }
+ */
+
/// Draw lines.
/// Fiedler, 22.10.2013.
private void DrawLines()
@@ -85,8 +438,9 @@ namespace CampusAppWP8.Utility.Lui.Templates
this.BGCanvas.Children.Clear();
Binding colLineBind = new Binding();
- colLineBind.Path = new PropertyPath("ActualWidth");
- colLineBind.ElementName = "MainCanvas";
+ colLineBind.Path = new PropertyPath("Width");
+ colLineBind.ElementName = "BGCanvas";
+ colLineBind.Converter = new DoubleNaNConverter();
colLineBind.Mode = BindingMode.OneWay;
for (int i = 1; i < this.BgListElements; i++)
diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Departments/DepartmentModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Departments/DepartmentModel.cs
index 947a52c4..f86a9159 100644
--- a/CampusAppWP8/CampusAppWPortalLib8/Model/Departments/DepartmentModel.cs
+++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Departments/DepartmentModel.cs
@@ -106,7 +106,7 @@ namespace CampusAppWPortalLib8.Model.Departments
foreach (FacultyModel temp in this.Faculties)
{
- if ((temp.HasChanged() == true) && (retValue == false))
+ if (temp.HasChanged() == true)
{
retValue = true;
}