diff --git a/CampusAppWP8/CampusAppWP8/App.xaml.cs b/CampusAppWP8/CampusAppWP8/App.xaml.cs index 81f3a560..65acbc71 100644 --- a/CampusAppWP8/CampusAppWP8/App.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/App.xaml.cs @@ -171,11 +171,18 @@ namespace CampusAppWP8 if (Settings.AppSetting.GeoWatchEnable) { - Thread thread = new Thread(new ThreadStart(Utilities.DetermineAndStoreCurrentPositionForce)); + Thread thread = new Thread(new ThreadStart(this.PositionThread)); thread.Start(); } } + /// Position thread. + /// Stubbfel, 18.11.2013. + private void PositionThread() + { + Utilities.DetermineAndStoreCurrentPositionForce(); + } + /// /// Load the usersettings from the store /// diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index bad54601..00e17b16 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -102,6 +102,8 @@ App.xaml + + @@ -141,6 +143,7 @@ AppointmentEdit.xaml + TimeTableDay.xaml @@ -151,6 +154,8 @@ TimeTableWeek.xaml + + @@ -236,6 +241,7 @@ + @@ -247,6 +253,12 @@ WeekViewPivotHeader.xaml + + AppointmentCanvas.xaml + + + MultiValueTextBlock.xaml + WeekView.xaml @@ -254,6 +266,7 @@ WeekViewDay.xaml + NFC.xaml @@ -281,8 +294,6 @@ - - CampusMapPage.xaml @@ -531,6 +542,11 @@ Designer MSBuild:Compile + + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs index 030d6aae..670e02b3 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeed.cs @@ -13,12 +13,19 @@ namespace CampusAppWP8.Feed.Mensa using CampusAppWP8.Model; using CampusAppWPortalLib8.Model.Mensa; using CampusAppWPortalLib8.Model; + using CampusAppWP8.Resources; + using CampusAppWPortalLib8.Model.Settings; /// This Class is for MensaFeeds. /// Stubbfel, 14.10.2013. /// public abstract class MensaFeed : XmlModel { + #region Member + /// The price feed. + private PriceFeed priceFeed = null; + + #endregion #region Constructor /// Initializes a new instance of the class. @@ -31,6 +38,11 @@ namespace CampusAppWP8.Feed.Mensa this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate); this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate); this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate); + + this.priceFeed = new PriceFeed(); + this.priceFeed.OnLoaded += this.PriceFeedIsReady; + this.priceFeed.OnFailedLoad += this.PriceFeedIsFailed; + this.priceFeed.LoadData(); } #endregion @@ -41,6 +53,10 @@ namespace CampusAppWP8.Feed.Mensa /// The title. public string Title { get; protected set; } + /// Gets the title. + /// The title. + public Campus Campus { get; protected set; } + #endregion #region Method @@ -119,6 +135,79 @@ namespace CampusAppWP8.Feed.Mensa return true; } + /// + /// Ändert die Quelldaten vor der Übergabe an das Ziel zur Anzeige in der Benutzeroberfläche. + /// + /// Fiedler, 14.11.2013. + /// + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) + { + string retValue = string.Empty; + int intVal = -1; + int intParam = -1; + + if (value is int) + { + intVal = (int)value; + } + else if (value is string) + { + intVal = int.Parse((string)value); + } + + if (parameter is int) + { + intParam = (int)parameter; + } + else if (parameter is string) + { + intParam = int.Parse((string)parameter); + } + + if ((intVal >= 0) && (intParam >= 0)) + { + if (this.priceFeed != null && this.priceFeed.Model != null) + { + PriceMealModel model = this.priceFeed.Model.GetCanteen(intParam).GetPriceMealModel(intVal); + retValue = AppResources.Students + ": " + model.PriceStudentStr + " € " + AppResources.Employees + ": " + model.PriceEmployeeStr + " € " + AppResources.Guests + ": " + model.PriceGuestStr + " €"; + } + } + + return retValue; + } + + /// Price feed is ready. + /// Fiedler, 14.11.2013. + private void PriceFeedIsReady() + { + this.priceFeed.SaveData(); + } + + /// Sets the prices. + /// Stubbfel, 18.11.2013. + public void SetPrices() + { + if (this.Model == null || this.Model.Menus == null || this.priceFeed == null || this.priceFeed.Model == null) + { + return; + } + + foreach(MenuModel menu in this.Model.Menus) { + foreach (MealModel meal in menu.Meals) + { + PriceMealModel model = this.priceFeed.Model.GetCanteen(this.Campus).GetPriceMealModel(meal.MealId); + meal.Price = AppResources.Students + ": " + model.PriceStudentStr + " € " + AppResources.Employees + ": " + model.PriceEmployeeStr + " € " + AppResources.Guests + ": " + model.PriceGuestStr + " €"; + } + } + + } + + /// Price feed is failed. + /// Fiedler, 14.11.2013. + private void PriceFeedIsFailed() + { + } + #endregion #endregion diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBMain.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBMain.cs index e0765814..7ea6dcf3 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBMain.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBMain.cs @@ -23,6 +23,7 @@ namespace CampusAppWP8.Feed.Mensa : base(Constants.FileMensa_Shedule_CBMain, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBMain) { this.Title = CampusAppWPortalLib8.Resources.AppResources.Campus_CBMain; + this.Campus = CampusAppWPortalLib8.Model.Settings.Campus.CB_MAIN; } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBNorth.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBNorth.cs index a6956d5f..b6959904 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBNorth.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBNorth.cs @@ -23,6 +23,7 @@ namespace CampusAppWP8.Feed.Mensa : base(Constants.FileMensa_Shedule_CBNorth, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBNorth) { this.Title = CampusAppWPortalLib8.Resources.AppResources.Campus_CBNorth; + this.Campus = CampusAppWPortalLib8.Model.Settings.Campus.CB_NORTH; } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBSouth.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBSouth.cs index fc33a1da..7c0cf80f 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBSouth.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedCBSouth.cs @@ -23,6 +23,7 @@ namespace CampusAppWP8.Feed.Mensa : base(Constants.FileMensa_Shedule_CBSouth, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_CBSouth) { this.Title = CampusAppWPortalLib8.Resources.AppResources.Campus_CBSouth; + this.Campus = CampusAppWPortalLib8.Model.Settings.Campus.CB_SOUTH; } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedSBFMain.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedSBFMain.cs index 0fe1fc1e..17c6c64e 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedSBFMain.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/MensaFeedSBFMain.cs @@ -23,6 +23,7 @@ namespace CampusAppWP8.Feed.Mensa : base(Constants.FileMensa_Shedule_SBFMain, CampusAppWPortalLib8.Resources.Constants.UrlMensa_Week_SBFMain) { this.Title = CampusAppWPortalLib8.Resources.AppResources.Campus_SFBMain; + this.Campus = CampusAppWPortalLib8.Model.Settings.Campus.SFB_MAIN; } #endregion diff --git a/CampusAppWP8/CampusAppWP8/Feed/Mensa/PriceFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Mensa/PriceFeed.cs new file mode 100644 index 00000000..a5380621 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Feed/Mensa/PriceFeed.cs @@ -0,0 +1,82 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 13.11.2013 +// Implements the price feed class +//----------------------------------------------------------------------- +namespace CampusAppWP8.Feed.Mensa +{ + using System; + using System.IO; + using CampusAppWP8.Model; + using CampusAppWP8.Resources; + using CampusAppWPortalLib8.Model.Mensa; + using CampusAppWPortalLib8.Model; + + /// A price feed. + /// Fiedler, 13.11.2013. + /// + public class PriceFeed : XmlModel + { + /// Initializes a new instance of the PriceFeed class. + /// Fiedler, 13.11.2013. + public PriceFeed() + : base(ModelType.FileAndFeed, Constants.FileMensaPrice, Constants.UrlMensaPrice) + { + this.IsFileUpToDateOnLoad += new IsFileUpToDate(this.CheckIsFileUpToDate); + this.IsModelUpToDateOnLoad += new IsModelUpToDate(this.CheckIsModelUpToDate); + this.IsFileUpToDateOnSave += new IsFileUpToDate(this.CheckIsFileUpToDate); + } + + /// Check is model up to date. + /// Fiedler, 13.11.2013. + /// The model. + /// true if it succeeds, false if it fails. + private bool CheckIsModelUpToDate(PriceModel model) + { + bool retValue = true; + + if (model == null) + { + retValue = false; + } + + return retValue; + } + + /// Check is file up to date. + /// Fiedler, 13.11.2013. + /// The model. + /// Information describing the file. + /// true if it succeeds, false if it fails. + private bool CheckIsFileUpToDate(PriceModel model, FileInfo fileInfo) + { + if (fileInfo == null || !fileInfo.Exists || fileInfo.Length < 1) + { + return false; + } + + return this.CheckIsUpToDate(fileInfo.LastWriteTime); + } + + /// Check is up to date. + /// Fiedler, 13.11.2013. + /// The last modified Date/Time. + /// true if it succeeds, false if it fails. + private bool CheckIsUpToDate(DateTime lastModified) + { + bool retValue = false; + TimeSpan diff = DateTime.Now.Subtract(lastModified); + + + if (diff.TotalDays < 7) + { + retValue = true; + } + + return retValue; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Feed/Openinghours/OpeninghoursFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/Openinghours/OpeninghoursFeed.cs index 5c4c974d..7f331eef 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/Openinghours/OpeninghoursFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/Openinghours/OpeninghoursFeed.cs @@ -11,15 +11,15 @@ namespace CampusAppWP8.Feed.Openinghours using System; using System.IO; using CampusAppWP8.Model; - using CampusAppWP8.Model.Openinghours; using CampusAppWP8.Resources; using CampusAppWP8.Utility; using CampusAppWPortalLib8.Model; + using CampusAppWPortalLib8.Model.Openinghours; /// This Class is for MesaFeeds. /// fiedlchr, 14.10.2013. /// - public class OpeninghoursFeed : XmlModel + public class OpeninghoursFeed : XmlModel { #region Constructor @@ -41,7 +41,7 @@ namespace CampusAppWP8.Feed.Openinghours /// fiedlchr, 14.10.2013. /// reference of the FeedModel. /// true, if model is up-to-date, otherwise false. - private bool CheckIsModelUpToDate(OpeninghoursWp8Model model) + private bool CheckIsModelUpToDate(OpeninghoursModel model) { bool retValue = true; @@ -62,7 +62,7 @@ namespace CampusAppWP8.Feed.Openinghours /// reference of the FeedModel. /// info about the file. /// true, if file is up-to-date, otherwise false. - private bool CheckIsFileUpToDateOnLoad(OpeninghoursWp8Model model, FileInfo info) + private bool CheckIsFileUpToDateOnLoad(OpeninghoursModel model, FileInfo info) { bool retValue = true; @@ -82,7 +82,7 @@ namespace CampusAppWP8.Feed.Openinghours /// reference of the FeedModel. /// info about the file. /// true, if file is up-to-date, otherwise false. - private bool CheckIsFileUpToDateOnSave(OpeninghoursWp8Model model, FileInfo info) + private bool CheckIsFileUpToDateOnSave(OpeninghoursModel model, FileInfo info) { bool retValue = true; 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/Openinghours/OpeninghoursInstitutionWp8Model.cs b/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursInstitutionWp8Model.cs deleted file mode 100644 index 7c4cfb96..00000000 --- a/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursInstitutionWp8Model.cs +++ /dev/null @@ -1,156 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Company copyright tag. -// -// fiedlchr -// 24.06.2013 -//----------------------------------------------------------------------------- - -namespace CampusAppWP8.Model.Openinghours -{ - using System.Globalization; - using System.Windows; - using System.Xml.Serialization; - - /// - /// Model for menu - /// - public class OpeninghoursInstitutionWp8Model : CampusAppWPortalLib8.Model.Openinghours.OpeninghoursInstitutionModel - { - #region Property - - /// - /// Gets the visibility state of the monday TextBlock. - /// - public Visibility VisibleMonday - { - get - { - return ((this.Monday == string.Empty) || (this.Monday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the tuesday TextBlock. - /// - public Visibility VisibleTuesday - { - get - { - return ((this.Tuesday == string.Empty) || (this.Tuesday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the wednesday TextBlock. - /// - public Visibility VisibleWednesday - { - get - { - return ((this.Wednesday == string.Empty) || (this.Wednesday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the thursday TextBlock. - /// - public Visibility VisibleThursday - { - get - { - return ((this.Thursday == string.Empty) || (this.Thursday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the friday TextBlock. - /// - public Visibility VisibleFriday - { - get - { - return ((this.Friday == string.Empty) || (this.Friday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the saturday TextBlock. - /// - public Visibility VisibleSaturday - { - get - { - return ((this.Saturday == string.Empty) || (this.Saturday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the sunday TextBlock. - /// - public Visibility VisibleSunday - { - get - { - return ((this.Sunday == string.Empty) || (this.Sunday.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the comment. - /// - public Visibility VisibleComment - { - get - { - return ((this.Comment == string.Empty) || (this.Comment.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the email address. - /// - public Visibility VisibleEMail - { - get - { - return ((this.EMail == string.Empty) || (this.EMail.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the phone number. - /// - public Visibility VisiblePhone - { - get - { - return ((this.Phone == string.Empty) || (this.Phone.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the room. - /// - public Visibility VisibleRoom - { - get - { - return ((this.Room == string.Empty) || (this.Room.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - /// - /// Gets the visibility state of the building. - /// - public Visibility VisibleBuilding - { - get - { - return ((this.Building == string.Empty) || (this.Building.Length == 0)) ? Visibility.Collapsed : Visibility.Visible; - } - } - - #endregion - } -} diff --git a/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursWp8Model.cs b/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursWp8Model.cs deleted file mode 100644 index 88b480bd..00000000 --- a/CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursWp8Model.cs +++ /dev/null @@ -1,20 +0,0 @@ -//----------------------------------------------------------------------------- -// -// Company copyright tag. -// -// fiedlchr -// 24.06.2013 -//----------------------------------------------------------------------------- - -namespace CampusAppWP8.Model.Openinghours -{ - using System.Xml.Serialization; - - /// - /// Model for opening hours. - /// - [XmlRoot("root")] - public class OpeninghoursWp8Model : CampusAppWPortalLib8.Model.Openinghours.OpeninghoursModel - { - } -} 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/Campusmap/RoomListPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml index 12d47a20..ac0bb7cd 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml @@ -14,7 +14,8 @@ Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="Portrait" Orientation="Portrait" mc:Ignorable="d" - shell:SystemTray.IsVisible="True"> + shell:SystemTray.IsVisible="True" + x:Name="root"> @@ -26,34 +27,43 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml.cs index da9c7fce..69fb12ef 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml.cs @@ -8,6 +8,7 @@ //----------------------------------------------------------------------- namespace CampusAppWP8.Pages.Campusmap { + using System; using System.Collections.Generic; using System.Linq; using System.Windows; @@ -23,6 +24,7 @@ namespace CampusAppWP8.Pages.Campusmap using CampusAppWPortalLib8.Model.Campusmap.Pin; using CampusAppWPortalLib8.Model.Utility; using Microsoft.Phone.Controls; + using Microsoft.Phone.Shell; using CampusAppWPortalLib8.Model.GeoDb; /// Class of the RoomListPage. @@ -49,8 +51,7 @@ namespace CampusAppWP8.Pages.Campusmap /// The offset point. private MapPoint offsetPoint; - /// The layer list picker. - private ListPickerItemListModel layerListPicker; + private string selectedLayer = string.Empty; #endregion @@ -65,6 +66,20 @@ namespace CampusAppWP8.Pages.Campusmap #endregion + private string SelectedLayer + { + get + { + return this.selectedLayer; + } + + set + { + this.selectedLayer = value; + this.LayerTag.Text = value; + } + } + #region Method #region protected @@ -122,12 +137,12 @@ namespace CampusAppWP8.Pages.Campusmap string layerKey = this.building.GetLayerKey(NavigationContext.QueryString[Constants.ParamRoomId]); if (layerKey != null) { - this.Layer.SelectedIndex = this.layerListPicker.GetIndexOrDefault(layerKey); + this.SelectedLayer = layerKey; this.ShowCurrentRoom(NavigationContext.QueryString[Constants.ParamRoomId]); } } - this.ShowLayerPlaces(((ListPickerItemModel)this.Layer.SelectedItem).Value); + this.ShowLayerPlaces((this.selectedLayer.Length > 0) ? this.selectedLayer : (this.ApplicationBar.MenuItems[0] as ApplicationBarMenuItem).Text); } else { @@ -269,14 +284,19 @@ namespace CampusAppWP8.Pages.Campusmap /// Stubbfel, 14.10.2013. private void CreateLayerListPicker() { - this.layerListPicker = new ListPickerItemListModel(); + this.ApplicationBar.MenuItems.Clear(); foreach (string layername in this.building.Layers.Keys) { - this.layerListPicker.AddItem(layername, layername); + ApplicationBarMenuItem newMenuItem = new ApplicationBarMenuItem(layername); + newMenuItem.Click += this.OnMenuItemClicked; + this.ApplicationBar.MenuItems.Add(newMenuItem); } - this.Layer.ItemsSource = this.layerListPicker.List; + if (this.ApplicationBar.MenuItems.Count > 0) + { + this.SelectedLayer = (this.ApplicationBar.MenuItems[0] as ApplicationBarMenuItem).Text; + } } /// Shows the layer places. @@ -360,13 +380,13 @@ namespace CampusAppWP8.Pages.Campusmap Canvas.SetZIndex(this.imgMap, 0); } - /// Event handler. Called by Layer for selection changed events. - /// Stubbfel, 14.10.2013. - /// Source of the event. - /// Selection changed event information. - private void Layer_SelectionChanged(object sender, SelectionChangedEventArgs e) + private void OnMenuItemClicked(object sender, System.EventArgs e) { - this.ShowLayerPlaces(((ListPickerItemModel)this.Layer.SelectedItem).Value); + if (this.SelectedLayer.Equals((sender as ApplicationBarMenuItem).Text) == false) + { + this.SelectedLayer = (sender as ApplicationBarMenuItem).Text; + this.ShowLayerPlaces((sender as ApplicationBarMenuItem).Text); + } } /// Clears the map described by removeTags. @@ -400,6 +420,28 @@ namespace CampusAppWP8.Pages.Campusmap #endregion + /// Event handler. Called by ZoomIn for tap events. + /// Fiedler, 15.11.2013. + /// Source of the event. + /// Gesture event information. + private void ZoomIn_Tap(object sender, System.Windows.Input.GestureEventArgs e) + { + //throw new NotImplementedException("TODO"); + (this.MapCanvas.RenderTransform as ScaleTransform).ScaleX *= 1.5; + (this.MapCanvas.RenderTransform as ScaleTransform).ScaleY *= 1.5; + } + + /// Event handler. Called by ZoomOut for tap events. + /// Fiedler, 15.11.2013. + /// Source of the event. + /// Gesture event information. + private void ZoomOut_Tap(object sender, System.Windows.Input.GestureEventArgs e) + { + //throw new NotImplementedException("TODO"); + (this.MapCanvas.RenderTransform as ScaleTransform).ScaleX /= 1.5; + (this.MapCanvas.RenderTransform as ScaleTransform).ScaleY /= 1.5; + } + #endregion } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml index 6377d8db..ea1339ba 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml @@ -8,14 +8,18 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:lui="clr-namespace:CampusAppWP8.Utility.Lui.Button" xmlns:header="clr-namespace:CampusAppWP8.Utility.Lui.Header" + xmlns:lu="clr-namespace:CampusAppWP8.Utility.Lui" xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit" xmlns:page="clr-namespace:CampusAppWP8.Utility.Lui.Page" + xmlns:utility="clr-namespace:CampusAppWP8.Utility" mc:Ignorable="d" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="PortraitOrLandscape" Orientation="Portrait" - shell:SystemTray.IsVisible="True"> + shell:SystemTray.IsVisible="True" + x:Name="root"> + @@ -25,7 +29,7 @@ - + @@ -44,18 +48,26 @@ - - - - - - - - + + + + + + + + + + + + + + + + - - - + + + @@ -79,6 +91,9 @@ + + + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs index 376a77a4..e837fc79 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs @@ -48,6 +48,9 @@ namespace CampusAppWP8.Pages.Mensa /// Flag for forcing webLoad. private bool forceLoad = false; + /// Identifier for the location. + public int locationID = -1; + #endregion #region Constructor @@ -56,10 +59,14 @@ namespace CampusAppWP8.Pages.Mensa /// Stubbfel, 15.10.2013. public MensaPage() { + this.locationID = 0; + this.InitializeComponent(); ApplicationBarMenuItem menuItem1 = ApplicationBar.MenuItems[0] as ApplicationBarMenuItem; ApplicationBarMenuItem menuItem2 = ApplicationBar.MenuItems[1] as ApplicationBarMenuItem; ApplicationBarMenuItem menuItem3 = ApplicationBar.MenuItems[2] as ApplicationBarMenuItem; + ApplicationBarMenuItem menuItem4 = ApplicationBar.MenuItems[3] as ApplicationBarMenuItem; + ApplicationBarMenuItem menuItem5 = ApplicationBar.MenuItems[4] as ApplicationBarMenuItem; if (menuItem1 != null) { @@ -76,11 +83,36 @@ namespace CampusAppWP8.Pages.Mensa menuItem3.Text = CampusAppWPortalLib8.Resources.AppResources.Campus_SFBMain; } + if (menuItem4 != null) + { + menuItem4.Text = AppResources.MensaApp_Dayplan + " " + AppResources.Copy; + } + + if (menuItem5 != null) + { + menuItem5.Text = AppResources.MensaApp_Weekplan + " " + AppResources.Copy; + } + this.DefHeader.ProgressVisibility = Visibility.Visible; } #endregion + /// Gets or sets the identifier of the location. + /// The identifier of the location. + public int LocationID + { + get + { + return this.locationID; + } + + set + { + this.locationID = value; + } + } + #region Method #region protected @@ -165,12 +197,12 @@ namespace CampusAppWP8.Pages.Mensa this.InitializeFeed(mensaCampus); } } - - /* this.campusApi = new CampusSpsApi(); - this.campusApi.OnLoaded += new SpsApi.OnIO(this.SpsApiIsReady); - this.campusApi.OnFailedLoad += new SpsApi.OnFailed(this.SpsApiIsFail); - this.campusApi.SetupCurrentCampusRequest(); - this.campusApi.LoadData();*/ + + /* this.campusApi = new CampusSpsApi(); + this.campusApi.OnLoaded += new SpsApi.OnIO(this.SpsApiIsReady); + this.campusApi.OnFailedLoad += new SpsApi.OnFailed(this.SpsApiIsFail); + this.campusApi.SetupCurrentCampusRequest(); + this.campusApi.LoadData();*/ } /// Method initialize the Feed depends of a campus. @@ -214,6 +246,7 @@ namespace CampusAppWP8.Pages.Mensa /// Stubbfel, 15.10.2013. private void FeedIsReady() { + this.feed.SetPrices(); this.SetupMensaPivot(); this.DefHeader.ProgressVisibility = Visibility.Collapsed; } @@ -341,6 +374,7 @@ namespace CampusAppWP8.Pages.Mensa /// Event information. private void ApplicationBarMenuItem_Click(object sender, EventArgs e) { + this.LocationID = 0; this.DefHeader.ProgressVisibility = Visibility.Visible; this.InitializeFeed(CampusAppWPortalLib8.Model.Settings.Campus.CB_MAIN); } @@ -351,6 +385,7 @@ namespace CampusAppWP8.Pages.Mensa /// Event information. private void ApplicationBarMenuItem2_Click(object sender, EventArgs e) { + this.LocationID = 1; this.DefHeader.ProgressVisibility = Visibility.Visible; this.InitializeFeed(CampusAppWPortalLib8.Model.Settings.Campus.CB_SOUTH); } @@ -361,6 +396,7 @@ namespace CampusAppWP8.Pages.Mensa /// Event information. private void ApplicationBarMenuItem3_Click(object sender, EventArgs e) { + this.LocationID = 2; this.DefHeader.ProgressVisibility = Visibility.Visible; this.InitializeFeed(CampusAppWPortalLib8.Model.Settings.Campus.SFB_MAIN); } @@ -381,6 +417,80 @@ namespace CampusAppWP8.Pages.Mensa Clipboard.SetText(copyText); } + /// Copies the menu of the selected day. + /// Stubbfel, 18.11.2013. + /// button object. + /// Event information. + private void CopyDay(object sender, EventArgs e) + { + if (this.MensaPivot == null) + { + return; + } + + int selecetdIndex = this.MensaPivot.SelectedIndex; + + if (this.feed == null || this.feed.Model == null || selecetdIndex >= this.feed.Model.Menus.Count || selecetdIndex < 0) + { + return; + } + + MenuModel menu = this.feed.Model.Menus[selecetdIndex]; + string copyText = AppResources.MensaApp_Dayplan + " (" + menu.Day + " - " + menu.Date + ") - " + AppResources.Setting_UserCampus + " " + this.feed.Title + " :"; + copyText = Wp8StringManager.AddNewLine(copyText); + + foreach (MealModel meal in menu.Meals) + { + copyText += meal.MealName + ": " + meal.MealDesc; + copyText = Wp8StringManager.AddNewLine(copyText); + } + + + Clipboard.SetText(copyText); + } + + /// Copies all meals from the week. + /// Stubbfel, 18.11.2013. + /// button object. + /// Event information. + private void CopyWeek(object sender, EventArgs e) + { + + if (this.MensaPivot == null || this.feed == null || this.feed.Model == null) + { + return; + } + + string startDate = null; + string endDate = null; + + string copyText = string.Empty; + foreach (MenuModel menu in this.feed.Model.Menus) + { + if (startDate == null) + { + startDate = menu.Date; + } + endDate = menu.Date; + + copyText += menu.Day + " (" + menu.Date + "):"; + copyText = Wp8StringManager.AddNewLine(copyText); + + foreach (MealModel meal in menu.Meals) + { + copyText += meal.MealName + ": " + meal.MealDesc; + copyText = Wp8StringManager.AddNewLine(copyText); + } + copyText = Wp8StringManager.AddNewLine(copyText); + + } + + string headline = AppResources.MensaApp_Weekplan + " (" + startDate + " - " + endDate + ") - " + AppResources.Setting_UserCampus + " " + this.feed.Title + " :"; + headline = Wp8StringManager.AddNewLine(headline); + + Clipboard.SetText(headline + copyText); + } + #endregion #endregion diff --git a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml index ca481e36..f5e7f4bf 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml @@ -9,6 +9,7 @@ xmlns:lui="clr-namespace:CampusAppWP8.Utility.Lui.Button" xmlns:header="clr-namespace:CampusAppWP8.Utility.Lui.Header" xmlns:page="clr-namespace:CampusAppWP8.Utility.Lui.Page" + xmlns:utility="clr-namespace:CampusAppWP8.Utility" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" @@ -16,6 +17,11 @@ mc:Ignorable="d" shell:SystemTray.IsVisible="True"> + + + + + @@ -27,105 +33,116 @@ - - - - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs index e0d58228..1bc482eb 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Openinghours/OpeninghoursPage.xaml.cs @@ -9,38 +9,34 @@ namespace CampusAppWP8.Pages.Openinghours { using System; using System.Windows; + using System.Windows.Controls; using System.Windows.Navigation; using CampusAppWP8.Feed.Openinghours; - using CampusAppWP8.Model.Openinghours; using CampusAppWP8.Resources; using CampusAppWP8.Utility; using CampusAppWP8.Utility.Lui.MessageBoxes; using CampusAppWP8.Utility.Lui.Page; + using CampusAppWPortalLib8.Model.Openinghours; - /// - /// Opening hours page. - /// + /// Opening hours page. + /// Fiedler, 13.11.2013. + /// public partial class OpeninghoursPage : PortraitLandscapePage { #region Members - /// - /// Opening hours feed object. - /// + /// Opening hours feed object. private OpeninghoursFeed feed = null; - /// - /// for checking if the instance is new or a tombstone. - /// + /// for checking if the instance is new or a tombstone. private bool isNewInstance = false; #endregion #region Constructor - /// - /// Initializes a new instance of the class. - /// + /// Initializes a new instance of the class. + /// Fiedler, 13.11.2013. public OpeninghoursPage() { this.InitializeComponent(); @@ -52,7 +48,7 @@ namespace CampusAppWP8.Pages.Openinghours this.feed.OnLoaded += new OpeninghoursFeed.OnIO(this.FeedIsReady); this.feed.OnFailedWeb += new OpeninghoursFeed.OnFailed(this.FeedIsFailedWeb); this.feed.OnFailedFile += new OpeninghoursFeed.OnFailed(this.FeedIsFailedFile); - this.feed.LoadData(Utilities.GetLoadModus()); + this.feed.LoadData(Utilities.GetLoadModus()); } this.isNewInstance = true; @@ -64,10 +60,9 @@ namespace CampusAppWP8.Pages.Openinghours #region protected - /// - /// Override the OnNavigatedTo method. - /// - /// Arguments of navigation + /// Override the OnNavigatedTo method. + /// Fiedler, 13.11.2013. + /// protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); @@ -76,9 +71,9 @@ namespace CampusAppWP8.Pages.Openinghours { if ((this.feed == null) || (this.feed.Model == null)) { - OpeninghoursWp8Model tempModel = null; + OpeninghoursModel tempModel = null; - if ((tempModel = App.LoadFromIsolatedStorage(Constants.IsolatedStorage_OpeninghoursModel)) != null) + if ((tempModel = App.LoadFromIsolatedStorage(Constants.IsolatedStorage_OpeninghoursModel)) != null) { this.feed.Model = tempModel; this.FeedIsReady(); @@ -89,20 +84,23 @@ namespace CampusAppWP8.Pages.Openinghours } } - /// - /// Override the OnNavigatedFrom method - /// - /// Arguments of navigation + /// Override the OnNavigatedFrom method. + /// Fiedler, 13.11.2013. + /// protected override void OnNavigatedFrom(NavigationEventArgs e) { this.feed.SaveData(); if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back) { - App.SaveToIsolatedStorage(Constants.IsolatedStorage_OpeninghoursModel, this.feed.Model); + App.SaveToIsolatedStorage(Constants.IsolatedStorage_OpeninghoursModel, this.feed.Model); } } + /// Raises the tap grid event. + /// Fiedler, 13.11.2013. + /// button object. + /// Event information to send to registered event handlers. private void OnTapGrid(object sender, EventArgs e) { @@ -113,55 +111,51 @@ namespace CampusAppWP8.Pages.Openinghours #region private - /// - /// Will be execute if the feed is ready. - /// + /// Will be execute if the feed is ready. + /// Fiedler, 13.11.2013. private void FeedIsReady() { - this.InstitutionPanel.ItemsSource = this.feed.Model.Institutions; + this.ThePivot.ItemsSource = this.feed.Model.Locations; this.DefHeader.ProgressVisibility = Visibility.Collapsed; this.feed.SaveData(); } /// - /// On clicking the update button in the ApplicationBar. - /// Force a data update from the web. + /// On clicking the update button in the ApplicationBar. Force a data update from the web. /// - /// button object - /// event args + /// Fiedler, 13.11.2013. + /// button object. + /// event args. private void OpenHoursForceUpdate_Click(object sender, EventArgs e) { this.DefHeader.ProgressVisibility = Visibility.Visible; this.feed.ForceWebUpdate(); } - /// - /// Method will be execute if the feed is failed - /// + /// Method will be execute if the feed is failed. + /// Fiedler, 13.11.2013. private void FeedIsFailedWeb() { MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadWeb); this.feed.ForceReadFile(); } - /// - /// Method will be execute if the feed is failed - /// + /// Method will be execute if the feed is failed. + /// Fiedler, 13.11.2013. private void FeedIsFailedFile() { this.DefHeader.ProgressVisibility = Visibility.Collapsed; MessageBoxResult result = MessageBoxes.ShowMainModelErrorMessageBox(AppResources.MsgBox_ErrorMainModelLoadFile); } - /// - /// Method will be execute if the selection is change in the listbox. - /// - /// listbox object. - /// event args. + /// Method will be execute if the selection is change in the listbox. + /// Fiedler, 13.11.2013. + /// listbox object. + /// event args. private void InstitutionPanel_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e) { - this.InstitutionPanel.SelectedIndex = -1; + (sender as ListBox).SelectedIndex = -1; } // private 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 e6daa710..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(); @@ -307,7 +321,7 @@ namespace CampusAppWP8.Pages if (result == MessageBoxResult.OK) { Settings.AppSetting.GeoWatchEnable = true; - Thread thread = new Thread(new ThreadStart(Utilities.DetermineAndStoreCurrentPosition)); + Thread thread = new Thread(new ThreadStart(this.PositionThread)); thread.Start(); } else @@ -316,6 +330,13 @@ namespace CampusAppWP8.Pages } } + /// Position thread. + /// Stubbfel, 18.11.2013. + private void PositionThread() + { + Utilities.DetermineAndStoreCurrentPosition(); + } + /// Event handler. Called by PintoStart for click events. /// Stubbfel, 15.10.2013. /// Caller of the function. @@ -416,6 +437,8 @@ namespace CampusAppWP8.Pages } else { + this.GoToAppointment(nfcContent); + /* removed for testing if (AppSettings.BTUTagDefaultHandler.CampusMap == Settings.AppSetting.TagDefaultHandler) { // search for placeId @@ -432,6 +455,7 @@ namespace CampusAppWP8.Pages this.ShowBtuTagMessageBox(); } } + */ } this.ndefId = this.device.SubscribeForMessage(Constants.NCFMessageType_NDEF, this.NDEFHandler); @@ -443,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) { @@ -473,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 retValue = new List(); - -// foreach (FrameworkElement elem in this.itemPages[index].Content.Children) - { -// if (elem.Tag.GetType().Equals(typeof(AppointmentModel))) - { -// if ((elem.Tag as AppointmentModel).Equals(model)) - { -// retValue.Add(elem as Canvas); - } - } - } - - return retValue.ToArray(); - } - - - private void DrawAppointment(AppointmentModel model, int index, int xIndex, double opacity = 1.0, int zIndex = 0, int modelCount = 0) - { -/* - Canvas modelCan = model.GetCanvas( - ((this.itemPages[index].Content.Width - WEEK_TABLE_HEAD_WIDTH) / 5) - 2 - 2 - (modelCount * WEEK_TABLE_ZINDEX_SHIFT), - WEEK_TABLE_CELL_HEIGHT, - this.itemPages[index].DateFrom.Date.AddDays(xIndex)); - - modelCan.DoubleTap += new EventHandler(this.OnAppointmentClick); - modelCan.Opacity = opacity; - modelCan.SetValue(Canvas.ZIndexProperty, WEEK_TABLE_ZINDEX_MAX - zIndex); - modelCan.Margin = new Thickness( - (WEEK_TABLE_HEAD_WIDTH + 2 + (zIndex * WEEK_TABLE_ZINDEX_SHIFT) + (xIndex * ((this.itemPages[index].Content.Width - WEEK_TABLE_HEAD_WIDTH) / 5))), - modelCan.Margin.Top, - 0, - 0); - - this.itemPages[index].Content.Children.Add(modelCan); -*/ - } - - private void DrawMultiBubble(int index, int dayIndex, int listIndex, int number, double xOffset, double yOffset) - { - Canvas can = new Canvas(); - - can.Width = WEEK_TABLE_CELL_HEIGHT * 2; - can.Height = WEEK_TABLE_CELL_HEIGHT * 2; - - Rectangle rect = new Rectangle(); - rect.Width = WEEK_TABLE_CELL_HEIGHT / 2; - rect.Height = WEEK_TABLE_CELL_HEIGHT / 2; - rect.RadiusX = WEEK_TABLE_CELL_HEIGHT / 4; - rect.RadiusY = WEEK_TABLE_CELL_HEIGHT / 4; - rect.StrokeThickness = 1; - rect.Stroke = new SolidColorBrush(Colors.DarkGray); - rect.Fill = new SolidColorBrush(Colors.Black); - - TextBlock block = new TextBlock(); - block.Height = WEEK_TABLE_CELL_HEIGHT / 2; - block.Width = WEEK_TABLE_CELL_HEIGHT / 2; - block.Text = "" + number; - block.HorizontalAlignment = HorizontalAlignment.Center; - block.VerticalAlignment = VerticalAlignment.Center; - block.FontWeight = FontWeights.Bold; - block.FontSize = WEEK_TABLE_CELL_HEIGHT / 3; - block.Padding = new Thickness(WEEK_TABLE_CELL_HEIGHT / 6.5, 0, 0, 0); - - can.Children.Add(rect); - rect.SetValue(Canvas.TopProperty, WEEK_TABLE_CELL_HEIGHT / 2); - rect.SetValue(Canvas.LeftProperty, WEEK_TABLE_CELL_HEIGHT / 2); - - can.Children.Add(block); - block.SetValue(Canvas.TopProperty, WEEK_TABLE_CELL_HEIGHT / 2); - block.SetValue(Canvas.LeftProperty, WEEK_TABLE_CELL_HEIGHT / 2); - - can.Tap += new EventHandler(this.OnMultiBubbleClick); - can.Tag = ((dayIndex & 0xF) << 24) | ((index & 0xFFF) << 12) | (listIndex & 0xFFF); - can.SetValue(Canvas.LeftProperty, xOffset - rect.Width - (WEEK_TABLE_CELL_HEIGHT / 2)); - can.SetValue(Canvas.TopProperty, yOffset - (WEEK_TABLE_CELL_HEIGHT / 2)); - can.SetValue(Canvas.ZIndexProperty, WEEK_TABLE_ZINDEX_MAX + 1); - -// this.itemPages[index].Content.Children.Add(can); - } - - private void DrawHeader(int index) - { - Grid grid = ((this.ThePivot.Items[index] as PivotItem).Header as Grid); - string text = string.Format("{0:dd.MM.yyyy} < {1:c} > {2:dd.MM.yyyy}", this.itemPages[index].DateFrom, this.itemPages[index].WeekChar, this.itemPages[index].DateTo); - - RowDefinition row_0 = new RowDefinition(); - RowDefinition row_1 = new RowDefinition(); - row_0.Height = GridLength.Auto; - row_1.Height = GridLength.Auto; - - grid.RowDefinitions.Add(row_0); - grid.RowDefinitions.Add(row_1); - - TextBlock newTB = new TextBlock(); - newTB.Text = text; - newTB.HorizontalAlignment = HorizontalAlignment.Center; - newTB.FontSize = 24; - newTB.SetValue(Grid.RowProperty, 0); - - grid.Children.Add(newTB); - - Canvas headCan = new Canvas(); - - string[] dayStr = new string[] {"Mo", "Di", "Mi", "Do", "Fr" }; - - double w = (grid.Width - WEEK_TABLE_HEAD_WIDTH) / 5; - - for (int i = 0; i < 5; i++) - { - Rectangle dayRect = new Rectangle(); - TextBlock dayTB = new TextBlock(); - - dayRect.Width = w; - dayRect.Height = 30; - dayRect.StrokeThickness = WEEK_TABLE_HEAD_THICKNESS; - dayRect.Stroke = new SolidColorBrush(Colors.White); - dayRect.Stretch = Stretch.Fill; - dayRect.Margin = new Thickness(WEEK_TABLE_HEAD_WIDTH - 9 + i * w, 0, 0, 0); - - if (this.itemPages[index].DateFrom.Date.AddDays(i).Equals(DateTime.Now.Date)) - { - dayRect.Fill = new SolidColorBrush(Colors.White); - dayTB.Foreground = new SolidColorBrush(Colors.Black); - } - - headCan.Children.Add(dayRect); - - dayTB.Text = dayStr[i]; - dayTB.TextAlignment = TextAlignment.Center; - dayTB.HorizontalAlignment = HorizontalAlignment.Center; - dayTB.Width = w; - dayTB.FontSize = 16; - dayTB.Margin = new Thickness(WEEK_TABLE_HEAD_WIDTH - 9 + i * w, 4, 0, 0); - - headCan.Children.Add(dayTB); - } - - headCan.SetValue(Grid.RowProperty, 1); - - grid.Children.Add(headCan); - } - - private void ScrollViewer_Loaded(object sender, RoutedEventArgs e) - { - - } - - private void TheWeekView_Loaded(object sender, RoutedEventArgs e) - { -// this.itemPages[this.loadedWeekView].weekView = sender as WeekView; - this.loadedWeekView++; - } - - private void ThePivot_LoadedPivotItem(object sender, PivotItemEventArgs e) - { - - } - - private void Grid_Loaded(object sender, RoutedEventArgs e) - { - } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs new file mode 100644 index 00000000..a5564e04 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs @@ -0,0 +1,163 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 06.11.2013 +// Implements the week view page item class +//----------------------------------------------------------------------- +namespace CampusAppWP8.Pages.TimeTable +{ + using System; + using System.Collections.ObjectModel; + using System.ComponentModel; + using CampusAppWP8.Model.TimeTable; + using CampusAppWP8.Utility.Lui.Templates; + + /// A week view page item. + /// Fiedler, 06.11.2013. + /// + public class WeekViewPageItem : INotifyPropertyChanged + { + /// from dt Date/Time. + private DateTime fromDT; + /// to dt Date/Time. + private DateTime toDT; + /// The days. + private int days; + /// The week string. + private string weekStr = string.Empty; + /// The week number. + private int weekNumber = -1; + /// The week view. + private WeekView weekView = null; + /// List of appointments. + private ObservableCollection appointmentList = null; + + /// Tritt ein, wenn sich ein Eigenschaftswert ändert. + public event PropertyChangedEventHandler PropertyChanged; + + /// Initializes a new instance of the WeekViewPageItem class. + /// Fiedler, 06.11.2013. + /// from Date/Time. + /// The. + /// Number of. + /// The days. + public WeekViewPageItem(DateTime from, string str, int number, int days) + { + this.fromDT = from; + this.toDT = from.Date.AddDays(days); + this.days = days; + this.weekStr = str; + this.weekNumber = number; + this.appointmentList = new ObservableCollection(); + } + + /// Gets or sets the Date/Time of from dt. + /// from dt. + public DateTime FromDT + { + get + { + return this.fromDT; + } + + set + { + this.fromDT = value; + this.NotifyPropertyChanged("FromDT"); + } + } + + /// Gets or sets the Date/Time of to dt. + /// to dt. + public DateTime ToDT + { + get + { + return this.toDT; + } + + set + { + this.toDT = value; + this.NotifyPropertyChanged("ToDT"); + } + } + + /// Gets or sets the week string. + /// The week string. + public string WeekStr + { + get + { + return this.weekStr; + } + + set + { + this.weekStr = value; + this.NotifyPropertyChanged("WeekStr"); + } + } + + /// Gets or sets the week nr. + /// The week nr. + public int WeekNr + { + get + { + return this.weekNumber; + } + + set + { + this.weekNumber = value; + this.NotifyPropertyChanged("WeekNr"); + } + } + + /// Gets or sets the view. + /// The view. + public WeekView View + { + get + { + return this.weekView; + } + + set + { + this.weekView = value; + this.NotifyPropertyChanged("View"); + } + } + + /// Gets or sets a list of appointments. + /// A List of appointments. + public ObservableCollection AppointmentList + { + get + { + return this.appointmentList; + } + + set + { + this.appointmentList = value; + this.NotifyPropertyChanged("AppointmentList"); + } + } + + /// Notifies a property changed. + /// Fiedler, 06.11.2013. + /// The information. + private void NotifyPropertyChanged(string info) + { + if (this.PropertyChanged != null) + { + this.PropertyChanged(this, new PropertyChangedEventArgs(info)); + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index dffe834c..1defd00d 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -204,6 +204,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die KW ähnelt. + /// + public static string Calendar_Week_Short { + get { + return ResourceManager.GetString("Calendar_Week_Short", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Gebäudeinfos ausblenden ähnelt. /// @@ -276,6 +285,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Kopieren ähnelt. + /// + public static string Copy { + get { + return ResourceManager.GetString("Copy", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Erstellen ähnelt. /// @@ -375,6 +393,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Angestellte ähnelt. + /// + public static string Employees { + get { + return ResourceManager.GetString("Employees", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Events ähnelt. /// @@ -420,6 +447,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Gäste ähnelt. + /// + public static string Guests { + get { + return ResourceManager.GetString("Guests", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Hinweis ähnelt. /// @@ -726,6 +762,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Tagesplan ähnelt. + /// + public static string MensaApp_Dayplan { + get { + return ResourceManager.GetString("MensaApp_Dayplan", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die 84 ähnelt. /// @@ -744,6 +789,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Wochenplan ähnelt. + /// + public static string MensaApp_Weekplan { + get { + return ResourceManager.GetString("MensaApp_Weekplan", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die BTU-Tag ähnelt. /// @@ -1266,6 +1320,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Studenten ähnelt. + /// + public static string Students { + get { + return ResourceManager.GetString("Students", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die vorlesen ähnelt. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 90588cd5..4d494990 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -596,4 +596,25 @@ Mi + + KW + + + Angestellte + + + Gäste + + + Studenten + + + Kopieren + + + Tagesplan + + + Wochenplan + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 1e7fbdef..a7a62d34 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -247,7 +247,7 @@ OpeninghoursFeed.xml - http://www.tu-cottbus.de/campusapp-data/getdata.php?db=openinghours&app=2&appversion=1 + http://www.tu-cottbus.de/campusapp-data/openinghours.php?v=2 NewsFeed.xml @@ -594,4 +594,19 @@ CurrentPositionPoint + + Appointments.xaml + + + pid + + + Raumnummer + + + mensaprice.xml + + + http://www.tu-cottbus.de/campusapp-data/canteens.php?v=1 + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs index 4aec5b6e..ea41e3aa 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs @@ -249,6 +249,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Appointments.xaml ähnelt. + /// + public static string FileAppointments_Name { + get { + return ResourceManager.GetString("FileAppointments_Name", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die DepartmentFavoriteFeed.xml ähnelt. /// @@ -375,6 +384,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die mensaprice.xml ähnelt. + /// + public static string FileMensaPrice { + get { + return ResourceManager.GetString("FileMensaPrice", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die NewsFeed.xml ähnelt. /// @@ -708,6 +726,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die pid ähnelt. + /// + public static string ParamPID { + get { + return ResourceManager.GetString("ParamPID", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die pivotindex ähnelt. /// @@ -1176,6 +1203,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// Sucht eine lokalisierte Zeichenfolge, die Raumnummer ähnelt. + /// + public static string PisInformationName_Room { + get { + return ResourceManager.GetString("PisInformationName_Room", resourceCulture); + } + } + /// /// Sucht eine lokalisierte Zeichenfolge, die Kurzbeschreibung ähnelt. /// @@ -1357,7 +1393,16 @@ namespace CampusAppWP8.Resources { } /// - /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/getdata.php?db=openinghours&app=2&appversion=1 ähnelt. + /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/canteens.php?v=1 ähnelt. + /// + public static string UrlMensaPrice { + get { + return ResourceManager.GetString("UrlMensaPrice", resourceCulture); + } + } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die http://www.tu-cottbus.de/campusapp-data/openinghours.php?v=2 ähnelt. /// public static string UrlOpeningHours_OpeningHours { get { diff --git a/CampusAppWP8/CampusAppWP8/Utility/DoubleNaNConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/DoubleNaNConverter.cs new file mode 100644 index 00000000..dc937c1a --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/DoubleNaNConverter.cs @@ -0,0 +1,22 @@ +namespace CampusAppWP8.Utility +{ + using System; + using System.Windows; + using System.Windows.Data; + + + public sealed class DoubleNaNConverter : IValueConverter + { + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) + { + return (value is double && value.Equals(double.NaN) == false) ? value : 0.0; + } + + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) + { + return (value is double && value.Equals(double.NaN) == false) ? value : 0.0; + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs index 220ba6e9..2b9b2493 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSClasses.cs @@ -204,16 +204,16 @@ namespace CampusAppWP8.Utility int val = 0; char typeChar; - for (int i = 0; i < durStr.Length; i++) + for (int i = 0; i < str.Length; i++) { - if (durStr[i] >= '0' && durStr[i] <= '9') + if (str[i] >= '0' && str[i] <= '9') { val *= 10; - val += durStr[0] - '0'; + val += str[i] - '0'; } else { - typeChar = durStr[i]; + typeChar = str[i]; retValue.Add(new Tuple(val, typeChar)); val = 0; } @@ -276,6 +276,8 @@ namespace CampusAppWP8.Utility /// Fiedler, 05.09.2013. public abstract class Interface { + protected string privateName = string.Empty; + /// Sets the property/class values. Used for import from a ICS file. /// Fiedler, 05.09.2013. /// The value string. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSManager.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSManager.cs index 530c876c..b07a1d12 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSManager.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSManager.cs @@ -48,52 +48,55 @@ namespace CampusAppWP8.Utility foreach (string e in elems) { - ContentLine prop = ICSManager.ToContentLine(e); - ICSDict.ICSElemDesc tempElem = null; - - if ((tempElem = parentList.Last().GetValue(prop.Name)) != null) + if (e.Length > 0) { - object propObj = tempElem.CreateObj(prop.ValueString, (prop.ParamList == null) ? null : prop.ParamList.ToArray()); + ContentLine prop = ICSManager.ToContentLine(e); + ICSDict.ICSElemDesc tempElem = null; - if (ICSManager.Is((propObj as ICSClasses.Interface).GetName(), ICSTag.BEGIN)) + if ((tempElem = parentList.Last().GetValue(prop.Name)) != null) { - retPointer = new ICalObject(); + object propObj = tempElem.CreateObj(prop.ValueString, (prop.ParamList == null) ? null : prop.ParamList.ToArray()); - if (retValue == null) + if (ICSManager.Is((propObj as ICSClasses.Interface).GetName(), ICSTag.BEGIN)) { - retValue = retPointer; + retPointer = new ICalObject(); + + if (retValue == null) + { + retValue = retPointer; + } + else + { + // FIXME + retValue.PropertieList.Add(retPointer); + } + + retPointer.Header = propObj as ICSProperties.Begin; + + parentList.Add(ICSManager.GetSubValue((propObj as ICSProperties.Begin).Value, tempElem)); + } + else if (ICSManager.Is((propObj as ICSClasses.Interface).GetName(), ICSTag.END)) + { + if (ICSManager.GetSubValue((propObj as ICSProperties.End).Value, tempElem) != null) + { + parentList.RemoveAt(parentList.Count - 1); + } } else { - // FIXME - retValue.PropertieList.Add(retPointer); + retPointer.PropertieList.Add(propObj); } - - retPointer.Header = propObj as ICSProperties.Begin; - - parentList.Add(ICSManager.GetSubValue((propObj as ICSProperties.Begin).Value, tempElem)); } - else if (ICSManager.Is((propObj as ICSClasses.Interface).GetName(), ICSTag.END)) + else { - if (ICSManager.GetSubValue((propObj as ICSProperties.End).Value, tempElem) != null) + if (prop.Name.IndexOf("X-") == 0) { - parentList.RemoveAt(parentList.Count - 1); + // TODO + } + else + { + throw new NotSupportedException("Tag (" + prop.Name + ") was not found in (" + parentList.Last().Name + ")"); } - } - else - { - retPointer.PropertieList.Add(propObj); - } - } - else - { - if (prop.Name.IndexOf("X-") == 0) - { - // TODO - } - else - { - throw new NotSupportedException("Tag (" + prop.Name + ") was not found in (" + parentList.Last().Name + ")"); } } } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/AccessClass.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/AccessClass.cs index d6a34996..e6a905f1 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/AccessClass.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/AccessClass.cs @@ -41,6 +41,7 @@ namespace CampusAppWP8.Utility.ICSProperties ICSValue.PRIVATE, ICSValue.CONFIDENTIAL }); + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -76,7 +77,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList.Count() > 0) { - throw new NotSupportedException("in (" + Name + ") is no param supported"); + throw new NotSupportedException("in (" + this.privateName + ") is no param supported"); } } @@ -95,7 +96,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// The string. public override string GetString() { - return Name + ":" + this.value; + return this.privateName + ":" + this.value; } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Action.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Action.cs index dd4e6bd1..4a46dfaf 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Action.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Action.cs @@ -40,6 +40,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public Action() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -95,7 +96,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + this.value; + retValue += this.privateName + ":" + this.value; return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attachment.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attachment.cs index 2b14f9ae..b532e9d2 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attachment.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attachment.cs @@ -49,6 +49,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public Attachment() { + this.privateName = this.GetName(); } /// Gets or sets the value bytes. @@ -182,7 +183,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; if (this.formatType.Equals(string.Empty) == false) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attendee.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attendee.cs index 84cc2719..b67cec23 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attendee.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Attendee.cs @@ -56,6 +56,7 @@ namespace CampusAppWP8.Utility.ICSProperties public Attendee() { this.paramList = new List>(); + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -112,7 +113,7 @@ namespace CampusAppWP8.Utility.ICSProperties if (p.Count() != 2) { - throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")"); + throw new FormatException("unsupported param format (" + paramStrList + ") in (" + this.privateName + ")"); } if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) @@ -121,7 +122,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new NotSupportedException("unsupported param (" + paramStrList[i] + ") in (" + Name + ")"); + throw new NotSupportedException("unsupported param (" + paramStrList[i] + ") in (" + this.privateName + ")"); } } } @@ -136,7 +137,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; for (int i = 0; i < this.paramList.Count(); i++) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Begin.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Begin.cs index 26f41c25..6abcff3f 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Begin.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Begin.cs @@ -46,6 +46,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public Begin() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -99,7 +100,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + this.value; + retValue += this.privateName + ":" + this.value; return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/CalendarScale.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/CalendarScale.cs index ca0f8242..da4eb9fd 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/CalendarScale.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/CalendarScale.cs @@ -38,6 +38,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public CalendarScale() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -91,7 +92,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + this.value; + retValue += this.privateName + ":" + this.value; return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Categories.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Categories.cs index 17f6a194..37a3a393 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Categories.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Categories.cs @@ -38,6 +38,7 @@ namespace CampusAppWP8.Utility.ICSProperties public Categories() { this.valueList = new List(); + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -114,7 +115,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; if (this.languageType.Equals(string.Empty) == false) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Comment.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Comment.cs index cc59ffc1..8b5d2b7f 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Comment.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Comment.cs @@ -41,6 +41,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public Comment() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -132,7 +133,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; if (this.altrep.Equals(string.Empty) == false) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Contact.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Contact.cs index 338f85ee..3d1a9558 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Contact.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Contact.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public Contact() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCompleted.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCompleted.cs index 15475618..4b768435 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCompleted.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCompleted.cs @@ -30,6 +30,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public DTCompleted() { + this.privateName = this.GetName(); } /// Gets or sets the Date/Time of the value. @@ -60,7 +61,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + throw new NotSupportedException("parameter are not supported in (" + this.privateName + ")"); } } @@ -73,7 +74,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList != null) { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + throw new NotSupportedException("parameter are not supported in (" + this.privateName + ")"); } this.value = ICSClasses.UTCStringToDateTime(valueStr); @@ -86,7 +87,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + ICSClasses.DateTimeToString(this.value); + retValue += this.privateName + ":" + ICSClasses.DateTimeToString(this.value); return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCreated.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCreated.cs index d4cc1e57..3b7e3363 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCreated.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTCreated.cs @@ -40,6 +40,7 @@ namespace CampusAppWP8.Utility.ICSProperties public DTCreated() { this.paramList = new List>(); + this.privateName = this.GetName(); } /// Gets or sets the Date/Time of the value. @@ -95,7 +96,7 @@ namespace CampusAppWP8.Utility.ICSProperties if (p.Count() != 2) { - throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")"); + throw new FormatException("unsupported param format (" + paramStrList + ") in (" + this.privateName + ")"); } if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) @@ -104,7 +105,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new NotSupportedException("unsupported param (" + paramStrList[i] + ") in (" + Name + ")"); + throw new NotSupportedException("unsupported param (" + paramStrList[i] + ") in (" + this.privateName + ")"); } } } @@ -119,7 +120,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + ICSClasses.DateTimeToString(this.value); + retValue += this.privateName + ":" + ICSClasses.DateTimeToString(this.value); return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTDue.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTDue.cs index f2ba8dc1..b0fccd20 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTDue.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTDue.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public DTDue() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTEnd.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTEnd.cs index cd3e321e..26aa2840 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTEnd.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTEnd.cs @@ -41,6 +41,7 @@ namespace CampusAppWP8.Utility.ICSProperties public DTEnd() { this.paramList = new List>(); + this.privateName = this.GetName(); } /// Gets or sets the Date/Time of the value. @@ -135,7 +136,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList.Count() > 2) { - throw new NotSupportedException("too many params in (" + Name + ")"); + throw new NotSupportedException("too many params in (" + this.privateName + ")"); } for (int i = 0; i < paramStrList.Count(); i++) @@ -162,7 +163,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new NotSupportedException("param (" + p[0] + ") is not supported in (" + Name + ")"); + throw new NotSupportedException("param (" + p[0] + ") is not supported in (" + this.privateName + ")"); } } } @@ -178,7 +179,7 @@ namespace CampusAppWP8.Utility.ICSProperties if (isDate != tempIsDate) { - throw new NotSupportedException("time value has not the same type as declared in param in(" + Name + ")"); + throw new NotSupportedException("time value has not the same type as declared in param in(" + this.privateName + ")"); } this.value = ICSClasses.UTCStringToDateTime(valueStr); @@ -191,7 +192,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; for (int i = 0; i < this.paramList.Count(); i++) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTException.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTException.cs index f1afeaa3..07eb720c 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTException.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTException.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public DTException() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTRecurrence.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTRecurrence.cs index 0d035cc5..26663b11 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTRecurrence.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTRecurrence.cs @@ -42,6 +42,7 @@ namespace CampusAppWP8.Utility.ICSProperties { this.values = new List>(); this.paramList = new List>(); + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -120,7 +121,7 @@ namespace CampusAppWP8.Utility.ICSProperties if (p.Count() != 2) { - throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")"); + throw new FormatException("unsupported param format (" + paramStrList + ") in (" + this.privateName + ")"); } if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) @@ -129,7 +130,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new NotSupportedException("unsupported param (" + paramStrList[0] + ") in (" + Name + ")"); + throw new NotSupportedException("unsupported param (" + paramStrList[0] + ") in (" + this.privateName + ")"); } } } @@ -188,7 +189,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; for (int i = 0; i < this.paramList.Count(); i++) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStamp.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStamp.cs index d9ac331c..bba7d3a7 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStamp.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStamp.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public DTStamp() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStart.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStart.cs index 2bb9ea50..55af1ac0 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStart.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/DTStart.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public DTStart() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Description.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Description.cs index 753a57c7..dda4b1d0 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Description.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Description.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public Description() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Duration.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Duration.cs index ffb5a9f4..7515fbc7 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Duration.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Duration.cs @@ -33,6 +33,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public Duration() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -83,7 +84,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList != null) { - throw new NotSupportedException("params are not supported in (" + Name + ")"); + throw new NotSupportedException("params are not supported in (" + this.privateName + ")"); } if (valueStr[0].Equals('-') || valueStr[0].Equals('+')) @@ -102,7 +103,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + ICSClasses.TimeSpanToString(this.value, this.isNegative); + retValue += this.privateName + ":" + ICSClasses.TimeSpanToString(this.value, this.isNegative); return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/End.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/End.cs index 024be530..694dbea5 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/End.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/End.cs @@ -43,6 +43,7 @@ namespace CampusAppWP8.Utility.ICSProperties public End() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/FreeBusyTime.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/FreeBusyTime.cs index 93b3557f..6b0467e4 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/FreeBusyTime.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/FreeBusyTime.cs @@ -40,6 +40,7 @@ namespace CampusAppWP8.Utility.ICSProperties public FreeBusyTime() { this.valueList = new List>(); + this.privateName = this.GetName(); } /// Gets or sets a list of values. @@ -91,7 +92,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList.Count() > 1) { - throw new NotSupportedException("there is only 1 param in (" + Name + ") supported"); + throw new NotSupportedException("there is only 1 param in (" + this.privateName + ") supported"); } string[] p = paramStrList[0].Split('='); @@ -161,7 +162,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; if (!this.freebusyType.Equals(string.Empty)) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Geo.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Geo.cs index a15ffc72..26b6b650 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Geo.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Geo.cs @@ -31,6 +31,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public Geo() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -61,7 +62,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + throw new NotSupportedException("parameter are not supported in (" + this.privateName + ")"); } } @@ -75,7 +76,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList != null) { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + throw new NotSupportedException("parameter are not supported in (" + this.privateName + ")"); } string[] valSplit = valueStr.Split(';'); @@ -96,11 +97,11 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; if (this.value == null) { - throw new NotSupportedException("there is no value set for (" + Name + ")"); + throw new NotSupportedException("there is no value set for (" + this.privateName + ")"); } retValue += ":" + this.value.Item1.ToString() + ";" + this.value.Item2.ToString(); diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/LastModified.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/LastModified.cs index bcff42bc..c4a3e960 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/LastModified.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/LastModified.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public LastModified() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Location.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Location.cs index 9225558c..38dde24a 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Location.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Location.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public Location() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Method.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Method.cs index 8e41ecc3..197de8f3 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Method.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Method.cs @@ -31,6 +31,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public Method() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -70,7 +71,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + this.value; + retValue += this.privateName + ":" + this.value; return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Organizer.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Organizer.cs index 0bfbac3e..279d3f32 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Organizer.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Organizer.cs @@ -34,6 +34,7 @@ namespace CampusAppWP8.Utility.ICSProperties public Organizer() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/PercentComplete.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/PercentComplete.cs index b2351ca5..b7295ee0 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/PercentComplete.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/PercentComplete.cs @@ -30,6 +30,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public PercentComplete() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -49,7 +50,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new ArgumentOutOfRangeException("value must be in rang of [0..100] in (" + Name + ")"); + throw new ArgumentOutOfRangeException("value must be in rang of [0..100] in (" + this.privateName + ")"); } } } @@ -67,7 +68,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + throw new NotSupportedException("parameter are not supported in (" + this.privateName + ")"); } } @@ -80,7 +81,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList != null) { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + throw new NotSupportedException("parameter are not supported in (" + this.privateName + ")"); } this.value = int.Parse(valueStr); @@ -94,11 +95,11 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; if (this.value < 0) { - throw new NotSupportedException("there is no value set for (" + Name + ")"); + throw new NotSupportedException("there is no value set for (" + this.privateName + ")"); } retValue += ":" + this.value.ToString(); diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Priority.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Priority.cs index 6f6d1010..3d5dd93f 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Priority.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Priority.cs @@ -30,6 +30,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public Priority() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -49,7 +50,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new ArgumentOutOfRangeException("value must be in rage of [0..9] in (" + Name + ")"); + throw new ArgumentOutOfRangeException("value must be in rage of [0..9] in (" + this.privateName + ")"); } } } @@ -67,7 +68,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + throw new NotSupportedException("parameter are not supported in (" + this.privateName + ")"); } } @@ -83,14 +84,14 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList != null) { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + throw new NotSupportedException("parameter are not supported in (" + this.privateName + ")"); } this.value = int.Parse(valueStr); if ((this.value < 0) || (this.value > 9)) { - throw new ArgumentOutOfRangeException("value must be in the range of [0..9] in (" + Name + ")"); + throw new ArgumentOutOfRangeException("value must be in the range of [0..9] in (" + this.privateName + ")"); } } @@ -102,11 +103,11 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; if (this.value < 0 || this.value > 9) { - throw new NotSupportedException("there is no value set for (" + Name + ")"); + throw new NotSupportedException("there is no value set for (" + this.privateName + ")"); } retValue += ":" + this.value.ToString(); diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/ProductID.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/ProductID.cs index a6d32830..1b6c67ba 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/ProductID.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/ProductID.cs @@ -31,6 +31,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public ProductID() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -70,7 +71,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + this.value; + retValue += this.privateName + ":" + this.value; return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceID.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceID.cs index fda0a69c..8b51d8b5 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceID.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceID.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public RecurrenceID() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceRule.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceRule.cs index ac5f2293..84857e52 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceRule.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RecurrenceRule.cs @@ -58,6 +58,7 @@ namespace CampusAppWP8.Utility.ICSProperties public RecurrenceRule() { this.values = new List>>(); + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -119,7 +120,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":"; + retValue += this.privateName + ":"; for (int i = 0; i < this.values.Count(); i++) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RelatedTo.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RelatedTo.cs index a703a01d..dd1f48c0 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RelatedTo.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RelatedTo.cs @@ -39,6 +39,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public RelatedTo() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -98,7 +99,7 @@ namespace CampusAppWP8.Utility.ICSProperties if (p.Count() != 2) { - throw new FormatException("unsupported param format (" + paramStrList + ") in (" + Name + ")"); + throw new FormatException("unsupported param format (" + paramStrList + ") in (" + this.privateName + ")"); } if (ICSClasses.CheckParamAndParamValue(p[0], p[1], PParams.ToArray())) @@ -107,7 +108,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new NotSupportedException("unsupported param (" + paramStrList[0] + ") in (" + Name + ")"); + throw new NotSupportedException("unsupported param (" + paramStrList[0] + ") in (" + this.privateName + ")"); } } } @@ -122,7 +123,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; if (!this.realType.Equals(string.Empty)) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RepeatCount.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RepeatCount.cs index ce747510..9e38904c 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RepeatCount.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RepeatCount.cs @@ -31,6 +31,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public RepeatCount() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -75,7 +76,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + this.value.ToString(); + retValue += this.privateName + ":" + this.value.ToString(); return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RequestStatus.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RequestStatus.cs index adad86bd..48f24486 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RequestStatus.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/RequestStatus.cs @@ -42,6 +42,7 @@ namespace CampusAppWP8.Utility.ICSProperties { this.paramList = new List>(); this.valueList = new List(); + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -142,7 +143,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; for (int i = 0; i < this.paramList.Count(); i++) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Resources.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Resources.cs index cb576669..53ab9506 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Resources.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Resources.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public Resources() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/SequenceNumber.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/SequenceNumber.cs index a1dea60f..43926020 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/SequenceNumber.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/SequenceNumber.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public SequenceNumber() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Status.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Status.cs index baa5c432..962348a5 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Status.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Status.cs @@ -63,6 +63,7 @@ namespace CampusAppWP8.Utility.ICSProperties ICSValue.FINAL, ICSValue.CANCELLED }); + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -84,7 +85,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new NotSupportedException("value (" + value + ") is not supported in (" + Name + ")"); + throw new NotSupportedException("value (" + value + ") is not supported in (" + this.privateName + ")"); } } } @@ -102,7 +103,7 @@ namespace CampusAppWP8.Utility.ICSProperties } else { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + throw new NotSupportedException("parameter are not supported in (" + this.privateName + ")"); } } @@ -115,14 +116,14 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList != null) { - throw new NotSupportedException("parameter are not supported in (" + Name + ")"); + throw new NotSupportedException("parameter are not supported in (" + this.privateName + ")"); } if ((this.ValueListEvent.IndexOf(valueStr) < 0) && (this.ValueListToDo.IndexOf(valueStr) < 0) && (this.ValueListJournal.IndexOf(valueStr) < 0)) { - throw new NotSupportedException("value (" + valueStr + ") is not supported in (" + Name + ")"); + throw new NotSupportedException("value (" + valueStr + ") is not supported in (" + this.privateName + ")"); } this.value = valueStr; @@ -135,7 +136,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + this.value; + retValue += this.privateName + ":" + this.value; return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Summary.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Summary.cs index 73512d7b..fab4f6da 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Summary.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Summary.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public Summary() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeTransparency.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeTransparency.cs index c2d93c31..cb9c65b5 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeTransparency.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeTransparency.cs @@ -39,6 +39,7 @@ namespace CampusAppWP8.Utility.ICSProperties ICSValue.OPAQUE, ICSValue.TRANSPARENT }); + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -81,7 +82,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList != null) { - throw new NotSupportedException("params are not supported in (" + Name + ")"); + throw new NotSupportedException("params are not supported in (" + this.privateName + ")"); } if (this.ValueList.IndexOf(valueStr) < 0) @@ -99,7 +100,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + this.value; + retValue += this.privateName + ":" + this.value; return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneIdentifier.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneIdentifier.cs index e3d465d4..3c3a78e4 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneIdentifier.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneIdentifier.cs @@ -30,6 +30,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public TimeZoneIdentifier() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -65,7 +66,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList != null) { - throw new NotSupportedException("params are not supported in (" + Name + ")"); + throw new NotSupportedException("params are not supported in (" + this.privateName + ")"); } this.value = valueStr; @@ -78,7 +79,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + this.value; + retValue += this.privateName + ":" + this.value; return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneName.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneName.cs index 071c1ea8..b4f7f0a4 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneName.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneName.cs @@ -37,6 +37,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public TimeZoneName() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -81,7 +82,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList.Count() > 1) { - throw new NotSupportedException("there is only 1 param supported in (" + Name + ")"); + throw new NotSupportedException("there is only 1 param supported in (" + this.privateName + ")"); } if (paramStrList.Count() == 1) @@ -114,7 +115,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; if (!this.language.Equals(string.Empty)) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetFrom.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetFrom.cs index 96f0d6d1..3b8e9c26 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetFrom.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetFrom.cs @@ -33,6 +33,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public TimeZoneOffsetFrom() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -84,7 +85,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList != null) { - throw new NotSupportedException("no param supported in (" + Name + ")"); + throw new NotSupportedException("no param supported in (" + this.privateName + ")"); } if (valueStr[0].Equals('+')) @@ -110,7 +111,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + (this.isNegative ? "-" : "+") + string.Format("{0:HHmm}", this.value); + retValue += this.privateName + ":" + (this.isNegative ? "-" : "+") + string.Format("{0:HHmm}", this.value); return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetTo.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetTo.cs index 0a07775f..68516374 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetTo.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneOffsetTo.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public TimeZoneOffsetTo() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneUrl.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneUrl.cs index c6d7635d..767d368f 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneUrl.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/TimeZoneUrl.cs @@ -30,6 +30,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public TimeZoneUrl() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -65,7 +66,7 @@ namespace CampusAppWP8.Utility.ICSProperties { if (paramStrList != null) { - throw new NotSupportedException("no param supported in (" + Name + ")"); + throw new NotSupportedException("no param supported in (" + this.privateName + ")"); } this.value = valueStr; @@ -78,7 +79,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":" + this.value; + retValue += this.privateName + ":" + this.value; return retValue; } diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Trigger.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Trigger.cs index 055dfdb1..89734797 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Trigger.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Trigger.cs @@ -49,6 +49,7 @@ namespace CampusAppWP8.Utility.ICSProperties public Trigger() { this.paramList = new List>(); + this.privateName = this.GetName(); } /// Gets or sets the Date/Time of the value. @@ -164,7 +165,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name; + retValue += this.privateName; for (int i = 0; i < this.paramList.Count(); i++) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/UniqueID.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/UniqueID.cs index cfc8fbad..bfe99bfd 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/UniqueID.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/UniqueID.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public UniqueID() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Url.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Url.cs index 597be46e..589f4cad 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Url.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Url.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Utility.ICSProperties public Url() : base() { + this.privateName = this.GetName(); } /// Gets the name. diff --git a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Version.cs b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Version.cs index 4310e911..39e4f55c 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Version.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/ICSProperties/Version.cs @@ -34,6 +34,7 @@ namespace CampusAppWP8.Utility.ICSProperties /// Fiedler, 05.09.2013. public Version() { + this.privateName = this.GetName(); } /// Gets or sets the value. @@ -132,7 +133,7 @@ namespace CampusAppWP8.Utility.ICSProperties { string retValue = string.Empty; - retValue += Name + ":"; + retValue += this.privateName + ":"; if (this.minVer >= 0.0f) { diff --git a/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs new file mode 100644 index 00000000..07a8dd99 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs @@ -0,0 +1,113 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 13.11.2013 +// Implements the identifier to place converter class +//----------------------------------------------------------------------- +namespace CampusAppWP8.Utility +{ + using System; + using System.Windows.Data; + using CampusAppWP8.File.Places; + using CampusAppWPortalLib8.Model.GeoDb; + + /// An identifier to place converter. + /// Fiedler, 13.11.2013. + /// + public sealed class IdToPlaceConverter : IValueConverter + { + /// The place file. + private PlacesFile placeFile = null; + + /// Initializes a new instance of the IdToPlaceConverter class. + /// Fiedler, 13.11.2013. + public IdToPlaceConverter() + { + this.placeFile = new PlacesFile(); + this.placeFile.OnLoaded += this.PlaceFileIsReady; + this.placeFile.OnFailedLoad += this.PlaceFileIsFailed; + this.placeFile.LoadData(); + } + + /// + /// Ändert die Quelldaten vor der Übergabe an das Ziel zur Anzeige in der Benutzeroberfläche. + /// + /// Fiedler, 13.11.2013. + /// info string of the place. + /// + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) + { + string retValue = string.Empty; + string paramStr = "Name"; + + if (parameter is string) + { + paramStr = (string)parameter; + } + + if (value is string) + { + retValue = this.GetInfo((string)value, paramStr); + } + else if (value is int) + { + retValue = this.GetInfo(string.Empty + (int)value, paramStr); + } + + return retValue; + } + + /// + /// Ändert die Zieldaten vor der Übergabe an das Quellobjekt. Diese Methode wird nur in + /// -Bindungen aufgerufen. + /// + /// Fiedler, 13.11.2013. + /// null + /// + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) + { + object retValue = null; + + /* + if(targetType.Equals(typeof(int))) + { + retValue = new int(); + retValue = + } + */ + return retValue; + } + + /// Gets an information. + /// Fiedler, 13.11.2013. + /// Identifier for the place. + /// Information describing the search. + /// The information. + private string GetInfo(string placeID, string searchInfo) + { + string retValue = string.Empty; + + if (this.placeFile.Model != null) + { + PlaceModel model = this.placeFile.Model.GetPlaceById(placeID); + retValue = model.GetInformationsValue(searchInfo); + } + + return retValue; + } + + /// Place file is failed. + /// Fiedler, 13.11.2013. + private void PlaceFileIsFailed() + { + } + + /// Place file is ready. + /// Fiedler, 13.11.2013. + private void PlaceFileIsReady() + { + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Header/WeekViewPivotHeader.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Header/WeekViewPivotHeader.xaml index b860a6e2..39e9fd70 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Header/WeekViewPivotHeader.xaml +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Header/WeekViewPivotHeader.xaml @@ -29,7 +29,7 @@ - + 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/MultiValueTextBlock.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml new file mode 100644 index 00000000..747b8420 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml @@ -0,0 +1,18 @@ + + + + + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml.cs new file mode 100644 index 00000000..4d050d77 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml.cs @@ -0,0 +1,94 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 14.11.2013 +// Implements the multi value text block.xaml class +//----------------------------------------------------------------------- +namespace CampusAppWP8.Utility.Lui +{ + using System.Windows; + using System.Windows.Controls; + using System.Windows.Data; + + /// A multi value text block. + /// Fiedler, 14.11.2013. + /// + public partial class MultiValueTextBlock : UserControl + { + /// The value 1 property. + public static readonly DependencyProperty Value_1_Property = DependencyProperty.Register("Value1", typeof(object), typeof(MultiValueTextBlock), new PropertyMetadata(null, MultiValueTextBlock.OnLoaded)); + /// The value 2 property. + public static readonly DependencyProperty Value_2_Property = DependencyProperty.Register("Value2", typeof(object), typeof(MultiValueTextBlock), new PropertyMetadata(null, MultiValueTextBlock.OnLoaded)); + + /// The converter property. + public static readonly DependencyProperty ConverterProperty = DependencyProperty.Register("Converter", typeof(IValueConverter), typeof(MultiValueTextBlock), new PropertyMetadata(null, MultiValueTextBlock.OnLoaded)); + + /// Initializes a new instance of the MultiValueTextBlock class. + /// Fiedler, 14.11.2013. + public MultiValueTextBlock() : base() + { + this.InitializeComponent(); + } + + /// Gets or sets the converter. + /// The converter. + public IValueConverter Converter + { + get + { + return (IValueConverter)this.GetValue(ConverterProperty); + } + + set + { + this.SetValue(ConverterProperty, value); + } + } + + /// Gets or sets the value 1. + /// The value 1. + public object Value1 + { + get + { + return this.GetValue(Value_1_Property); + } + + set + { + this.SetValue(Value_1_Property, value); + } + } + + /// Gets or sets the value 2. + /// The value 2. + public object Value2 + { + get + { + return this.GetValue(Value_2_Property); + } + + set + { + this.SetValue(Value_2_Property, value); + } + } + + /// Raises the dependency property changed event. + /// Fiedler, 14.11.2013. + /// The DependencyObject to process. + /// Event information to send to registered event handlers. + private static void OnLoaded(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + MultiValueTextBlock obj = d as MultiValueTextBlock; + + if ((obj.Value1 != null) && (obj.Value2 != null) && (obj.Converter != null)) + { + obj.TheText.Text = (string)obj.Converter.Convert(obj.Value1, typeof(string), obj.Value2, System.Globalization.CultureInfo.CurrentCulture); + } + } + } +} 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/CampusAppWP8/Utility/MealIdToPriceConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs new file mode 100644 index 00000000..73caa561 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs @@ -0,0 +1,100 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 14.11.2013 +// Implements the meal identifier to price converter class +//----------------------------------------------------------------------- +namespace CampusAppWP8.Utility +{ + using System; + using System.Windows.Data; + using CampusAppWP8.Feed.Mensa; + using CampusAppWP8.Resources; + using CampusAppWPortalLib8.Model.Mensa; + + /// A meal identifier to price converter. + /// Fiedler, 14.11.2013. + /// + public sealed class MealIdToPriceConverter : IValueConverter + { + /// The price feed. + private PriceFeed priceFeed = null; + + /// Initializes a new instance of the MealIdToPriceConverter class. + /// Fiedler, 14.11.2013. + public MealIdToPriceConverter() + { + this.priceFeed = new PriceFeed(); + this.priceFeed.OnLoaded += this.PriceFeedIsReady; + this.priceFeed.OnFailedLoad += this.PriceFeedIsFailed; + this.priceFeed.LoadData(); + } + + /// + /// Ändert die Quelldaten vor der Übergabe an das Ziel zur Anzeige in der Benutzeroberfläche. + /// + /// Fiedler, 14.11.2013. + /// + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) + { + string retValue = string.Empty; + int intVal = -1; + int intParam = -1; + + if (value is int) + { + intVal = (int)value; + } + else if(value is string) + { + intVal = int.Parse((string)value); + } + + if (parameter is int) + { + intParam = (int)parameter; + } + else if (parameter is string) + { + intParam = int.Parse((string)parameter); + } + + if ((intVal >= 0) && (intParam >= 0)) + { + if (this.priceFeed != null && this.priceFeed.Model != null) + { + PriceMealModel model = this.priceFeed.Model.GetCanteen(intParam).GetPriceMealModel(intVal); + retValue = AppResources.Students + ": " + model.PriceStudentStr + " € " + AppResources.Employees + ": " + model.PriceEmployeeStr + " € " + AppResources.Guests + ": " + model.PriceGuestStr + " €"; + } + } + + return retValue; + } + + /// + /// Ändert die Zieldaten vor der Übergabe an das Quellobjekt. Diese Methode wird nur in + /// -Bindungen aufgerufen. + /// + /// Fiedler, 14.11.2013. + /// + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) + { + return null; + } + + /// Price feed is ready. + /// Fiedler, 14.11.2013. + private void PriceFeedIsReady() + { + this.priceFeed.SaveData(); + } + + /// Price feed is failed. + /// Fiedler, 14.11.2013. + private void PriceFeedIsFailed() + { + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs index 6a38a13a..f1df31c3 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Utilities.cs @@ -228,14 +228,14 @@ namespace CampusAppWP8.Utility /// Method determine the current position of the phone. /// Stubbfel, 14.10.2013. /// the position of the phone. - public static GeoPosition DetermineCurrentPosition() + public static GeoPosition DetermineCurrentPosition(GeoPositionAccuracy accuracy = GeoPositionAccuracy.High) { if (!Settings.AppSetting.GeoWatchEnable) { return null; } - GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(GeoPositionAccuracy.High); + GeoCoordinateWatcher watcher = new GeoCoordinateWatcher(accuracy); bool success = watcher.TryStart(false, TimeSpan.FromMilliseconds(10000)); GeoPosition geoposition = null; if (success) @@ -263,9 +263,9 @@ namespace CampusAppWP8.Utility /// Method determine and store the current position of the phone. /// Stubbfel, 14.10.2013. - public static void DetermineAndStoreCurrentPositionForce() + public static void DetermineAndStoreCurrentPositionForce(GeoPositionAccuracy accuracy = GeoPositionAccuracy.High) { - GeoPosition geoposition = Utilities.DetermineCurrentPosition(); + GeoPosition geoposition = Utilities.DetermineCurrentPosition(accuracy); if (geoposition != null) { @@ -285,19 +285,19 @@ namespace CampusAppWP8.Utility /// Method determine and store the current position of the phone, in 15 min interval. /// /// Stubbfel, 14.10.2013. - public static void DetermineAndStoreCurrentPosition() + public static void DetermineAndStoreCurrentPosition(GeoPositionAccuracy accuracy = GeoPositionAccuracy.High) { GeoMapPoint currentPoint = App.LoadFromAppState(Constants.GeoWatch_CurrentPositionPoint); if (currentPoint == null) { - Utilities.DetermineAndStoreCurrentPositionForce(); + Utilities.DetermineAndStoreCurrentPositionForce(accuracy); } else { DateTime expired = new DateTime(currentPoint.Timestamp).AddMinutes(15); if (DateTime.Now.Ticks > expired.Ticks) { - Utilities.DetermineAndStoreCurrentPositionForce(); + Utilities.DetermineAndStoreCurrentPositionForce(accuracy); } } } @@ -378,16 +378,25 @@ namespace CampusAppWP8.Utility /// Gets the determined campus. /// Stubbfel, 14.10.2013. /// The Campus. - public static Campus DetermineCampus() + public static Campus DetermineCampus(GeoPositionAccuracy accuracy = GeoPositionAccuracy.Default) { Campus result = Campus.UserSettingCampus; - Utilities.DetermineAndStoreCurrentPosition(); + + Utilities.DetermineAndStoreCurrentPosition(accuracy); MapPoint currentPoint = App.LoadFromAppState("CurrentGeoPoint"); if (currentPoint == null) { - return result; + if (accuracy.Equals(GeoPositionAccuracy.High)) + { + + return result; + } + else + { + return Utilities.DetermineCampus(GeoPositionAccuracy.High); + } } MapPoint tmpCampus = CampusMapPoints.NorthCB; diff --git a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj index ea952363..addae01f 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj +++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj @@ -62,8 +62,13 @@ + + + + + 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; } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs index 18a32b4d..e1502d6f 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/MealModel.cs @@ -112,6 +112,10 @@ namespace CampusAppWPortalLib8.Model.Mensa /// The icon URL. public string IconUrl { get; set; } + /// Gets or sets the price. + /// The price. + public string Price { get; set; } + /// Gets or sets the icon name. /// The name of the icon. [XmlAttribute("icon")] diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceCanteenModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceCanteenModel.cs new file mode 100644 index 00000000..26d6c5c3 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceCanteenModel.cs @@ -0,0 +1,185 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 13.11.2013 +// Implements the price canteen model class +//----------------------------------------------------------------------- +namespace CampusAppWPortalLib8.Model.Mensa +{ + using System.Collections.ObjectModel; + using System.Xml.Serialization; + using CampusAppWPortalLib8.Model.Utility; + + /// A data Model for the price canteen. + /// Fiedler, 13.11.2013. + public class PriceCanteenModel + { + /// The identifier. + private int id = -1; + /// The name de. + private string name_de = string.Empty; + /// URL of the name. + private string name_url = string.Empty; + /// The position. + private MapPoint pos = null; + /// List of prices. + private ObservableCollection priceList = null; + + /// Initializes a new instance of the PriceCanteenModel class. + /// Fiedler, 13.11.2013. + public PriceCanteenModel() + { + this.pos = new MapPoint(-1, -1); + this.priceList = new ObservableCollection(); + } + + /// Gets or sets the identifier. + /// The identifier. + [XmlAttribute("id")] + public string IdStr + { + get + { + return string.Empty + this.id; + } + + set + { + this.id = int.Parse(value); + } + } + + /// Gets or sets the identifier. + /// The identifier. + [XmlIgnore] + public int Id + { + get + { + return this.id; + } + + set + { + this.id = value; + } + } + + /// Gets or sets the name. + /// The name. + [XmlAttribute("name_de")] + public string Name + { + get + { + return this.name_de; + } + + set + { + this.name_de = value; + } + } + + /// Gets or sets URL of the document. + /// The URL. + [XmlAttribute("name_url")] + public string Url + { + get + { + return this.name_url; + } + + set + { + this.name_url = value; + } + } + + /// Gets or sets the x coordinate. + /// The x coordinate. + [XmlAttribute("x")] + public string X + { + get + { + return string.Empty + this.pos.X; + } + + set + { + this.pos.X = double.Parse(value); + } + } + + /// Gets or sets the y coordinate. + /// The y coordinate. + [XmlAttribute("y")] + public string Y + { + get + { + return string.Empty + this.pos.Y; + } + + set + { + this.pos.Y = double.Parse(value); + } + } + + /// Gets or sets the position. + /// The position. + [XmlIgnore] + public MapPoint Position + { + get + { + return this.pos; + } + + set + { + this.pos = value; + } + } + + /// Gets or sets the prices. + /// The prices. + [XmlElement("price")] + public ObservableCollection Prices + { + get + { + return this.priceList; + } + + set + { + this.priceList = value; + } + } + + /// Gets price meal model. + /// Fiedler, 13.11.2013. + /// Identifier for the meal. + /// The price meal model. + public PriceMealModel GetPriceMealModel(int meal_id) + { + PriceMealModel retValue = null; + + for (int i = 0; i < this.priceList.Count; i++) + { + if (this.priceList[i].MealID.Equals(meal_id)) + { + retValue = this.priceList[i]; + } + } + + return retValue; + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs new file mode 100644 index 00000000..460322f6 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs @@ -0,0 +1,169 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 13.11.2013 +// Implements the price meal model class +//----------------------------------------------------------------------- +namespace CampusAppWPortalLib8.Model.Mensa +{ + using System.Xml.Serialization; + + /// A data Model for the price meal. + /// Fiedler, 13.11.2013. + public class PriceMealModel + { + /// Identifier for the meal. + private int meal_id = -1; + /// The price student. + private double priceStudent = 0; + /// The price employee. + private double priceEmployee = 0; + /// The price guest. + private double priceGuest = 0; + + /// Initializes a new instance of the PriceMealModel class. + /// Fiedler, 13.11.2013. + public PriceMealModel() + { + } + + /// Gets or sets the identifier of the meal. + /// The identifier of the meal. + [XmlAttribute("meal_id")] + public string MealIDStr + { + get + { + return string.Empty + this.meal_id; + } + + set + { + this.meal_id = int.Parse(value); + } + } + + /// Gets or sets the identifier of the meal. + /// The identifier of the meal. + [XmlIgnore] + public int MealID + { + get + { + return this.meal_id; + } + + set + { + this.meal_id = value; + } + } + + /// Gets or sets the price student. + /// The price student. + [XmlAttribute("s")] + public string PriceStudentStr + { + get + { + return this.CurrencyString(this.priceStudent); + } + + set + { + this.priceStudent = double.Parse(value); + } + } + + /// Gets or sets the price student. + /// The price student. + [XmlIgnore] + public double PriceStudent + { + get + { + return this.priceStudent; + } + + set + { + this.priceStudent = value; + } + } + + /// Gets or sets the price employee. + /// The price employee. + [XmlAttribute("e")] + public string PriceEmployeeStr + { + get + { + return this.CurrencyString(this.priceEmployee); + } + + set + { + this.priceEmployee = double.Parse(value); + } + } + + /// Gets or sets the price employee. + /// The price employee. + [XmlIgnore] + public double PriceEmployee + { + get + { + return this.priceEmployee; + } + + set + { + this.priceEmployee = value; + } + } + + /// Gets or sets the price guest. + /// The price guest. + [XmlAttribute("g")] + public string PriceGuestStr + { + get + { + return this.CurrencyString(this.priceGuest); + } + + set + { + this.priceGuest = double.Parse(value); + } + } + + /// Gets or sets the price guest. + /// The price guest. + [XmlIgnore] + public double PriceGuest + { + get + { + return this.priceGuest; + } + + set + { + this.priceGuest = value; + } + } + + /// Currency string. + /// Fiedler, 14.11.2013. + /// The value. + /// A string. + private string CurrencyString(double val) + { + return string.Format("{0:0.00}", val); + } + } +} diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs new file mode 100644 index 00000000..5630e72a --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs @@ -0,0 +1,76 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 13.11.2013 +// Implements the price model class +//----------------------------------------------------------------------- +namespace CampusAppWPortalLib8.Model.Mensa +{ + using CampusAppWPortalLib8.Model.Settings; + using System.Collections.ObjectModel; + using System.Xml.Serialization; + + /// A data Model for the price. + /// Fiedler, 13.11.2013. + [XmlRoot("root")] + public class PriceModel + { + /// The canteens. + private ObservableCollection canteens = null; + + /// Initializes a new instance of the PriceModel class. + /// Fiedler, 13.11.2013. + public PriceModel() + { + this.canteens = new ObservableCollection(); + } + + /// Gets or sets the canteens. + /// The canteens. + [XmlArray("Canteens")] + [XmlArrayItem("Canteen")] + public ObservableCollection Canteens + { + get + { + return this.canteens; + } + + set + { + this.canteens = value; + } + } + + /// Gets a canteen. + /// Fiedler, 13.11.2013. + /// The identifier. + /// The canteen. + public PriceCanteenModel GetCanteen(int id) + { + PriceCanteenModel retValue = null; + + foreach (PriceCanteenModel prize in this.canteens) + { + if (prize.Id == id) + { + retValue = prize; + break; + } + } + + return retValue; + } + + /// Gets a canteen. + /// Stubbfel, 18.11.2013. + /// The campus. + /// The canteen. + public PriceCanteenModel GetCanteen(Campus campus) + { + return this.GetCanteen((int)campus - 1); + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpenhoursDayModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpenhoursDayModel.cs new file mode 100644 index 00000000..0718c121 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpenhoursDayModel.cs @@ -0,0 +1,217 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 12.11.2013 +// Implements the openhours day model class +//----------------------------------------------------------------------- +namespace CampusAppWPortalLib8.Model.Openinghours +{ + using System; + using System.Xml.Serialization; + + /// A data Model for the openinghours day. + /// Fiedler, 12.11.2013. + [XmlRoot("Open")] + public class OpeninghoursDayModel + { + /// The start. + private TimeSpan start; + /// The end. + private TimeSpan end; + /// The day. + private DayOfWeek day; + + /// Initializes a new instance of the OpeninghoursDayModel class. + /// Fiedler, 12.11.2013. + public OpeninghoursDayModel() + { + this.start = TimeSpan.Zero; + this.end = TimeSpan.Zero; + this.day = DayOfWeek.Sunday; + } + + /// Gets or sets the start. + /// The start. + [XmlAttribute("start")] + public string Start + { + get + { + return this.TimeSpanToString(this.start); + } + + set + { + this.start = this.StringToTimeSpan(value); + } + } + + /// Gets or sets the start. + /// The start. + [XmlIgnore] + public TimeSpan StartTS + { + get + { + return this.start; + } + + set + { + this.start = value; + } + } + + /// Gets or sets the end. + /// The end. + [XmlAttribute("end")] + public string End + { + get + { + return this.TimeSpanToString(this.end); + } + + set + { + this.end = this.StringToTimeSpan(value); + } + } + + /// Gets or sets the end. + /// The end. + [XmlIgnore] + public TimeSpan EndTS + { + get + { + return this.end; + } + + set + { + this.end = value; + } + } + + /// Gets or sets the day. + /// The day. + [XmlAttribute("day")] + public int Day + { + get + { + return this.DayOfWeekToInt(this.day); + } + + set + { + this.day = this.IntToDayOfWeek(value); + } + } + + /// Gets or sets the day. + /// The day. + [XmlIgnore] + public DayOfWeek DayDOW + { + get + { + return this.day; + } + + set + { + this.day = value; + } + } + + /// Gets the time string. + /// The time string. + [XmlIgnore] + public string TimeString + { + get + { + return this.TimeSpanToString(this.start) + " - " + this.TimeSpanToString(this.end); + } + } + + /// String to time span. + /// Fiedler, 12.11.2013. + /// The. + /// A TimeSpan. + private TimeSpan StringToTimeSpan(string str) + { + string[] split = str.Split(':'); + + return new TimeSpan( + int.Parse(split[0]), + (split.Length > 1) ? int.Parse(split[1]) : 0, + (split.Length > 2) ? int.Parse(split[2]) : 0); + } + + /// Time span to string. + /// Fiedler, 12.11.2013. + /// The span. + /// A string. + private string TimeSpanToString(TimeSpan span) + { + return string.Format("{0:hh\\:mm}", span); + } + + /// Int to day of week. + /// Fiedler, 12.11.2013. + /// + /// Thrown when the requested operation is not supported. + /// + /// The day nr. + /// A DayOfWeek. + private DayOfWeek IntToDayOfWeek(int dayNr) + { + DayOfWeek retValue = DayOfWeek.Sunday; + + switch(dayNr) + { + case 1: retValue = DayOfWeek.Monday; break; + case 2: retValue = DayOfWeek.Tuesday; break; + case 3: retValue = DayOfWeek.Wednesday; break; + case 4: retValue = DayOfWeek.Thursday; break; + case 5: retValue = DayOfWeek.Friday; break; + case 6: retValue = DayOfWeek.Saturday; break; + case 7: retValue = DayOfWeek.Sunday; break; + + default: + { + throw new NotSupportedException("day number is not supported (" + dayNr + ")"); + } + } + + return retValue; + } + + /// Day of week to int. + /// Fiedler, 12.11.2013. + /// The dow. + /// An int. + private int DayOfWeekToInt(DayOfWeek dow) + { + int retValue = -1; + + switch (dow) + { + case DayOfWeek.Monday: retValue = 1; break; + case DayOfWeek.Tuesday: retValue = 2; break; + case DayOfWeek.Wednesday: retValue = 3; break; + case DayOfWeek.Thursday: retValue = 4; break; + case DayOfWeek.Friday: retValue = 5; break; + case DayOfWeek.Saturday: retValue = 6; break; + case DayOfWeek.Sunday: retValue = 7; break; + } + + return retValue; + } + } +} diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursInstitutionModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursInstitutionModel.cs index 5a59452b..e2c4892d 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursInstitutionModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursInstitutionModel.cs @@ -8,6 +8,8 @@ //----------------------------------------------------------------------- namespace CampusAppWPortalLib8.Model.Openinghours { + using System; + using System.Collections.ObjectModel; using System.Globalization; using System.Windows; using System.Xml.Serialization; @@ -24,27 +26,6 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// English version of the institution title. private string titleEN = string.Empty; - /// Opening hours on monday. - private string dayMonday = string.Empty; - - /// Opening hours on tuesday. - private string dayTuesday = string.Empty; - - /// Opening hours on wednesday. - private string dayWednesday = string.Empty; - - /// Opening hours on thursday. - private string dayThursday = string.Empty; - - /// Opening hours on friday. - private string dayFriday = string.Empty; - - /// Opening hours on saturday. - private string daySaturday = string.Empty; - - /// Opening hours on sunday. - private string daySunday = string.Empty; - /// Email address of the institution. private string infoEmail = string.Empty; @@ -63,6 +44,9 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// English version of the comment. private string commentEN = string.Empty; + /// List of days. + private ObservableCollection dayList = null; + #endregion #region Constructor @@ -73,6 +57,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// Stubbfel, 15.10.2013. public OpeninghoursInstitutionModel() { + this.dayList = new ObservableCollection(); } #endregion @@ -111,115 +96,80 @@ namespace CampusAppWPortalLib8.Model.Openinghours } } - /// Gets or sets the open hours on monday. + /// Gets the open hours on monday. /// The monday. - [XmlAttribute("monday")] + [XmlIgnore] public string Monday { get { - return this.dayMonday; - } - - set - { - this.dayMonday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Monday); } } - /// Gets or sets the open hours on tuesday. + /// Gets the open hours on tuesday. /// The tuesday. - [XmlAttribute("tuesday")] + [XmlIgnore] public string Tuesday { get { - return this.dayTuesday; - } - - set - { - this.dayTuesday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Tuesday); } } - /// Gets or sets the open hours on wednesday. + /// Gets the open hours on wednesday. /// The wednesday. - [XmlAttribute("wednesday")] + [XmlIgnore] public string Wednesday { get { - return this.dayWednesday; - } - - set - { - this.dayWednesday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Wednesday); } } - /// Gets or sets the open hours on thursday. + /// Gets the open hours on thursday. /// The thursday. - [XmlAttribute("thursday")] + [XmlIgnore] public string Thursday { get { - return this.dayThursday; - } - - set - { - this.dayThursday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Thursday); } } - /// Gets or sets the open hours on friday. + /// Gets the open hours on friday. /// The friday. - [XmlAttribute("friday")] + [XmlIgnore] public string Friday { get { - return this.dayFriday; - } - - set - { - this.dayFriday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Friday); } } - /// Gets or sets the open hours on saturday. + /// Gets the open hours on saturday. /// The saturday. - [XmlAttribute("saturday")] + [XmlIgnore] public string Saturday { get { - return this.daySaturday; - } - - set - { - this.daySaturday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Saturday); } } - /// Gets or sets the open hours on sunday. + /// Gets the open hours on sunday. /// The sunday. - [XmlAttribute("sunday")] + [XmlIgnore] public string Sunday { get { - return this.daySunday; - } - - set - { - this.daySunday = this.FixOpeninghoursString(value); + return this.DayToString(DayOfWeek.Sunday); } } @@ -319,11 +269,28 @@ namespace CampusAppWPortalLib8.Model.Openinghours } } + /// Gets or sets the days. + /// The days. + [XmlElement("Open")] + public ObservableCollection Days + { + get + { + return this.dayList; + } + + set + { + this.dayList = value; + } + } + /// /// Gets the localized title. If the phone is set to german language, the german title will /// be returned otherwise the english title. /// /// The title. + [XmlIgnore] public string Title { get @@ -344,6 +311,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// will be returned otherwise the english comment. /// /// The comment. + [XmlIgnore] public string Comment { get @@ -363,6 +331,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// Gets a string containing the email address and the institution title separated by ':'. /// /// The e mail title. + [XmlIgnore] public string EMailTitle { get @@ -375,6 +344,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// Gets a string containing the phone number and the institution title separated by ':'. /// /// The phone title. + [XmlIgnore] public string PhoneTitle { get @@ -383,19 +353,183 @@ namespace CampusAppWPortalLib8.Model.Openinghours } } + /// Gets a value indicating whether the visible monday. + /// true if visible monday, false if not. + [XmlIgnore] + public bool VisibleMonday + { + get + { + return this.HasDay(DayOfWeek.Monday); + } + } + + /// Gets a value indicating whether the visible tuesday. + /// true if visible tuesday, false if not. + [XmlIgnore] + public bool VisibleTuesday + { + get + { + return this.HasDay(DayOfWeek.Tuesday); + } + } + + /// Gets a value indicating whether the visible wednesday. + /// true if visible wednesday, false if not. + [XmlIgnore] + public bool VisibleWednesday + { + get + { + return this.HasDay(DayOfWeek.Wednesday); + } + } + + /// Gets a value indicating whether the visible thursday. + /// true if visible thursday, false if not. + [XmlIgnore] + public bool VisibleThursday + { + get + { + return this.HasDay(DayOfWeek.Thursday); + } + } + + /// Gets a value indicating whether the visible friday. + /// true if visible friday, false if not. + [XmlIgnore] + public bool VisibleFriday + { + get + { + return this.HasDay(DayOfWeek.Friday); + } + } + + /// Gets a value indicating whether the visible saturday. + /// true if visible saturday, false if not. + [XmlIgnore] + public bool VisibleSaturday + { + get + { + return this.HasDay(DayOfWeek.Saturday); + } + } + + /// Gets a value indicating whether the visible sunday. + /// true if visible sunday, false if not. + [XmlIgnore] + public bool VisibleSunday + { + get + { + return this.HasDay(DayOfWeek.Sunday); + } + } + + /// Gets a value indicating whether the visible comment. + /// true if visible comment, false if not. + [XmlIgnore] + public bool VisibleComment + { + get + { + return !((this.Comment == string.Empty) || (this.Comment.Length == 0)); + } + } + + /// Gets a value indicating whether the visible mail. + /// true if visible mail, false if not. + [XmlIgnore] + public bool VisibleEMail + { + get + { + return !((this.EMail == string.Empty) || (this.EMail.Length == 0)); + } + } + + /// Gets a value indicating whether the visible phone. + /// true if visible phone, false if not. + [XmlIgnore] + public bool VisiblePhone + { + get + { + return !((this.Phone == string.Empty) || (this.Phone.Length == 0)); + } + } + + /// Gets a value indicating whether the visible room. + /// true if visible room, false if not. + [XmlIgnore] + public bool VisibleRoom + { + get + { + return !((this.Room == string.Empty) || (this.Room.Length == 0)); + } + } + + /// Gets a value indicating whether the visible building. + /// true if visible building, false if not. + [XmlIgnore] + public bool VisibleBuilding + { + get + { + return !((this.Building == string.Empty) || (this.Building.Length == 0)); + } + } + #endregion #region Method - /// Removes unwanted chars in a string. - /// Stubbfel, 15.10.2013. - /// input string. - /// fixed string. - private string FixOpeninghoursString(string str) + /// Day to string. + /// Fiedler, 13.11.2013. + /// The dow. + /// A string. + private string DayToString(DayOfWeek dow) { string retValue = string.Empty; - retValue = str.Replace(" | ", "\n"); + foreach (OpeninghoursDayModel dm in this.dayList) + { + if (dm.DayDOW.Equals(dow)) + { + if (retValue.Equals(string.Empty)) + { + retValue += dm.TimeString; + } + else + { + retValue += "\n" + dm.TimeString; + } + } + } + + return retValue; + } + + /// Query if 'dow' has day. + /// Fiedler, 13.11.2013. + /// The dow. + /// true if day, false if not. + private bool HasDay(DayOfWeek dow) + { + bool retValue = false; + + foreach (OpeninghoursDayModel dm in this.dayList) + { + if (dm.DayDOW.Equals(dow)) + { + retValue = true; + } + } return retValue; } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursLocationModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursLocationModel.cs new file mode 100644 index 00000000..e2027919 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursLocationModel.cs @@ -0,0 +1,62 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 13.11.2013 +// Implements the openinghours location model class +//----------------------------------------------------------------------- +namespace CampusAppWPortalLib8.Model.Openinghours +{ + using System.Collections.ObjectModel; + using System.Xml.Serialization; + + /// Model for menu. + /// Stubbfel, 15.10.2013. + public class OpeninghoursLocationModel + { + /// The institutions. + private ObservableCollection institutions = null; + /// Identifier for the location. + private int locationID = -1; + + /// Initializes a new instance of the OpeninghoursLocationModel class. + /// Fiedler, 13.11.2013. + public OpeninghoursLocationModel() + { + this.institutions = new ObservableCollection(); + } + + /// Gets or sets the identifier of the location. + /// The identifier of the location. + [XmlAttribute("id")] + public int LocationID + { + get + { + return this.locationID; + } + + set + { + this.locationID = value; + } + } + + /// Gets or sets the institutions. + /// The institutions. + [XmlElement("Object")] + public ObservableCollection Institutions + { + get + { + return this.institutions; + } + + set + { + this.institutions = value; + } + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursModel.cs index 42492466..c0dc5316 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursModel.cs @@ -16,7 +16,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// fiedlchr, 15.10.2013. /// Generic type parameter. [XmlRoot("root")] - public class OpeninghoursModel where T : OpeninghoursInstitutionModel + public class OpeninghoursModel { #region Member @@ -24,7 +24,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours private readonly DateTime createTime; /// Gets or sets feed information item list. - private ObservableCollection institutions; + private ObservableCollection locations; #endregion @@ -34,7 +34,7 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// fiedlchr, 15.10.2013. public OpeninghoursModel() { - this.institutions = new ObservableCollection(); + this.locations = new ObservableCollection(); this.createTime = DateTime.Now; } @@ -55,17 +55,17 @@ namespace CampusAppWPortalLib8.Model.Openinghours /// Gets or sets the Institutions. /// The institutions. [XmlArray("data")] - [XmlArrayItem("institution")] - public ObservableCollection Institutions + [XmlArrayItem("Location")] + public ObservableCollection Locations { get { - return this.institutions; + return this.locations; } set { - this.institutions = value; + this.locations = value; } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/MapPoint.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/MapPoint.cs index 3a6de69f..a9ea34e6 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/MapPoint.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Utility/MapPoint.cs @@ -134,6 +134,31 @@ namespace CampusAppWPortalLib8.Model.Utility return false; } + /// Rotate degrees. + /// Fiedler, 13.11.2013. + /// The fix point. + /// The angle degrees. positive values -> counterclockwise rotation. + /// A MapPoint. + public MapPoint RotateDeg(MapPoint fixPoint, double angleDeg) + { + return this.Rotate(fixPoint, angleDeg * (Math.PI / 180)); + } + + /// Rotates. + /// Fiedler, 13.11.2013. + /// The fix point. + /// The angle radians. positive values -> counterclockwise rotation. + /// A MapPoint. + public MapPoint Rotate(MapPoint fixPoint, double angleRad) + { + MapPoint retValue = new MapPoint(0, 0); + + retValue.X = fixPoint.X + (this.X - fixPoint.X) * Math.Cos(angleRad) - (this.Y - fixPoint.Y) * Math.Sin(angleRad); + retValue.Y = fixPoint.Y + (this.X - fixPoint.X) * Math.Sin(angleRad) + (this.Y - fixPoint.Y) * Math.Cos(angleRad); + + return retValue; + } + #endregion } }