From c6ea2b5ed7982afd2733be72be54353a134a51a6 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Thu, 24 Oct 2013 13:38:39 +0200 Subject: [PATCH 01/22] bla --- .../Pages/TimeTable/TimeTableWeek.xaml | 5 +-- .../Pages/TimeTable/TimeTableWeek.xaml.cs | 7 +++- .../CampusAppWP8/Properties/WMAppManifest.xml | 2 +- .../Lui/Header/WeekViewPivotHeader.xaml | 2 +- .../Lui/Header/WeekViewPivotHeader.xaml.cs | 32 ++++++++++++++++++- 5 files changed, 42 insertions(+), 6 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml index ffa1094b..1693c64b 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}" @@ -16,10 +17,10 @@ - + - + diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs index 58ed4163..c1f3ab39 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs @@ -21,6 +21,7 @@ namespace CampusAppWP8.Pages.TimeTable using CampusAppWP8.Model.TimeTable; using CampusAppWP8.Resources; using CampusAppWP8.Utility.Lui.Templates; + using CampusAppWP8.Utility.Lui.Header; public partial class TimeTableWeek : PhoneApplicationPage { @@ -822,12 +823,16 @@ namespace CampusAppWP8.Pages.TimeTable private void ThePivot_LoadedPivotItem(object sender, PivotItemEventArgs e) { - } private void Grid_Loaded(object sender, RoutedEventArgs e) { } + + private void ThePivot_LoadingPivotItem(object sender, PivotItemEventArgs e) + { + + } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml b/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml index 288b01c9..ebcb1c37 100644 --- a/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml +++ b/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml @@ -13,7 +13,7 @@ - + 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); + } + } } } From 4b33e1fe34901b32068a41b8a9e5be30c8e2534a Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Thu, 24 Oct 2013 19:26:11 +0200 Subject: [PATCH 02/22] i can see a weekview --- .../Pages/TimeTable/TimeTableWeek.xaml | 14 +- .../Pages/TimeTable/TimeTableWeek.xaml.cs | 102 ++++++----- .../Resources/AppResources.Designer.cs | 9 + .../CampusAppWP8/Resources/AppResources.resx | 3 + .../Utility/Lui/Templates/WeekView.xaml | 170 ++++++++++++------ .../Utility/Lui/Templates/WeekView.xaml.cs | 75 ++++++-- 6 files changed, 255 insertions(+), 118 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml index 1693c64b..e579f271 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml @@ -17,17 +17,21 @@ - + - + - - - + diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs index c1f3ab39..5c399192 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs @@ -22,6 +22,7 @@ namespace CampusAppWP8.Pages.TimeTable using CampusAppWP8.Resources; using CampusAppWP8.Utility.Lui.Templates; using CampusAppWP8.Utility.Lui.Header; + using System.Windows.Data; public partial class TimeTableWeek : PhoneApplicationPage { @@ -41,8 +42,7 @@ namespace CampusAppWP8.Pages.TimeTable public int WeekNumber { get; set; } public WeekView weekView { get; set; } //??? - public List appointmentList { get; set; } - public PivotItem pItemPtr { get; set; } + public List AppointmentList { get; set; } } private static readonly int PIVOT_PAGES = 3; @@ -51,7 +51,6 @@ namespace CampusAppWP8.Pages.TimeTable private PageItem[] itemPages = new PageItem[PIVOT_PAGES]; private int lastSelectedIndex = 0; - private int loadedWeekView = 0; public TimeTableWeek() { @@ -63,6 +62,8 @@ namespace CampusAppWP8.Pages.TimeTable { this.itemPages[i].DateFrom = firstDay; this.itemPages[i].DateTo = firstDay.AddDays(6); + this.itemPages[i].WeekNumber = this.GetWeekNumber(this.itemPages[i].DateFrom); + this.itemPages[i].WeekChar = ((this.itemPages[i].WeekNumber % 2) != 0) ? 'A' : 'B'; firstDay = firstDay.AddDays(7); } @@ -119,6 +120,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; @@ -157,10 +168,7 @@ namespace CampusAppWP8.Pages.TimeTable { 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].WeekNumber = this.GetWeekNumber(this.itemPages[i].DateFrom); this.itemPages[i].WeekChar = ((this.itemPages[i].WeekNumber % 2) == 0) ? 'B' : 'A'; firstDay = firstDay.AddDays(7); @@ -625,25 +633,6 @@ namespace CampusAppWP8.Pages.TimeTable */ } - 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) @@ -747,7 +736,46 @@ namespace CampusAppWP8.Pages.TimeTable // this.itemPages[index].Content.Children.Add(can); } +/* + private PageItem CreatePivotItem(PageItem pItem) + { + pItem.pItemPtr = new PivotItem(); + pItem.pItemPtr.Header = new Grid(); + + pItem.weekView = new WeekView(); + pItem.weekView.Name = "TheWeekView"; + pItem.weekView.StartDate = pItem.DateFrom; + WeekViewPivotHeader wvpHeader = new WeekViewPivotHeader(); + wvpHeader.DateFrom = pItem.DateFrom; + + Grid g = (pItem.pItemPtr.Header as Grid); + + Binding colLineBind = new Binding(); + colLineBind.Path = new PropertyPath("ActualWidth"); + colLineBind.ElementName = "TheWeekView"; + colLineBind.Mode = BindingMode.OneWay; + + g.SetBinding(WidthProperty, colLineBind); + g.Children.Clear(); + //wvpHeader.Width = g.Width; + //g.Children.Add(wvpHeader); + + RowDefinition row = new RowDefinition(); + row.Height = GridLength.Auto; + g.RowDefinitions.Add(row); + + g.Background = new SolidColorBrush(Colors.Green); + TextBlock tb = new TextBlock(); + tb.Text = "hallo"; + tb.SetValue(Grid.RowProperty, 0); + g.Children.Add(tb); + + pItem.pItemPtr.Content = pItem.weekView; + + return pItem; + } +*/ private void DrawHeader(int index) { Grid grid = ((this.ThePivot.Items[index] as PivotItem).Header as Grid); @@ -810,29 +838,9 @@ namespace CampusAppWP8.Pages.TimeTable 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) - { - - } - - private void ThePivot_LoadingPivotItem(object sender, PivotItemEventArgs e) - { - + } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index dffe834c..97f47b74 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. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 90588cd5..52126cbe 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -596,4 +596,7 @@ Mi + + KW + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml index 3194e106..85cec670 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml @@ -10,65 +10,123 @@ FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" > - - - - - + + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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..8e8194e9 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs @@ -17,10 +17,16 @@ namespace CampusAppWP8.Utility.Lui.Templates using System.Windows.Media; using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; + using CampusAppWP8.Model.TimeTable; public partial class WeekView : UserControl { - public static readonly DependencyProperty StartDateProperty = DependencyProperty.Register("StartDate", typeof(DateTime), typeof(WeekView), new PropertyMetadata(null)); + public static readonly DependencyProperty DateFromProperty = DependencyProperty.Register("DateFrom", typeof(DateTime), typeof(WeekView), new PropertyMetadata(null)); + public static readonly DependencyProperty DateToProperty = DependencyProperty.Register("DateTo", typeof(DateTime), typeof(WeekView), new PropertyMetadata(null)); + public static readonly DependencyProperty DaysProperty = DependencyProperty.Register("Days", typeof(int), typeof(WeekView), new PropertyMetadata(null)); + public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(List), typeof(WeekView), new PropertyMetadata(null)); + public static readonly DependencyProperty WeekNameProperty = DependencyProperty.Register("WeekName", typeof(string), typeof(WeekView), new PropertyMetadata(null)); + public static readonly DependencyProperty WeekNumberProperty = DependencyProperty.Register("WeekNumber", typeof(int), typeof(WeekView), new PropertyMetadata(null)); private List borderList = new List(); @@ -29,21 +35,76 @@ namespace CampusAppWP8.Utility.Lui.Templates public WeekView() { + this.Days = 5; + this.InitializeComponent(); this.InitLayout(); } - public DateTime StartDate + public DateTime DateFrom { get { - return (DateTime)this.GetValue(StartDateProperty); + return (DateTime)this.GetValue(DateFromProperty); } set { - this.SetValue(StartDateProperty, value); + 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); + } + } + + public List Appointments + { + get + { + return (List)this.GetValue(AppointmentsProperty); + } + + set + { + this.SetValue(AppointmentsProperty, value); + } + } + + public string WeekName + { + get + { + return (string)this.GetValue(WeekNameProperty); + } + + set + { + this.SetValue(WeekNameProperty, value); + } + } + + public int WeekNumber + { + get + { + return (int)this.GetValue(WeekNumberProperty); + } + + set + { + this.SetValue(WeekNumberProperty, value); } } @@ -70,12 +131,6 @@ namespace CampusAppWP8.Utility.Lui.Templates this.borderList.Add(this.FriBorder); this.TimeList.ItemsSource = this.timeStrings; - - //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; } } } From 56228da6411956d0a0103e8d7130e4d1bfe4e17f Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Mon, 28 Oct 2013 19:17:29 +0100 Subject: [PATCH 03/22] daily commit --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 8 + .../Model/TimeTable/AppointmentModel.cs | 114 +++------ .../CampusAppWP8/Pages/TimeTable/TimeTable.cs | 6 +- .../Pages/TimeTable/TimeTableDay.xaml.cs | 2 + .../Pages/TimeTable/TimeTableWeek.xaml | 13 +- .../Pages/TimeTable/TimeTableWeek.xaml.cs | 218 +++--------------- .../Pages/TimeTable/WeekViewPageItem.cs | 128 ++++++++++ .../Lui/Templates/AppointmentCanvas.xaml | 28 +++ .../Lui/Templates/AppointmentCanvas.xaml.cs | 125 ++++++++++ .../Utility/Lui/Templates/WeekView.xaml | 12 +- .../Utility/Lui/Templates/WeekView.xaml.cs | 104 ++++++++- .../Utility/Lui/Templates/WeekViewDay.xaml | 11 +- .../Utility/Lui/Templates/WeekViewDay.xaml.cs | 115 ++++++++- 13 files changed, 581 insertions(+), 303 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs create mode 100644 CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml create mode 100644 CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index bad54601..2748d227 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -151,6 +151,7 @@ TimeTableWeek.xaml + @@ -247,6 +248,9 @@ WeekViewPivotHeader.xaml + + AppointmentCanvas.xaml + WeekView.xaml @@ -531,6 +535,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs index b4aaaca5..918e2ebc 100644 --- a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs @@ -25,16 +25,8 @@ namespace CampusAppWP8.Model.TimeTable [XmlRoot("root")] 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; - private ICalObject icalObj = null; - //private ICalObject eventICalObj = null; - + public delegate void OnAppointmentClick(AppointmentModel sender); public event OnAppointmentClick OnClick = null; @@ -53,11 +45,6 @@ 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); } public AppointmentModel(string icsData) : this() @@ -150,93 +137,50 @@ namespace CampusAppWP8.Model.TimeTable vevent.AddProperty(value); } - public Canvas GetCanvas(double width, double hourSpacing, DateTime date) + 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) + 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) + 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; } private ICalObject GetVEventObj(bool create = false) diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs index 65f5dded..fffa353a 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs @@ -24,9 +24,9 @@ namespace CampusAppWP8.Pages.TimeTable { private static AppointmentListModel appList //= null; = new AppointmentListModel(new AppointmentModel[] { - new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:ownCloud Calendar 0.6.3\r\nX-WR-CALNAME:Das is der Titel\r\nBEGIN:VEVENT\r\nCREATED;VALUE=DATE-TIME:20130827T113216Z\r\nUID:c9904ea73c\r\nLAST-MODIFIED;VALUE=DATE-TIME:20130827T113216Z\r\nDTSTAMP;VALUE=DATE-TIME:20130827T113216Z\r\nSUMMARY:Das is der Titel\r\nDTSTART;VALUE=DATE-TIME: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: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:20131022T113500Z\r\nDTEND;VALUE=DATE-TIME:20131022T212000Z\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 welche einen etwas längeren titel enthält\r\nDESCRIPTION:Beschreibung des Termines\r\nCLASS:PUBLIC\r\nDTSTART:20131023T110000Z\r\nDTEND:20131024T113000Z\r\nDTSTAMP:20131003T125900Z\r\nPRIORITY:3\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:20131025T150000Z\r\nDTEND:20131025T170000Z\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") diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs index f4f6c819..43226ae6 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs @@ -471,6 +471,7 @@ namespace CampusAppWP8.Pages.TimeTable private void DrawAppointmentModel(AppointmentModel model, int index, double opacity = 1.0, int zIndex = 0, int modelCount = 0) { +/* TODO Canvas modelCan = model.GetCanvas( ((this.itemPages[index].Content.Width - DAY_TABLE_HEAD_WIDTH) - 2 - 2 - (modelCount * DAY_TABLE_ZINDEX_SHIFT)), DAY_TABLE_CELL_HEIGHT, @@ -479,6 +480,7 @@ namespace CampusAppWP8.Pages.TimeTable 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) diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml index e579f271..c1e89fdd 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml @@ -13,7 +13,8 @@ Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="Landscape" Orientation="Landscape" mc:Ignorable="d" - shell:SystemTray.IsVisible="True"> + shell:SystemTray.IsVisible="True" + > @@ -27,11 +28,11 @@ + Margin="0,-36,0,0" + DateFrom="{Binding Path=FromDT, Mode=OneWay}" + WeekName="{Binding Path=WeekStr, Mode=OneWay}" + Appointments="{Binding Path=AppointmentList, Mode=OneWay}" + WeekNumber="{Binding Path=WeekNr, Mode=OneWay}"/> diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs index 5c399192..75e324ba 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.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; @@ -33,25 +34,14 @@ namespace CampusAppWP8.Pages.TimeTable 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; } - } - 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 ObservableCollection itemList = new ObservableCollection(); + public TimeTableWeek() { this.InitializeComponent(); @@ -60,10 +50,13 @@ namespace CampusAppWP8.Pages.TimeTable for (int i = 0; i < PIVOT_PAGES; i++) { - this.itemPages[i].DateFrom = firstDay; - this.itemPages[i].DateTo = firstDay.AddDays(6); - this.itemPages[i].WeekNumber = this.GetWeekNumber(this.itemPages[i].DateFrom); - this.itemPages[i].WeekChar = ((this.itemPages[i].WeekNumber % 2) != 0) ? 'A' : 'B'; + 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); } @@ -102,9 +95,11 @@ namespace CampusAppWP8.Pages.TimeTable } 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(); } } @@ -156,6 +151,7 @@ namespace CampusAppWP8.Pages.TimeTable page.NavigationService.Navigate(url); */ // this.itemPages[this.ThePivot.SelectedIndex].weekView.SetColumnBackground(0, new SolidColorBrush(Colors.Red)); + (this.ThePivot.SelectedItem as WeekViewPageItem).AppointmentList.Add(TimeTable.AppointmentsModel.Appointments[1]); } private void OnClickToday(object sender, EventArgs e) @@ -198,7 +194,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; @@ -210,10 +206,10 @@ namespace CampusAppWP8.Pages.TimeTable } 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.itemPages[index].Content.Children.Clear(); // this.itemPages[index].WeekNumber = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear( // this.itemPages[index].DateFrom, @@ -292,7 +288,7 @@ namespace CampusAppWP8.Pages.TimeTable */ // this.RemoveContentUIElement(index, sender as Canvas); - bool bubbleDrawn = false; + //bool bubbleDrawn = false; /* for (int day = 0; day < 5; day++) { @@ -329,7 +325,7 @@ namespace CampusAppWP8.Pages.TimeTable { for (int i = 0; i < PIVOT_PAGES; i++) { - if (tempModel.IsDate(this.itemPages[i].DateFrom, 4) > -1) + if (tempModel.IsDate(this.itemList[i].FromDT, 4) > -1) { this.SetupPage(i); } @@ -337,30 +333,21 @@ namespace CampusAppWP8.Pages.TimeTable } } - private void OnCanvasSizeChanged(object sender, SizeChangedEventArgs e) + private void CheckAppointments() { - /* - if (e.NewSize.Width.Equals(e.PreviousSize.Width) == false) + foreach (AppointmentModel m in TimeTable.AppointmentsModel.Appointments) { - 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); + for (int i = 0; i < PIVOT_PAGES; i++) + { + if (m.IsDate(this.itemList[i].FromDT, 4) >= 0) + { + this.itemList[i].AppointmentList.Add(m); + } + } } - */ } + private void SetupPage(int index) { // Header @@ -400,7 +387,7 @@ namespace CampusAppWP8.Pages.TimeTable } } */ - if (TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemPages[index].DateFrom.Date, 4) > -1) + if (TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemList[index].FromDT.Date, 4) > -1) { tempList.Add(TimeTable.AppointmentsModel.Appointments[i]); } @@ -633,46 +620,6 @@ namespace CampusAppWP8.Pages.TimeTable */ } - 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) { /* @@ -736,107 +683,6 @@ namespace CampusAppWP8.Pages.TimeTable // this.itemPages[index].Content.Children.Add(can); } -/* - private PageItem CreatePivotItem(PageItem pItem) - { - pItem.pItemPtr = new PivotItem(); - pItem.pItemPtr.Header = new Grid(); - - pItem.weekView = new WeekView(); - pItem.weekView.Name = "TheWeekView"; - pItem.weekView.StartDate = pItem.DateFrom; - - WeekViewPivotHeader wvpHeader = new WeekViewPivotHeader(); - wvpHeader.DateFrom = pItem.DateFrom; - - Grid g = (pItem.pItemPtr.Header as Grid); - - Binding colLineBind = new Binding(); - colLineBind.Path = new PropertyPath("ActualWidth"); - colLineBind.ElementName = "TheWeekView"; - colLineBind.Mode = BindingMode.OneWay; - - g.SetBinding(WidthProperty, colLineBind); - g.Children.Clear(); - //wvpHeader.Width = g.Width; - //g.Children.Add(wvpHeader); - - RowDefinition row = new RowDefinition(); - row.Height = GridLength.Auto; - g.RowDefinitions.Add(row); - - g.Background = new SolidColorBrush(Colors.Green); - TextBlock tb = new TextBlock(); - tb.Text = "hallo"; - tb.SetValue(Grid.RowProperty, 0); - g.Children.Add(tb); - - pItem.pItemPtr.Content = pItem.weekView; - - return pItem; - } -*/ - 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 ThePivot_LoadedPivotItem(object sender, PivotItemEventArgs e) { diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs new file mode 100644 index 00000000..b56d75b8 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs @@ -0,0 +1,128 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using CampusAppWP8.Utility.Lui.Templates; +using CampusAppWP8.Model.TimeTable; +using System.ComponentModel; + +namespace CampusAppWP8.Pages.TimeTable +{ + public class WeekViewPageItem : INotifyPropertyChanged + { + private DateTime fromDT; + private DateTime toDT; + private int days; + private string weekStr = string.Empty; + private int weekNumber = -1; + private WeekView weekView = null; + private ObservableCollection appointmentList = null; + + public event PropertyChangedEventHandler PropertyChanged; + + + 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(); + } + + public DateTime FromDT + { + get + { + return this.fromDT; + } + + set + { + this.fromDT = value; + this.NotifyPropertyChanged("FromDT"); + } + } + + public DateTime ToDT + { + get + { + return this.toDT; + } + + set + { + this.toDT = value; + this.NotifyPropertyChanged("ToDT"); + } + } + + public string WeekStr + { + get + { + return this.weekStr; + } + + set + { + this.weekStr = value; + this.NotifyPropertyChanged("WeekStr"); + } + } + + public int WeekNr + { + get + { + return this.weekNumber; + } + + set + { + this.weekNumber = value; + this.NotifyPropertyChanged("WeekNr"); + } + } + + 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/Utility/Lui/Templates/AppointmentCanvas.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml new file mode 100644 index 00000000..8608ffe9 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml @@ -0,0 +1,28 @@ + + + + + + + + \ 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..12d870b2 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml.cs @@ -0,0 +1,125 @@ +//----------------------------------------------------------------------- +// +// 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 System.Windows.Data; + using System.Windows.Media; + + public partial class AppointmentCanvas : UserControl + { + private static readonly double HOURS_SPACING = 40; + private static readonly double INDEX_SPACING = 10; + + private static readonly SolidColorBrush[] PRIO_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) + }; + + 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; + + this.Height = model.GetTotalHours(day) * HOURS_SPACING; + this.SetText(model.Title); + this.SetValue(Canvas.TopProperty, (day.Date.Equals(model.Start.Date)) ? (model.Start.TimeOfDay.TotalHours * HOURS_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( + (INDEX_SPACING * index), + 0, + (INDEX_SPACING * count), + 0); + + if (index > 0) + { + 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) + { + this.TheText.Text = text; + } + + private void SetBGColorByPriority(int prio) + { + if (prio < PRIO_COLORS.Count() && prio >= 0) + { + this.TheRect.Fill = PRIO_COLORS[prio]; + } + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml index 85cec670..87dab9c4 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml @@ -9,7 +9,7 @@ FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" - > + x:Name="root"> @@ -30,12 +30,12 @@ - - + + - + - + @@ -48,7 +48,7 @@ - + diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs index 8e8194e9..27e76a26 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs @@ -9,6 +9,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; @@ -18,30 +20,89 @@ namespace CampusAppWP8.Utility.Lui.Templates using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using CampusAppWP8.Model.TimeTable; - + + public partial class WeekView : UserControl { - public static readonly DependencyProperty DateFromProperty = DependencyProperty.Register("DateFrom", typeof(DateTime), typeof(WeekView), new PropertyMetadata(null)); - public static readonly DependencyProperty DateToProperty = DependencyProperty.Register("DateTo", typeof(DateTime), typeof(WeekView), new PropertyMetadata(null)); - public static readonly DependencyProperty DaysProperty = DependencyProperty.Register("Days", typeof(int), typeof(WeekView), new PropertyMetadata(null)); - public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(List), typeof(WeekView), new PropertyMetadata(null)); - public static readonly DependencyProperty WeekNameProperty = DependencyProperty.Register("WeekName", typeof(string), typeof(WeekView), new PropertyMetadata(null)); - public static readonly DependencyProperty WeekNumberProperty = DependencyProperty.Register("WeekNumber", typeof(int), typeof(WeekView), new PropertyMetadata(null)); + public static readonly DependencyProperty DateFromProperty = DependencyProperty.Register("DateFrom", typeof(DateTime), typeof(WeekView), new PropertyMetadata(new DateTime(0), OnDateFromChanged)); + public static readonly DependencyProperty DateToProperty = DependencyProperty.Register("DateTo", typeof(DateTime), typeof(WeekView), new PropertyMetadata(new DateTime(0))); + public static readonly DependencyProperty DaysProperty = DependencyProperty.Register("Days", typeof(int), typeof(WeekView), new PropertyMetadata(5)); + public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(ObservableCollection), typeof(WeekView), new PropertyMetadata(null, OnAppointmentsChanged)); + public static readonly DependencyProperty WeekNameProperty = DependencyProperty.Register("WeekName", typeof(string), typeof(WeekView), new PropertyMetadata("T-Woche")); + public static readonly DependencyProperty WeekNumberProperty = DependencyProperty.Register("WeekNumber", typeof(int), typeof(WeekView), new PropertyMetadata(-1)); private List borderList = new List(); + private List dayList = new List(); private string[] timeStrings = new string[24]; private string[] monStrings = new string[24]; + public WeekView() { - this.Days = 5; - this.InitializeComponent(); this.InitLayout(); } + 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); + } + + 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)); + } + } + + 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; + } + } + + private void OnAppointmentListChanged(object s, NotifyCollectionChangedEventArgs e) + { + for(int i = 0; i < e.NewItems.Count; i++) + { + this.SeperateAppointments(e.NewItems[i] as AppointmentModel); + } + } + + private void SeperateAppointments(ObservableCollection list) + { + foreach (AppointmentModel m in list) + { + this.SeperateAppointments(m); + } + } + + private void SeperateAppointments(AppointmentModel model) + { + for(int i = 0; i < this.Days; i++) + { + if (model.IsDate(this.DateFrom.AddDays(i)) == 0) + { + this.dayList[i].Appointments.Add(model); + } + } + } + public DateTime DateFrom { get @@ -52,7 +113,19 @@ namespace CampusAppWP8.Utility.Lui.Templates set { this.SetValue(DateFromProperty, value); - this.SetValue(DateToProperty, value.AddDays(this.Days)); + } + } + + public DateTime DateTo + { + get + { + return (DateTime)this.GetValue(DateToProperty); + } + + set + { + this.SetValue(DateToProperty, value); } } @@ -69,11 +142,11 @@ namespace CampusAppWP8.Utility.Lui.Templates } } - public List Appointments + public ObservableCollection Appointments { get { - return (List)this.GetValue(AppointmentsProperty); + return (ObservableCollection)this.GetValue(AppointmentsProperty); } set @@ -92,6 +165,7 @@ namespace CampusAppWP8.Utility.Lui.Templates set { this.SetValue(WeekNameProperty, value); + } } @@ -130,6 +204,12 @@ namespace CampusAppWP8.Utility.Lui.Templates this.borderList.Add(this.ThuBorder); this.borderList.Add(this.FriBorder); + 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; } } diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml index e964d8ec..e466a31e 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml @@ -7,6 +7,7 @@ FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" + x:Name="root" > @@ -16,12 +17,16 @@ - - + + 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)); + public static readonly DependencyProperty DateProperty = DependencyProperty.Register("Date", typeof(DateTime), typeof(WeekViewDay), new PropertyMetadata(DateTime.Today)); + public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(ObservableCollection), typeof(WeekViewDay), new PropertyMetadata(null, OnAppointmentsChanged)); + + 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(); } + 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; + } + } + + private void OnAppointmentListChanged(object s, NotifyCollectionChangedEventArgs e) + { + if (e.Action == NotifyCollectionChangedAction.Add) + { + for (int i = 0; i < e.NewItems.Count; i++) + { + this.CheckForStack(e.NewItems[i] as AppointmentModel); + } + } + else if (e.Action == NotifyCollectionChangedAction.Remove) + { + throw new NotImplementedException(); + } + } + + public ObservableCollection Appointments + { + get + { + return (ObservableCollection)this.GetValue(AppointmentsProperty); + } + + set + { + this.SetValue(AppointmentsProperty, value); + } + } + + public DateTime Date + { + get + { + return (DateTime)this.GetValue(DateProperty); + } + + set + { + this.SetValue(DateProperty, value); + } + } + /// Gets or sets the background list elements. /// The background list elements. public int BgListElements @@ -75,6 +137,55 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + private void CheckForStack(AppointmentModel model) + { + int[] intersect = model.IntersectArray(this.Appointments.ToArray()); + + if (intersect.Count() == 0) + { + this.DrawApp(model); + } + else + { + + } + } + + private void DrawApp(AppointmentModel model, int stackIndex = -1) + { + AppointmentCanvas newCan = new AppointmentCanvas(model, this.Date); + + Binding widthBind = new Binding("ActualWidth"); + widthBind.ElementName = "MainCanvas"; + widthBind.Mode = BindingMode.OneWay; + newCan.SetBinding(WidthProperty, widthBind); + + if (stackIndex >= 0) + { + newCan.SetListPosition(this.stacks[stackIndex]); + } + + this.UserCanvas.Children.Add(newCan); + } + + 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); + } + } + /// Draw lines. /// Fiedler, 22.10.2013. private void DrawLines() From f1cf9cdefb0dce87e62e91a6ac3fdd4e3e561441 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Tue, 29 Oct 2013 19:09:22 +0100 Subject: [PATCH 04/22] daily commit --- .../Model/TimeTable/AppointmentModel.cs | 9 +- .../Pages/TimeTable/AppointmentEdit.xaml | 9 +- .../Pages/TimeTable/AppointmentEdit.xaml.cs | 3 +- .../CampusAppWP8/Pages/TimeTable/TimeTable.cs | 2 +- .../Pages/TimeTable/TimeTableWeek.xaml | 2 +- .../Pages/TimeTable/TimeTableWeek.xaml.cs | 55 ++---- .../Lui/Templates/AppointmentCanvas.xaml | 5 +- .../Lui/Templates/AppointmentCanvas.xaml.cs | 31 +++- .../Utility/Lui/Templates/WeekView.xaml | 22 +-- .../Utility/Lui/Templates/WeekView.xaml.cs | 32 +++- .../Utility/Lui/Templates/WeekViewDay.xaml.cs | 173 +++++++++++++++++- 11 files changed, 261 insertions(+), 82 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs index 918e2ebc..f205729f 100644 --- a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs @@ -206,8 +206,8 @@ namespace CampusAppWP8.Model.TimeTable return retValue; } -/* - private void OnCanvasClick(object sender, EventArgs e) + + public void OnCanvasClick(object sender, EventArgs e) { if (this.OnClick != null) { @@ -215,11 +215,6 @@ namespace CampusAppWP8.Model.TimeTable } } - private void OnCanvasSizeChanged(object sender, SizeChangedEventArgs e) - { - - } -*/ // ------------------------------------------------------ public string Title { 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..47452724 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs @@ -20,8 +20,9 @@ namespace CampusAppWP8.Pages.TimeTable 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 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" }; diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs index fffa353a..85ce3f26 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs @@ -24,7 +24,7 @@ namespace CampusAppWP8.Pages.TimeTable { private static AppointmentListModel appList //= null; = new AppointmentListModel(new AppointmentModel[] { - new AppointmentModel("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:ownCloud Calendar 0.6.3\r\nX-WR-CALNAME:Das is der Titel\r\nBEGIN:VEVENT\r\nCREATED;VALUE=DATE-TIME:20130827T113216Z\r\nUID:c9904ea73c\r\nLAST-MODIFIED;VALUE=DATE-TIME:20130827T113216Z\r\nDTSTAMP;VALUE=DATE-TIME:20130827T113216Z\r\nSUMMARY:Das is der Titel\r\nDTSTART;VALUE=DATE-TIME:20131022T113500Z\r\nDTEND;VALUE=DATE-TIME:20131022T212000Z\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: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:20131023T113500Z\r\nDTEND;VALUE=DATE-TIME:20131023T212000Z\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 welche einen etwas längeren titel enthält\r\nDESCRIPTION:Beschreibung des Termines\r\nCLASS:PUBLIC\r\nDTSTART:20131023T110000Z\r\nDTEND:20131024T113000Z\r\nDTSTAMP:20131003T125900Z\r\nPRIORITY:3\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:20131025T150000Z\r\nDTEND:20131025T170000Z\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"), diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml index c1e89fdd..caaf9438 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml @@ -18,7 +18,7 @@ - + diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs index 75e324ba..bf3825d3 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs @@ -28,16 +28,11 @@ namespace CampusAppWP8.Pages.TimeTable 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 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 int lastSelectedIndex = 0; private ObservableCollection itemList = new ObservableCollection(); @@ -230,9 +225,9 @@ namespace CampusAppWP8.Pages.TimeTable } } - 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.AppointmentsModel.Appointments.IndexOf(model); if (index >= 0) { @@ -315,19 +310,26 @@ 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.itemList[i].FromDT, 4) > -1) + if (this.itemList[i].AppointmentList.IndexOf(tempModel) >= 0) { - this.SetupPage(i); + tempModel.OnClick -= this.OnAppointmentClick; + this.itemList[i].AppointmentList.Remove(tempModel); } } } @@ -341,6 +343,7 @@ namespace CampusAppWP8.Pages.TimeTable { if (m.IsDate(this.itemList[i].FromDT, 4) >= 0) { + m.OnClick += this.OnAppointmentClick; this.itemList[i].AppointmentList.Add(m); } } @@ -620,27 +623,6 @@ namespace CampusAppWP8.Pages.TimeTable */ } - 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(); @@ -683,10 +665,5 @@ namespace CampusAppWP8.Pages.TimeTable // this.itemPages[index].Content.Children.Add(can); } - - private void ThePivot_LoadedPivotItem(object sender, PivotItemEventArgs e) - { - - } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml index 8608ffe9..f188b56c 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml @@ -13,9 +13,9 @@ SizeChanged="TheMainCanvas_SizeChanged"> @@ -23,6 +23,7 @@ FontSize="14" Padding="3" TextWrapping="Wrap" + Foreground="White" /> \ 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 index 12d870b2..577c0ad2 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml.cs @@ -25,6 +25,7 @@ namespace CampusAppWP8.Utility.Lui.Templates { private static readonly double HOURS_SPACING = 40; private static readonly double INDEX_SPACING = 10; + private static readonly int TOP_Z_INDEX = 10; private static readonly SolidColorBrush[] PRIO_COLORS = new SolidColorBrush[] { @@ -55,7 +56,9 @@ namespace CampusAppWP8.Utility.Lui.Templates { this.appPtr = model; - this.Height = model.GetTotalHours(day) * HOURS_SPACING; + double totalHours = model.GetTotalHours(day); + + this.Height = ((totalHours < 0.25) ? 0.25 : totalHours) * HOURS_SPACING; this.SetText(model.Title); this.SetValue(Canvas.TopProperty, (day.Date.Equals(model.Start.Date)) ? (model.Start.TimeOfDay.TotalHours * HOURS_SPACING) : 0); @@ -81,10 +84,16 @@ namespace CampusAppWP8.Utility.Lui.Templates this.Margin = new Thickness( (INDEX_SPACING * index), 0, - (INDEX_SPACING * count), + (INDEX_SPACING * (count - 1)), 0); - - if (index > 0) + + this.SetValue(Canvas.ZIndexProperty, ((TOP_Z_INDEX - index) < 0) ? 0 : (TOP_Z_INDEX - index)); + + if (index == 0) + { + this.Opacity = 1; + } + else { this.Opacity = 0.5; } @@ -111,7 +120,19 @@ namespace CampusAppWP8.Utility.Lui.Templates private void SetText(string text) { - this.TheText.Text = text; + if (this.Height < (HOURS_SPACING * 0.5)) + { + this.TheText.Text = "..."; + this.TheText.Margin = new Thickness( + 0, + this.Height - (HOURS_SPACING * 0.5), + 0, + 0); + } + else + { + this.TheText.Text = text; + } } private void SetBGColorByPriority(int prio) diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml index 87dab9c4..494fa87f 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml @@ -11,7 +11,7 @@ Foreground="{StaticResource PhoneForegroundBrush}" x:Name="root"> - + @@ -48,20 +48,20 @@ - - + + - + - + - + - + @@ -70,7 +70,7 @@ @@ -94,13 +94,13 @@ - + - - + + diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs index 27e76a26..b9b117da 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs @@ -78,9 +78,19 @@ namespace CampusAppWP8.Utility.Lui.Templates private void OnAppointmentListChanged(object s, NotifyCollectionChangedEventArgs e) { - for(int i = 0; i < e.NewItems.Count; i++) + if (e.Action == NotifyCollectionChangedAction.Add) { - this.SeperateAppointments(e.NewItems[i] as AppointmentModel); + 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); + } } } @@ -88,17 +98,24 @@ namespace CampusAppWP8.Utility.Lui.Templates { foreach (AppointmentModel m in list) { - this.SeperateAppointments(m); + this.SeperateAppointments(m, NotifyCollectionChangedAction.Add); } } - private void SeperateAppointments(AppointmentModel model) + private void SeperateAppointments(AppointmentModel model, NotifyCollectionChangedAction action) { for(int i = 0; i < this.Days; i++) { if (model.IsDate(this.DateFrom.AddDays(i)) == 0) { - this.dayList[i].Appointments.Add(model); + if (action == NotifyCollectionChangedAction.Add) + { + this.dayList[i].Appointments.Add(model); + } + else if (action == NotifyCollectionChangedAction.Remove) + { + this.dayList[i].Appointments.Remove(model); + } } } } @@ -212,5 +229,10 @@ namespace CampusAppWP8.Utility.Lui.Templates this.TimeList.ItemsSource = this.timeStrings; } + + private void AutoScroll(object sender, RoutedEventArgs e) + { + this.TheScrollView.ScrollToVerticalOffset((40 * 7) + 2); + } } } diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs index 55ea3131..4d67b4ce 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs @@ -62,12 +62,15 @@ namespace CampusAppWP8.Utility.Lui.Templates { for (int i = 0; i < e.NewItems.Count; i++) { - this.CheckForStack(e.NewItems[i] as AppointmentModel); + this.CheckStackAdd(e.NewItems[i] as AppointmentModel); } } else if (e.Action == NotifyCollectionChangedAction.Remove) { - throw new NotImplementedException(); + for (int i = 0; i < e.OldItems.Count; i++) + { + this.CheckStackRemove(e.OldItems[i] as AppointmentModel); + } } } @@ -137,32 +140,190 @@ namespace CampusAppWP8.Utility.Lui.Templates } } - private void CheckForStack(AppointmentModel model) + private void CheckStackAdd(AppointmentModel model) { int[] intersect = model.IntersectArray(this.Appointments.ToArray()); if (intersect.Count() == 0) { - this.DrawApp(model); + 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); + } + } + } + + 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); + } + } + + 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); + } + } + } + + private void ManipulateAppCanvas(AppointmentModel model, int stackIndex) + { + if (stackIndex < this.stacks.Count) + { + this.ManipulateAppCanvas(model, this.stacks[stackIndex]); + } + } + + private void ManipulateAppCanvas(AppointmentModel model, List list) + { + int index = list.IndexOf(model); + + if (index >= 0) + { + this.ManipulateAppCanvas(model, index, list.Count); + } + } + + 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); } } private void DrawApp(AppointmentModel model, int stackIndex = -1) + { + if (stackIndex >= 0) + { + this.DrawApp(model, this.stacks[stackIndex]); + } + else + { + this.DrawApp(model, null); + } + } + + 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("ActualWidth"); widthBind.ElementName = "MainCanvas"; widthBind.Mode = BindingMode.OneWay; newCan.SetBinding(WidthProperty, widthBind); - if (stackIndex >= 0) + if (stack != null) { - newCan.SetListPosition(this.stacks[stackIndex]); + newCan.SetListPosition(stack); } this.UserCanvas.Children.Add(newCan); From c225d3b9be1200f6a642545f6515fa4698d5caee Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Mon, 4 Nov 2013 19:14:32 +0100 Subject: [PATCH 05/22] daily commit --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 1 + .../Feed/TimeTable/AppointmentFeed.cs | 111 ++++++++++++++++ .../Model/TimeTable/AppointmentListModel.cs | 31 ++++- .../Model/TimeTable/AppointmentModel.cs | 14 ++- .../Pages/TimeTable/Appointment.xaml.cs | 14 +-- .../Pages/TimeTable/AppointmentEdit.xaml.cs | 8 +- .../CampusAppWP8/Pages/TimeTable/TimeTable.cs | 56 +++++++-- .../Pages/TimeTable/TimeTableDay.xaml.cs | 16 +-- .../TimeTable/TimeTableProperties.xaml.cs | 8 +- .../Pages/TimeTable/TimeTableWeek.xaml.cs | 54 +++++--- .../CampusAppWP8/Resources/Constants.resx | 3 + .../Resources/Constants1.Designer.cs | 9 ++ .../Lui/Templates/AppointmentCanvas.xaml.cs | 37 ++---- .../Utility/Lui/Templates/WeekView.xaml | 118 +++++++++--------- .../Utility/Lui/Templates/WeekView.xaml.cs | 3 +- .../Model/Departments/DepartmentModel.cs | 2 +- 16 files changed, 347 insertions(+), 138 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 2748d227..9be602ad 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -102,6 +102,7 @@ App.xaml + diff --git a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs new file mode 100644 index 00000000..e72ab883 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs @@ -0,0 +1,111 @@ + +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; + + public class AppointmentFeed : XmlModel + { + + 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(); + } + } + + private bool CheckIsModelUpToDate(AppointmentListModel model) + { + bool retValue = true; + + if (model == null) + { + retValue = false; + } + + return retValue; + } + + private bool CheckIsFileUpToDateOnLoad(AppointmentListModel model, FileInfo info) + { + bool retValue = true; + + return retValue; + } + + 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; + } + + 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.Length > 0) + { + appStr[i] = appStr[i].Replace("", string.Empty); + + AppointmentModel newAppModel = new AppointmentModel(appStr[i]); + + this.Model.Appointments.Add(newAppModel); + } + } + + return true; + } + + protected override byte[] SerializeModel() + { + List retValue = new List(); + + if (this.Model != null) + { + for (int i = 0; i < this.Model.Appointments.Count; i++) + { + retValue.AddRange(Encoding.UTF8.GetBytes("")); + retValue.AddRange(ICSManager.ExportToICSByte(this.Model.Appointments[i].CalendarObj)); + retValue.AddRange(Encoding.UTF8.GetBytes("")); + } + } + + return retValue.ToArray(); + } + } +} diff --git a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentListModel.cs b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentListModel.cs index 19feec4c..34db3d0d 100644 --- a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentListModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentListModel.cs @@ -24,17 +24,17 @@ namespace CampusAppWP8.Model.TimeTable /// /// Model for appointments. /// - [XmlRoot("root")] public class AppointmentListModel { private ObservableCollection appointmentList; private int hasChangedIndex = -1; + private bool hasChanged = false; /// Initializes a new instance of the class. public AppointmentListModel() { this.appointmentList = new ObservableCollection(); - this.appointmentList.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnCollectionChanged); + this.appointmentList.CollectionChanged += this.OnCollectionChanged; } // for testing @@ -50,7 +50,6 @@ namespace CampusAppWP8.Model.TimeTable } } - public ObservableCollection Appointments { get @@ -60,7 +59,17 @@ namespace CampusAppWP8.Model.TimeTable set { + if(this.appointmentList != null) + { + this.appointmentList.CollectionChanged -= this.OnCollectionChanged; + } + this.appointmentList = value; + + if(this.appointmentList != null) + { + this.appointmentList.CollectionChanged += this.OnCollectionChanged; + } } } @@ -74,12 +83,28 @@ namespace CampusAppWP8.Model.TimeTable } } + public bool HasChanged(bool reset = false) + { + bool retValue = false; + + retValue = this.hasChanged; + + if(reset == true) + { + this.hasChanged = false; + } + + return retValue; + } + private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) { this.hasChangedIndex = e.NewStartingIndex; } + + this.hasChanged = true; } } } diff --git a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs index f205729f..3ca3ad88 100644 --- a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs @@ -22,7 +22,6 @@ namespace CampusAppWP8.Model.TimeTable /// /// Model for appointments. /// - [XmlRoot("root")] public class AppointmentModel { private ICalObject icalObj = null; @@ -52,6 +51,19 @@ namespace CampusAppWP8.Model.TimeTable this.icalObj = ICSManager.ImportFromICS(icsData); } + public ICalObject CalendarObj + { + get + { + return this.icalObj; + } + + set + { + this.icalObj = value; + } + } + public int IsDate(DateTime date, int daySpan = 0) { int retValue = -1; 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.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs index 47452724..ec213f5b 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs @@ -68,11 +68,11 @@ namespace CampusAppWP8.Pages.TimeTable 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; @@ -230,10 +230,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/TimeTable.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs index 85ce3f26..977bd6c2 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs @@ -12,6 +12,7 @@ namespace CampusAppWP8.Pages.TimeTable using System.Linq; using System.Net; using System.Windows; + using System.Windows.Media; using System.Windows.Controls; using System.Windows.Navigation; using Microsoft.Phone.Controls; @@ -19,6 +20,7 @@ namespace CampusAppWP8.Pages.TimeTable using CampusAppWP8.Resources; using CampusAppWP8.Utility; using CampusAppWP8.Model.TimeTable; + using CampusAppWP8.Feed.TimeTable; public partial class TimeTable : PhoneApplicationPage { @@ -32,21 +34,57 @@ namespace CampusAppWP8.Pages.TimeTable 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") }); - public static int AutoScrollToHour = 7; - public static int VisualScale = 0; //0 - small, 1 - medium, 2 - large + public static int Setting_AutoScrollToHour = 7; + public static int Setting_VisualScale = 0; //0 - small, 1 - medium, 2 - large UNUSED ATM + public static double Setting_Hour_Spacing = 40; + public static double Setting_View_Height = Setting_Hour_Spacing * 24; + public static int Setting_Max_Z_Index = 10; + public static double Setting_Z_Spacing = 10; + 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 TimeTable() - { - //this.InitializeComponent(); - TimeTable.appList = new AppointmentListModel(); - } + private static AppointmentFeed feed = null; - public static AppointmentListModel AppointmentsModel + public static AppointmentFeed Feed { get { - return TimeTable.appList; + if (TimeTable.feed == null) + { + throw new NullReferenceException(); + } + + return TimeTable.feed; + } + } + + public static void InitFeed() + { + if(TimeTable.feed == null) + { + TimeTable.feed = new AppointmentFeed(false); + TimeTable.feed.OnFailedFile += new CampusAppWPortalLib8.Model.AbstractMainModel.OnFailed(TimeTable.OnLoadFailed); + TimeTable.feed.LoadData(); + } + } + + private static void OnLoadFailed() + { + if (TimeTable.feed.Model == null) + { + TimeTable.feed.Model = new AppointmentListModel(); } } } diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs index 43226ae6..c6db0614 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs @@ -92,7 +92,7 @@ namespace CampusAppWP8.Pages.TimeTable if (e.NavigationMode == NavigationMode.Back) { - TimeTable.AppointmentsModel.Appointments.CollectionChanged -= this.OnListChanged; + TimeTable.Feed.Model.Appointments.CollectionChanged -= this.OnListChanged; } else { @@ -136,11 +136,11 @@ namespace CampusAppWP8.Pages.TimeTable 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((sender as Canvas).Tag as AppointmentModel); if (index >= 0) { - TimeTable.AppointmentsModel.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged); + TimeTable.Feed.Model.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged); string urlString = "/Pages/TimeTable/Appointment.xaml?" + Constants.Param_Appointment_Index + "=" + index; @@ -190,7 +190,7 @@ namespace CampusAppWP8.Pages.TimeTable { if ((sender as ScrollViewer).VerticalOffset == 0.0) { - (sender as ScrollViewer).ScrollToVerticalOffset(DAY_TABLE_CELL_HEIGHT * TimeTable.AutoScrollToHour); + (sender as ScrollViewer).ScrollToVerticalOffset(DAY_TABLE_CELL_HEIGHT * TimeTable.Setting_AutoScrollToHour); } } @@ -223,7 +223,7 @@ namespace CampusAppWP8.Pages.TimeTable private void OnClickAdd(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("/Pages/TimeTable/AppointmentEdit.xaml", UriKind.Relative); Page page = App.RootFrame.Content as Page; @@ -306,13 +306,13 @@ namespace CampusAppWP8.Pages.TimeTable this.itemPages[index].Stacks.Clear(); this.itemPages[index].Content.Children.Clear(); - for (int i = 0; i < TimeTable.AppointmentsModel.Appointments.Count(); i++) + for (int i = 0; i < TimeTable.Feed.Model.Appointments.Count(); i++) { int appointmentIndex = -1; - if ((appointmentIndex = TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemPages[index].Date)) > -1) + if ((appointmentIndex = TimeTable.Feed.Model.Appointments[i].IsDate(this.itemPages[index].Date)) > -1) { - tempList.Add(TimeTable.AppointmentsModel.Appointments[i]); + tempList.Add(TimeTable.Feed.Model.Appointments[i]); } } // ------------------------------------------------------------- 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.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs index bf3825d3..993ca036 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs @@ -41,6 +41,8 @@ namespace CampusAppWP8.Pages.TimeTable { this.InitializeComponent(); + TimeTable.InitFeed(); + DateTime firstDay = this.GetFirstDayOfWeek(DateTime.Now).AddDays(-7 * PIVOT_PAGES_HALF_DOWN); for (int i = 0; i < PIVOT_PAGES; i++) @@ -86,7 +88,7 @@ namespace CampusAppWP8.Pages.TimeTable if (e.NavigationMode == NavigationMode.Back) { - TimeTable.AppointmentsModel.Appointments.CollectionChanged -= this.OnListChanged; + TimeTable.Feed.Model.Appointments.CollectionChanged -= this.OnListChanged; } else { @@ -98,6 +100,13 @@ namespace CampusAppWP8.Pages.TimeTable } } + protected override void OnNavigatedFrom(NavigationEventArgs e) + { + base.OnNavigatedFrom(e); + + TimeTable.Feed.SaveData(); + } + private DateTime GetFirstDayOfWeek(DateTime dayInWeek) { DateTime retValue = dayInWeek.Date; @@ -146,7 +155,7 @@ namespace CampusAppWP8.Pages.TimeTable page.NavigationService.Navigate(url); */ // this.itemPages[this.ThePivot.SelectedIndex].weekView.SetColumnBackground(0, new SolidColorBrush(Colors.Red)); - (this.ThePivot.SelectedItem as WeekViewPageItem).AppointmentList.Add(TimeTable.AppointmentsModel.Appointments[1]); + (this.ThePivot.SelectedItem as WeekViewPageItem).AppointmentList.Add(TimeTable.Feed.Model.Appointments[1]); } private void OnClickToday(object sender, EventArgs e) @@ -179,7 +188,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; @@ -216,7 +225,7 @@ namespace CampusAppWP8.Pages.TimeTable this.lastSelectedIndex = this.ThePivot.SelectedIndex; } - +/* private void OnAutoScroll(object sender, RoutedEventArgs e) { if ((sender as ScrollViewer).VerticalOffset == 0.0) @@ -224,14 +233,14 @@ namespace CampusAppWP8.Pages.TimeTable (sender as ScrollViewer).ScrollToVerticalOffset(WEEK_TABLE_CELL_HEIGHT * TimeTable.AutoScrollToHour); } } - +*/ private void OnAppointmentClick(AppointmentModel model) { - int index = TimeTable.AppointmentsModel.Appointments.IndexOf(model); + 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; @@ -319,6 +328,8 @@ namespace CampusAppWP8.Pages.TimeTable this.itemList[i].AppointmentList.Add(tempModel); } } + + TimeTable.Feed.SaveData(true); } else if (e.Action == NotifyCollectionChangedAction.Remove) { @@ -337,14 +348,29 @@ namespace CampusAppWP8.Pages.TimeTable private void CheckAppointments() { - foreach (AppointmentModel m in TimeTable.AppointmentsModel.Appointments) + if (TimeTable.Feed == null) { + throw new NullReferenceException("feed == null"); + } + else if (TimeTable.Feed.Model == null) + { + throw new NullReferenceException("model == null"); + } + else if (TimeTable.Feed.Model.Appointments == null) + { + throw new NullReferenceException("Appointments == null"); + } + + for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++) + { + AppointmentModel temp = TimeTable.Feed.Model.Appointments[m]; + for (int i = 0; i < PIVOT_PAGES; i++) { - if (m.IsDate(this.itemList[i].FromDT, 4) >= 0) + if (temp.IsDate(this.itemList[i].FromDT, 4) >= 0) { - m.OnClick += this.OnAppointmentClick; - this.itemList[i].AppointmentList.Add(m); + temp.OnClick += this.OnAppointmentClick; + this.itemList[i].AppointmentList.Add(temp); } } } @@ -379,7 +405,7 @@ namespace CampusAppWP8.Pages.TimeTable tempList[i] = new List(); } */ - for (int i = 0; i < TimeTable.AppointmentsModel.Appointments.Count(); i++) + for (int i = 0; i < TimeTable.Feed.Model.Appointments.Count(); i++) { /* for (int k = 0; k < 5; k++) @@ -390,9 +416,9 @@ namespace CampusAppWP8.Pages.TimeTable } } */ - if (TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemList[index].FromDT.Date, 4) > -1) + if (TimeTable.Feed.Model.Appointments[i].IsDate(this.itemList[index].FromDT.Date, 4) > -1) { - tempList.Add(TimeTable.AppointmentsModel.Appointments[i]); + tempList.Add(TimeTable.Feed.Model.Appointments[i]); } } // ------------------------------------------------------- diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 1e7fbdef..7db93ad9 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -594,4 +594,7 @@ CurrentPositionPoint + + Appointments.xaml + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs index 4aec5b6e..7e7836cf 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. /// diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml.cs index 577c0ad2..6c897d5b 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/AppointmentCanvas.xaml.cs @@ -18,29 +18,12 @@ namespace CampusAppWP8.Utility.Lui.Templates 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 static readonly double HOURS_SPACING = 40; - private static readonly double INDEX_SPACING = 10; - private static readonly int TOP_Z_INDEX = 10; - - private static readonly SolidColorBrush[] PRIO_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) - }; - private AppointmentModel appPtr = null; public AppointmentCanvas() : base() @@ -58,9 +41,9 @@ namespace CampusAppWP8.Utility.Lui.Templates double totalHours = model.GetTotalHours(day); - this.Height = ((totalHours < 0.25) ? 0.25 : totalHours) * HOURS_SPACING; + 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 * HOURS_SPACING) : 0); + this.SetValue(Canvas.TopProperty, (day.Date.Equals(model.Start.Date)) ? (model.Start.TimeOfDay.TotalHours * TimeTable.Setting_Hour_Spacing) : 0); object tempProp = null; @@ -82,12 +65,12 @@ namespace CampusAppWP8.Utility.Lui.Templates public void SetListPosition(int index, int count) { this.Margin = new Thickness( - (INDEX_SPACING * index), + (TimeTable.Setting_Z_Spacing * index), 0, - (INDEX_SPACING * (count - 1)), + (TimeTable.Setting_Z_Spacing * (count - 1)), 0); - this.SetValue(Canvas.ZIndexProperty, ((TOP_Z_INDEX - index) < 0) ? 0 : (TOP_Z_INDEX - index)); + this.SetValue(Canvas.ZIndexProperty, ((TimeTable.Setting_Max_Z_Index - index) < 0) ? 0 : (TimeTable.Setting_Max_Z_Index - index)); if (index == 0) { @@ -120,12 +103,12 @@ namespace CampusAppWP8.Utility.Lui.Templates private void SetText(string text) { - if (this.Height < (HOURS_SPACING * 0.5)) + if (this.Height < (TimeTable.Setting_Hour_Spacing * 0.5)) { this.TheText.Text = "..."; this.TheText.Margin = new Thickness( 0, - this.Height - (HOURS_SPACING * 0.5), + this.Height - (TimeTable.Setting_Hour_Spacing * 0.5), 0, 0); } @@ -137,9 +120,9 @@ namespace CampusAppWP8.Utility.Lui.Templates private void SetBGColorByPriority(int prio) { - if (prio < PRIO_COLORS.Count() && prio >= 0) + if (prio < TimeTable.Setting_Priority_Colors.Count() && prio >= 0) { - this.TheRect.Fill = PRIO_COLORS[prio]; + 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 494fa87f..3b9c5896 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml @@ -67,66 +67,66 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 b9b117da..3c7cb3f2 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs @@ -20,6 +20,7 @@ namespace CampusAppWP8.Utility.Lui.Templates using Microsoft.Phone.Controls; using Microsoft.Phone.Shell; using CampusAppWP8.Model.TimeTable; + using CampusAppWP8.Pages.TimeTable; public partial class WeekView : UserControl @@ -232,7 +233,7 @@ namespace CampusAppWP8.Utility.Lui.Templates private void AutoScroll(object sender, RoutedEventArgs e) { - this.TheScrollView.ScrollToVerticalOffset((40 * 7) + 2); + this.TheScrollView.ScrollToVerticalOffset((TimeTable.Setting_Hour_Spacing * 7) + 2); } } } 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; } From 1e7d9767ec37a572ff975b4b5f5cf277f9cdf69b Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Tue, 5 Nov 2013 19:13:42 +0100 Subject: [PATCH 06/22] daily --- .../Feed/TimeTable/AppointmentFeed.cs | 2 +- .../CampusAppWP8/Pages/TimeTable/TimeTable.cs | 10 --- .../Pages/TimeTable/TimeTableWeek.xaml.cs | 20 ++---- .../CampusAppWP8/Utility/ICSClasses.cs | 10 +-- .../CampusAppWP8/Utility/ICSManager.cs | 69 ++++++++++--------- .../Utility/ICSProperties/AccessClass.cs | 5 +- .../Utility/ICSProperties/Action.cs | 3 +- .../Utility/ICSProperties/Attachment.cs | 3 +- .../Utility/ICSProperties/Attendee.cs | 7 +- .../Utility/ICSProperties/Begin.cs | 3 +- .../Utility/ICSProperties/CalendarScale.cs | 3 +- .../Utility/ICSProperties/Categories.cs | 3 +- .../Utility/ICSProperties/Comment.cs | 3 +- .../Utility/ICSProperties/Contact.cs | 1 + .../Utility/ICSProperties/DTCompleted.cs | 7 +- .../Utility/ICSProperties/DTCreated.cs | 7 +- .../Utility/ICSProperties/DTDue.cs | 1 + .../Utility/ICSProperties/DTEnd.cs | 9 +-- .../Utility/ICSProperties/DTException.cs | 1 + .../Utility/ICSProperties/DTRecurrence.cs | 7 +- .../Utility/ICSProperties/DTStamp.cs | 1 + .../Utility/ICSProperties/DTStart.cs | 1 + .../Utility/ICSProperties/Description.cs | 1 + .../Utility/ICSProperties/Duration.cs | 5 +- .../CampusAppWP8/Utility/ICSProperties/End.cs | 1 + .../Utility/ICSProperties/FreeBusyTime.cs | 5 +- .../CampusAppWP8/Utility/ICSProperties/Geo.cs | 9 +-- .../Utility/ICSProperties/LastModified.cs | 1 + .../Utility/ICSProperties/Location.cs | 1 + .../Utility/ICSProperties/Method.cs | 3 +- .../Utility/ICSProperties/Organizer.cs | 1 + .../Utility/ICSProperties/PercentComplete.cs | 11 +-- .../Utility/ICSProperties/Priority.cs | 13 ++-- .../Utility/ICSProperties/ProductID.cs | 3 +- .../Utility/ICSProperties/RecurrenceID.cs | 1 + .../Utility/ICSProperties/RecurrenceRule.cs | 3 +- .../Utility/ICSProperties/RelatedTo.cs | 7 +- .../Utility/ICSProperties/RepeatCount.cs | 3 +- .../Utility/ICSProperties/RequestStatus.cs | 3 +- .../Utility/ICSProperties/Resources.cs | 1 + .../Utility/ICSProperties/SequenceNumber.cs | 1 + .../Utility/ICSProperties/Status.cs | 11 +-- .../Utility/ICSProperties/Summary.cs | 1 + .../Utility/ICSProperties/TimeTransparency.cs | 5 +- .../ICSProperties/TimeZoneIdentifier.cs | 5 +- .../Utility/ICSProperties/TimeZoneName.cs | 5 +- .../ICSProperties/TimeZoneOffsetFrom.cs | 5 +- .../Utility/ICSProperties/TimeZoneOffsetTo.cs | 1 + .../Utility/ICSProperties/TimeZoneUrl.cs | 5 +- .../Utility/ICSProperties/Trigger.cs | 3 +- .../Utility/ICSProperties/UniqueID.cs | 1 + .../CampusAppWP8/Utility/ICSProperties/Url.cs | 1 + .../Utility/ICSProperties/Version.cs | 3 +- 53 files changed, 164 insertions(+), 131 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs index e72ab883..9f166c89 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs @@ -78,7 +78,7 @@ namespace CampusAppWP8.Feed.TimeTable for (int i = 0; i < appStr.Length; i++) { - if (appStr.Length > 0) + if (appStr[i].Length > 0) { appStr[i] = appStr[i].Replace("", string.Empty); diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs index 977bd6c2..5d23d8e8 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs @@ -24,16 +24,6 @@ namespace CampusAppWP8.Pages.TimeTable 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:20131023T113500Z\r\nDTEND;VALUE=DATE-TIME:20131023T212000Z\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 welche einen etwas längeren titel enthält\r\nDESCRIPTION:Beschreibung des Termines\r\nCLASS:PUBLIC\r\nDTSTART:20131023T110000Z\r\nDTEND:20131024T113000Z\r\nDTSTAMP:20131003T125900Z\r\nPRIORITY:3\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:20131025T150000Z\r\nDTEND:20131025T170000Z\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") - }); - public static int Setting_AutoScrollToHour = 7; public static int Setting_VisualScale = 0; //0 - small, 1 - medium, 2 - large UNUSED ATM public static double Setting_Hour_Spacing = 40; diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs index 993ca036..2d4a0c76 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs @@ -149,34 +149,26 @@ 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)); - (this.ThePivot.SelectedItem as WeekViewPageItem).AppointmentList.Add(TimeTable.Feed.Model.Appointments[1]); } 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; for (int i = 0; i < PIVOT_PAGES; i++) { - this.itemPages[i].DateFrom = firstDay; - this.itemPages[i].DateTo = this.itemPages[i].DateFrom.AddDays(6); - this.itemPages[i].WeekNumber = this.GetWeekNumber(this.itemPages[i].DateFrom); - this.itemPages[i].WeekChar = ((this.itemPages[i].WeekNumber % 2) == 0) ? 'B' : 'A'; + this.itemList[i].FromDT = firstDay; + this.itemList[i].ToDT = this.itemList[i].FromDT.AddDays(6); + this.itemList[i].WeekNr = this.GetWeekNumber(this.itemList[i].FromDT); + this.itemList[i].WeekStr = ((this.itemList[i].WeekNr % 2) == 0) ? "B" : "A"; firstDay = firstDay.AddDays(7); - - this.SetupPage(i); } - */ - //this.itemPages[this.ThePivot.SelectedIndex].weekView.SetColumnBackground(0); + //maybe FIXME } private void OnClickProperties(object sender, EventArgs e) @@ -328,8 +320,6 @@ namespace CampusAppWP8.Pages.TimeTable this.itemList[i].AppointmentList.Add(tempModel); } } - - TimeTable.Feed.SaveData(true); } else if (e.Action == NotifyCollectionChangedAction.Remove) { 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) { From 4425a4f5626809ecd1bed4c4b182492d50e06238 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Wed, 6 Nov 2013 16:55:39 +0100 Subject: [PATCH 07/22] TimeTableWeek done --- .../Feed/TimeTable/AppointmentFeed.cs | 38 +- .../Model/TimeTable/AppointmentModel.cs | 83 +++- .../CampusAppWP8/Pages/TimeTable/TimeTable.cs | 28 +- .../Pages/TimeTable/TimeTableWeek.xaml.cs | 383 +++--------------- .../Pages/TimeTable/WeekViewPageItem.cs | 57 ++- .../Utility/Lui/Templates/WeekView.xaml.cs | 96 ++++- .../Utility/Lui/Templates/WeekViewDay.xaml.cs | 67 ++- 7 files changed, 386 insertions(+), 366 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs index 9f166c89..2131a7d8 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs @@ -1,7 +1,13 @@ - +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 06.11.2013 +// Implements the appointment feed class +//----------------------------------------------------------------------- namespace CampusAppWP8.Feed.TimeTable { - using System; using System.Collections.Generic; using System.IO; using System.Text; @@ -12,9 +18,14 @@ namespace CampusAppWP8.Feed.TimeTable using CampusAppWP8.Model.TimeTable; using CampusAppWPortalLib8.Model; + /// An appointment feed. + /// Fiedler, 06.11.2013. + /// public class AppointmentFeed : XmlModel { - + /// Initializes a new instance of the AppointmentFeed class. + /// Fiedler, 06.11.2013. + /// (Optional) the automatic load. public AppointmentFeed(bool autoLoad = true) : base(ModelType.File, Constants.FileAppointments_Name) { @@ -28,6 +39,10 @@ namespace CampusAppWP8.Feed.TimeTable } } + /// Check is model up to date. + /// Fiedler, 06.11.2013. + /// The model. + /// true if it succeeds, false if it fails. private bool CheckIsModelUpToDate(AppointmentListModel model) { bool retValue = true; @@ -40,6 +55,11 @@ namespace CampusAppWP8.Feed.TimeTable return retValue; } + /// Check is file up to date on load. + /// Fiedler, 06.11.2013. + /// The model. + /// The information. + /// true if it succeeds, false if it fails. private bool CheckIsFileUpToDateOnLoad(AppointmentListModel model, FileInfo info) { bool retValue = true; @@ -47,6 +67,11 @@ namespace CampusAppWP8.Feed.TimeTable return retValue; } + /// Check is file up to date on save. + /// Fiedler, 06.11.2013. + /// The model. + /// The information. + /// true if it succeeds, false if it fails. private bool CheckIsFileUpToDateOnSave(AppointmentListModel model, FileInfo info) { bool retValue = true; @@ -66,6 +91,10 @@ namespace CampusAppWP8.Feed.TimeTable return retValue; } + /// Deserialize model. + /// Fiedler, 06.11.2013. + /// Information describing the model. + /// true if it succeeds, false if it fails. protected override bool DeserializeModel(byte[] modelData) { if (this.Model == null) @@ -91,6 +120,9 @@ namespace CampusAppWP8.Feed.TimeTable return true; } + /// Gets the serialize model. + /// Fiedler, 06.11.2013. + /// A byte[]. protected override byte[] SerializeModel() { List retValue = new List(); diff --git a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs index 3ca3ad88..bc731c58 100644 --- a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs @@ -10,26 +10,25 @@ namespace CampusAppWP8.Model.TimeTable { using System; using System.Collections.Generic; - using System.Text.RegularExpressions; - using System.Windows.Shapes; - using System.Xml.Serialization; - using System.Windows.Controls; - using System.Windows.Media; - using System.Windows; using CampusAppWP8.Utility; using CampusAppWP8.Utility.ICSProperties; - /// - /// Model for appointments. - /// + /// Model for appointments. + /// Fiedler, 06.11.2013. public class AppointmentModel { + /// The ical object. private ICalObject icalObj = null; - + + /// Executes the appointment click action. + /// Fiedler, 06.11.2013. + /// The sender. public delegate void OnAppointmentClick(AppointmentModel sender); + /// Occurs when On Click. public event OnAppointmentClick OnClick = null; - - /// Initializes a new instance of the class. + + /// Initializes a new instance of the class. + /// Fiedler, 06.11.2013. public AppointmentModel() { this.icalObj = new ICalObject(); @@ -46,11 +45,16 @@ namespace CampusAppWP8.Model.TimeTable this.icalObj.AddProperty(newProdID); } + /// Initializes a new instance of the AppointmentModel class. + /// Fiedler, 06.11.2013. + /// Information describing the ics. public AppointmentModel(string icsData) : this() { this.icalObj = ICSManager.ImportFromICS(icsData); } + /// Gets or sets the calendar object. + /// The calendar object. public ICalObject CalendarObj { get @@ -64,6 +68,11 @@ namespace CampusAppWP8.Model.TimeTable } } + /// Is date. + /// Fiedler, 06.11.2013. + /// The date Date/Time. + /// (Optional) the day span. + /// An int. public int IsDate(DateTime date, int daySpan = 0) { int retValue = -1; @@ -92,6 +101,10 @@ namespace CampusAppWP8.Model.TimeTable return retValue; } + /// Intersects the given model. + /// Fiedler, 06.11.2013. + /// The model. + /// true if it succeeds, false if it fails. public bool Intersect(AppointmentModel model) { bool retValue = false; @@ -112,6 +125,10 @@ namespace CampusAppWP8.Model.TimeTable return retValue; } + /// Intersects the given model. + /// Fiedler, 06.11.2013. + /// List of models. + /// true if it succeeds, false if it fails. public int Intersect(AppointmentModel[] modelList) { int retValue = -1; @@ -127,6 +144,10 @@ namespace CampusAppWP8.Model.TimeTable return retValue; } + /// Intersect array. + /// Fiedler, 06.11.2013. + /// List of models. + /// An int[]. public int[] IntersectArray(AppointmentModel[] modelList) { List retValue = new List(); @@ -142,6 +163,9 @@ namespace CampusAppWP8.Model.TimeTable return retValue.ToArray(); } + /// Sets a value. + /// Fiedler, 06.11.2013. + /// The value. public void SetValue(object value) { ICalObject vevent = this.GetVEventObj(true); @@ -149,6 +173,10 @@ namespace CampusAppWP8.Model.TimeTable vevent.AddProperty(value); } + /// Gets a value. + /// Fiedler, 06.11.2013. + /// Name of the property. + /// The value. public object GetValue(string propertyName) { object retValue = this.GetVEventObj().GetProperty(propertyName); @@ -156,11 +184,18 @@ namespace CampusAppWP8.Model.TimeTable return retValue; } + /// Gets total hours. + /// Fiedler, 06.11.2013. + /// The total hours. public double GetTotalHours() { return this.End.Subtract(this.Start).TotalHours; } + /// Gets total hours. + /// Fiedler, 06.11.2013. + /// The date Date/Time. + /// The total hours. public double GetTotalHours(DateTime date) { double retValue = 0; @@ -195,6 +230,13 @@ namespace CampusAppWP8.Model.TimeTable return retValue; } + /// Gets v event object. + /// Fiedler, 06.11.2013. + /// + /// Thrown when a value was unexpectedly null. + /// + /// (Optional) the create. + /// The v event object. private ICalObject GetVEventObj(bool create = false) { ICalObject retValue = this.icalObj.GetProperty(ICSTag.VEVENT) as ICalObject; @@ -219,6 +261,10 @@ namespace CampusAppWP8.Model.TimeTable return retValue; } + /// Raises the canvas click event. + /// Fiedler, 06.11.2013. + /// Source of the event. + /// Event information to send to registered event handlers. public void OnCanvasClick(object sender, EventArgs e) { if (this.OnClick != null) @@ -228,6 +274,9 @@ namespace CampusAppWP8.Model.TimeTable } // ------------------------------------------------------ + + /// Gets the title. + /// The title. public string Title { get @@ -239,6 +288,8 @@ namespace CampusAppWP8.Model.TimeTable } } + /// Gets the date. + /// The date. public string Date { get @@ -265,6 +316,8 @@ namespace CampusAppWP8.Model.TimeTable } } + /// Gets the location. + /// The location. public string Location { get @@ -283,6 +336,8 @@ namespace CampusAppWP8.Model.TimeTable } } + /// Gets the description. + /// The description. public string Description { get @@ -301,6 +356,8 @@ namespace CampusAppWP8.Model.TimeTable } } + /// Gets the Date/Time of the start. + /// The start. public DateTime Start { get @@ -317,6 +374,8 @@ namespace CampusAppWP8.Model.TimeTable } } + /// Gets the Date/Time of the end. + /// The end. public DateTime End { get diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs index 5d23d8e8..526ef841 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs @@ -8,28 +8,29 @@ namespace CampusAppWP8.Pages.TimeTable { using System; - using System.Collections.Generic; - using System.Linq; - using System.Net; - using System.Windows; using System.Windows.Media; - using System.Windows.Controls; - using System.Windows.Navigation; using Microsoft.Phone.Controls; - using Microsoft.Phone.Shell; - using CampusAppWP8.Resources; - using CampusAppWP8.Utility; using CampusAppWP8.Model.TimeTable; using CampusAppWP8.Feed.TimeTable; + /// A time table. + /// Fiedler, 06.11.2013. + /// public partial class TimeTable : PhoneApplicationPage { + /// The setting automatic scroll to hour. public static int Setting_AutoScrollToHour = 7; - public static int Setting_VisualScale = 0; //0 - small, 1 - medium, 2 - large UNUSED ATM + /// 0 - small, 1 - medium, 2 - large UNUSED ATM. + public static int Setting_VisualScale = 0; + /// The setting hour spacing. public static double Setting_Hour_Spacing = 40; + /// Height of the setting view. public static double Setting_View_Height = Setting_Hour_Spacing * 24; + /// Zero-based index of the setting maximum z coordinate. public static int Setting_Max_Z_Index = 10; + /// The setting z coordinate spacing. public static double Setting_Z_Spacing = 10; + /// List of colors of the setting priorities. public static SolidColorBrush[] Setting_Priority_Colors = new SolidColorBrush[] { new SolidColorBrush(Colors.Green), @@ -45,8 +46,11 @@ namespace CampusAppWP8.Pages.TimeTable }; + /// The feed. private static AppointmentFeed feed = null; + /// Gets the feed. + /// The feed. public static AppointmentFeed Feed { get @@ -60,6 +64,8 @@ namespace CampusAppWP8.Pages.TimeTable } } + /// Initialises the feed. + /// Fiedler, 06.11.2013. public static void InitFeed() { if(TimeTable.feed == null) @@ -70,6 +76,8 @@ namespace CampusAppWP8.Pages.TimeTable } } + /// Executes the load failed action. + /// Fiedler, 06.11.2013. private static void OnLoadFailed() { if (TimeTable.feed.Model == null) diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs index 2d4a0c76..8f9aa30e 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs @@ -8,10 +8,8 @@ namespace CampusAppWP8.Pages.TimeTable { using System; - using System.Collections.Generic; using System.Collections.Specialized; using System.Collections.ObjectModel; - using System.Linq; using System.Windows; using System.Windows.Controls; using System.Windows.Media; @@ -21,9 +19,6 @@ namespace CampusAppWP8.Pages.TimeTable using Microsoft.Phone.Shell; using CampusAppWP8.Model.TimeTable; using CampusAppWP8.Resources; - using CampusAppWP8.Utility.Lui.Templates; - using CampusAppWP8.Utility.Lui.Header; - using System.Windows.Data; public partial class TimeTableWeek : PhoneApplicationPage { @@ -156,19 +151,39 @@ namespace CampusAppWP8.Pages.TimeTable private void OnClickToday(object sender, EventArgs e) { - DateTime firstDay = this.GetFirstDayOfWeek(DateTime.Now).AddDays(-7 * PIVOT_PAGES_HALF_DOWN); - this.ThePivot.SelectedIndex = PIVOT_PAGES_HALF_DOWN; + DateTime firstDay = this.GetFirstDayOfWeek(DateTime.Now); + int testIndex = -1; - for (int i = 0; i < PIVOT_PAGES; i++) + for (int i = 0; i < this.itemList.Count; i++) { - this.itemList[i].FromDT = firstDay; - this.itemList[i].ToDT = this.itemList[i].FromDT.AddDays(6); - this.itemList[i].WeekNr = this.GetWeekNumber(this.itemList[i].FromDT); - this.itemList[i].WeekStr = ((this.itemList[i].WeekNr % 2) == 0) ? "B" : "A"; - - firstDay = firstDay.AddDays(7); + if (this.itemList[i].FromDT.Equals(firstDay) == true) + { + testIndex = i; + } + } + + if (testIndex < 0) + { + this.ThePivot.SelectedIndex = PIVOT_PAGES_HALF_DOWN; + firstDay = firstDay.AddDays(-7 * PIVOT_PAGES_HALF_DOWN); + + for (int i = 0; i < PIVOT_PAGES; i++) + { + this.itemList[i].FromDT = firstDay; + this.itemList[i].ToDT = this.itemList[i].FromDT.AddDays(6); + this.itemList[i].WeekNr = this.GetWeekNumber(this.itemList[i].FromDT); + this.itemList[i].WeekStr = ((this.itemList[i].WeekNr % 2) != 0) ? "A" : "B"; + this.itemList[i].AppointmentList.Clear(); + + this.CheckAppointments(i); + + firstDay = firstDay.AddDays(7); + } + } + else + { + this.ThePivot.SelectedIndex = testIndex; } - //maybe FIXME } private void OnClickProperties(object sender, EventArgs e) @@ -190,7 +205,7 @@ namespace CampusAppWP8.Pages.TimeTable private void OnPivotSelectionChanged(object sender, SelectionChangedEventArgs e) { int delta = this.ThePivot.SelectedIndex - this.lastSelectedIndex; - /* + if (delta < -1) delta = 1; else if (delta > 1) delta = -1; @@ -200,32 +215,19 @@ namespace CampusAppWP8.Pages.TimeTable { return; } - else - { - this.itemList[index].FromDT = this.itemList[this.ThePivot.SelectedIndex].FromDT.AddDays((7 * delta)); - this.itemList[index].ToDT = this.itemList[this.ThePivot.SelectedIndex].ToDT.AddDays((7 * delta)); - } - */ - //this.itemPages[index].Content.Children.Clear(); -// this.itemPages[index].WeekNumber = System.Globalization.DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear( -// this.itemPages[index].DateFrom, -// System.Globalization.CalendarWeekRule.FirstDay, -// DayOfWeek.Monday); -// this.itemPages[index].WeekChar = ((this.itemPages[index].WeekNumber % 2) == 0) ? 'B' : 'A'; + + this.itemList[index].FromDT = this.itemList[this.ThePivot.SelectedIndex].FromDT.AddDays((7 * delta)); + this.itemList[index].ToDT = this.itemList[this.ThePivot.SelectedIndex].ToDT.AddDays((7 * delta)); + this.itemList[index].WeekNr = this.GetWeekNumber(this.itemList[index].FromDT); + this.itemList[index].WeekStr = ((this.itemList[index].WeekNr % 2) != 0) ? "A" : "B"; - //this.SetupPage(index); + this.itemList[index].AppointmentList.Clear(); + + this.CheckAppointments(index); this.lastSelectedIndex = this.ThePivot.SelectedIndex; } -/* - private void OnAutoScroll(object sender, RoutedEventArgs e) - { - if ((sender as ScrollViewer).VerticalOffset == 0.0) - { - (sender as ScrollViewer).ScrollToVerticalOffset(WEEK_TABLE_CELL_HEIGHT * TimeTable.AutoScrollToHour); - } - } -*/ + private void OnAppointmentClick(AppointmentModel model) { int index = TimeTable.Feed.Model.Appointments.IndexOf(model); @@ -302,7 +304,7 @@ namespace CampusAppWP8.Pages.TimeTable } } */ -} + } private void OnListChanged(object sender, NotifyCollectionChangedEventArgs e) { @@ -336,7 +338,7 @@ namespace CampusAppWP8.Pages.TimeTable } } - private void CheckAppointments() + private void CheckAppointments(int pageIndex = -1) { if (TimeTable.Feed == null) { @@ -351,294 +353,37 @@ namespace CampusAppWP8.Pages.TimeTable throw new NullReferenceException("Appointments == null"); } - for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++) + if (pageIndex < 0) { - AppointmentModel temp = TimeTable.Feed.Model.Appointments[m]; - - for (int i = 0; i < PIVOT_PAGES; i++) + for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++) { - if (temp.IsDate(this.itemList[i].FromDT, 4) >= 0) + AppointmentModel temp = TimeTable.Feed.Model.Appointments[m]; + + for (int i = 0; i < PIVOT_PAGES; i++) + { + if (temp.IsDate(this.itemList[i].FromDT, 4) >= 0) + { + temp.OnClick += this.OnAppointmentClick; + this.itemList[i].AppointmentList.Add(temp); + } + } + } + } + else + { + for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++) + { + AppointmentModel temp = TimeTable.Feed.Model.Appointments[m]; + + if (temp.IsDate(this.itemList[pageIndex].FromDT, 4) >= 0) { temp.OnClick += this.OnAppointmentClick; - this.itemList[i].AppointmentList.Add(temp); + this.itemList[pageIndex].AppointmentList.Add(temp); } } } } - - private void SetupPage(int index) - { - // Header - - //((this.ThePivot.Items[index] as PivotItem).Header as Grid).Children.Clear(); - - //this.DrawHeader(index); - - // Items - -// List[] tempList = new List[5]; - List tempList = new List(); - - /* - for(int i = 0; i < 5; i++) - { - this.itemPages[index].Stacks[i].Clear(); - } - /**/ -// this.itemPages[index].Stacks.Clear(); - -// this.itemPages[index].Content.Children.Clear(); -/* - for(int i = 0; i < 5; i++) - { - tempList[i] = new List(); - } -*/ - for (int i = 0; i < TimeTable.Feed.Model.Appointments.Count(); i++) - { -/* - for (int k = 0; k < 5; k++) - { - if (TimeTable.AppointmentsModel.Appointments[i].IsDate(this.itemPages[index].DateFrom.Date.AddDays(k)) > -1) - { - tempList[k].Add(TimeTable.AppointmentsModel.Appointments[i]); - } - } -*/ - if (TimeTable.Feed.Model.Appointments[i].IsDate(this.itemList[index].FromDT.Date, 4) > -1) - { - tempList.Add(TimeTable.Feed.Model.Appointments[i]); - } - } - // ------------------------------------------------------- -/* - for (int i = 0; i < tempList.Count(); i++) - { - int[] intersectIndex = tempList[i].IntersectArray(tempList.ToArray()); - - if (intersectIndex.Count() == 0) - { - for (int day = 0; day < 5; day++) - { - if (tempList[i].IsDate(this.itemPages[index].DateFrom.Date.AddDays(day)) > -1) - { - this.DrawAppointment(tempList[i], index, day); - } - } - } - else if (intersectIndex.Count() == 1) - { - int addIndex = -1; - - for (int k = 0; k < this.itemPages[index].Stacks.Count(); k++) - { - //if (this.itemPages[index].Stacks[day][k].IndexOf(tempList[day][intersectIndex[0]]) > -1) - if(this.itemPages[index].Stacks[k].IndexOf(tempList[intersectIndex[0]]) > -1) - { - addIndex = k; - } - } - - if (addIndex >= 0) - { - //this.itemPages[index].Stacks[day][addIndex].Add(tempList[day][i]); - this.itemPages[index].Stacks[addIndex].Add(tempList[i]); - } - else - { - List newList = new List(); - //newList.Add(tempList[day][i]); - //this.itemPages[index].Stacks[day].Add(newList); - newList.Add(tempList[i]); - this.itemPages[index].Stacks.Add(newList); - } - } - else - { - List> intersectLists = new List>(); - - for (int k = 0; k < intersectIndex.Count(); k++) - { - //for (int m = 0; m < this.itemPages[index].Stacks[day].Count(); m++) - for(int m = 0; m < this.itemPages[index].Stacks.Count(); m++) - { - //if (this.itemPages[index].Stacks[day][m].IndexOf(tempList[day][intersectIndex[k]]) > -1) - if(this.itemPages[index].Stacks[m].IndexOf(tempList[intersectIndex[k]]) > -1) - { - //if (intersectLists.IndexOf(this.itemPages[index].Stacks[day][m]) < 0) - if(intersectLists.IndexOf(this.itemPages[index].Stacks[m]) < 0) - { - //intersectLists.Add(this.itemPages[index].Stacks[day][m]); - intersectLists.Add(this.itemPages[index].Stacks[m]); - } - } - } - } - - if (intersectLists.Count() == 0) - { - List newList = new List(); - //newList.Add(tempList[day][i]); - //this.itemPages[index].Stacks[day].Add(newList); - newList.Add(tempList[i]); - this.itemPages[index].Stacks.Add(newList); - } - else if (intersectLists.Count() == 1) - { - //intersectLists[0].Add(tempList[day][i]); - intersectLists[0].Add(tempList[i]); - } - else - { - for (int k = 1; k < intersectLists.Count(); k++) - { - intersectLists[0].AddRange(intersectLists[k].ToArray()); - //this.itemPages[index].Stacks[day].Remove(intersectLists[k]); - this.itemPages[index].Stacks.Remove(intersectLists[k]); - } - - //intersectLists[0].Add(tempList[day][i]); - intersectLists[0].Add(tempList[i]); - } - } - } -*/ -/* - for (int day = 0; day < 5; day++) - { - for (int i = 0; i < tempList[day].Count(); i++) - { - int[] intersectIndex = tempList[day][i].IntersectArray(tempList[day].ToArray()); - - if (intersectIndex.Count() == 0) - { - this.DrawAppointment(tempList[day][i], index, day); - } - else if (intersectIndex.Count() == 1) - { - int addIndex = -1; - - for (int k = 0; k < this.itemPages[index].Stacks[day].Count(); k++) - { - if (this.itemPages[index].Stacks[day][k].IndexOf(tempList[day][intersectIndex[0]]) > -1) - { - addIndex = k; - } - } - - if (addIndex >= 0) - { - this.itemPages[index].Stacks[day][addIndex].Add(tempList[day][i]); - } - else - { - List newList = new List(); - newList.Add(tempList[day][i]); - this.itemPages[index].Stacks[day].Add(newList); - } - } - else - { - List> intersectLists = new List>(); - - for (int k = 0; k < intersectIndex.Count(); k++) - { - for (int m = 0; m < this.itemPages[index].Stacks[day].Count(); m++) - { - if (this.itemPages[index].Stacks[day][m].IndexOf(tempList[day][intersectIndex[k]]) > -1) - { - if (intersectLists.IndexOf(this.itemPages[index].Stacks[day][m]) < 0) - { - intersectLists.Add(this.itemPages[index].Stacks[day][m]); - } - } - } - } - - if (intersectLists.Count() == 0) - { - List newList = new List(); - newList.Add(tempList[day][i]); - this.itemPages[index].Stacks[day].Add(newList); - } - else if (intersectLists.Count() == 1) - { - intersectLists[0].Add(tempList[day][i]); - } - else - { - for (int k = 1; k < intersectLists.Count(); k++) - { - intersectLists[0].AddRange(intersectLists[k].ToArray()); - this.itemPages[index].Stacks[day].Remove(intersectLists[k]); - } - - intersectLists[0].Add(tempList[day][i]); - } - } - } - } -*/ -/* - // stack draw - //for (int day = 0; day < 5; day++) - { - //for (int i = 0; i < this.itemPages[index].Stacks[day].Count(); i++) - for(int i = 0; i < this.itemPages[index].Stacks.Count(); i++) - { - //for (int k = 0; k < this.itemPages[index].Stacks[day][i].Count(); k++) - for(int k = 0; k < this.itemPages[index].Stacks[i].Count(); k++) - { - if (k > 0) - { - //this.DrawAppointment(this.itemPages[index].Stacks[day][i][k], index, day, 0.5, k, this.itemPages[index].Stacks[day][i].Count() - 1 - k); - for (int day = 0; day < 5; day++) - { - this.DrawAppointment(this.itemPages[index].Stacks[i][k], index, day, 0.5, k, this.itemPages[index].Stacks[i].Count() - 1 - k); - } - } - else - { - //this.DrawAppointment(this.itemPages[index].Stacks[day][i][k], index, day, 1.0, k, this.itemPages[index].Stacks[day][i].Count() - 1 - k); - for (int day = 0; day < 5; day++) - { - this.DrawAppointment(this.itemPages[index].Stacks[i][k], index, day, 1.0, k, this.itemPages[index].Stacks[i].Count() - 1 - k); - } - } - } -*/ -/* - Canvas[] tempCan = this.GetModelCanvasFromContent(index, this.itemPages[index].Stacks[day][i][0]); -// FIXME: tempCan[0] -> - this.DrawMultiBubble( - index, - day, - i, - this.itemPages[index].Stacks[day][i].Count(), - tempCan[0].Width + tempCan[0].Margin.Left, - tempCan[0].Margin.Top); -*/ -/* - for (int day = 0; day < 5; day++) - { - if (this.itemPages[index].Stacks[i][0].IsDate(this.itemPages[index].DateFrom.Date.AddDays(day)) > -1) - { - Canvas[] tempCan = this.GetModelCanvasFromContent(index, this.itemPages[index].Stacks[i][0]); - this.DrawMultiBubble( - index, - day, - i, - this.itemPages[index].Stacks[i].Count(), - tempCan[0].Width + tempCan[0].Margin.Left, - tempCan[0].Margin.Top); - } - } - } - } -*/ - } - private void DrawMultiBubble(int index, int dayIndex, int listIndex, int number, double xOffset, double yOffset) { Canvas can = new Canvas(); diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs index b56d75b8..a5564e04 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/WeekViewPageItem.cs @@ -1,28 +1,48 @@ -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CampusAppWP8.Utility.Lui.Templates; -using CampusAppWP8.Model.TimeTable; -using System.ComponentModel; - +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 06.11.2013 +// Implements the week view page item class +//----------------------------------------------------------------------- namespace CampusAppWP8.Pages.TimeTable { + using System; + using System.Collections.ObjectModel; + using System.ComponentModel; + using CampusAppWP8.Model.TimeTable; + using CampusAppWP8.Utility.Lui.Templates; + + /// A week view page item. + /// Fiedler, 06.11.2013. + /// public class WeekViewPageItem : INotifyPropertyChanged { + /// from dt Date/Time. private DateTime fromDT; + /// to dt Date/Time. private DateTime toDT; + /// The days. private int days; + /// The week string. private string weekStr = string.Empty; + /// The week number. private int weekNumber = -1; + /// The week view. private WeekView weekView = null; + /// List of appointments. private ObservableCollection appointmentList = null; + /// Tritt ein, wenn sich ein Eigenschaftswert ändert. public event PropertyChangedEventHandler PropertyChanged; - + /// Initializes a new instance of the WeekViewPageItem class. + /// Fiedler, 06.11.2013. + /// from Date/Time. + /// The. + /// Number of. + /// The days. public WeekViewPageItem(DateTime from, string str, int number, int days) { this.fromDT = from; @@ -33,6 +53,8 @@ namespace CampusAppWP8.Pages.TimeTable this.appointmentList = new ObservableCollection(); } + /// Gets or sets the Date/Time of from dt. + /// from dt. public DateTime FromDT { get @@ -47,6 +69,8 @@ namespace CampusAppWP8.Pages.TimeTable } } + /// Gets or sets the Date/Time of to dt. + /// to dt. public DateTime ToDT { get @@ -61,6 +85,8 @@ namespace CampusAppWP8.Pages.TimeTable } } + /// Gets or sets the week string. + /// The week string. public string WeekStr { get @@ -75,6 +101,8 @@ namespace CampusAppWP8.Pages.TimeTable } } + /// Gets or sets the week nr. + /// The week nr. public int WeekNr { get @@ -89,6 +117,8 @@ namespace CampusAppWP8.Pages.TimeTable } } + /// Gets or sets the view. + /// The view. public WeekView View { get @@ -103,6 +133,8 @@ namespace CampusAppWP8.Pages.TimeTable } } + /// Gets or sets a list of appointments. + /// A List of appointments. public ObservableCollection AppointmentList { get @@ -117,6 +149,9 @@ namespace CampusAppWP8.Pages.TimeTable } } + /// Notifies a property changed. + /// Fiedler, 06.11.2013. + /// The information. private void NotifyPropertyChanged(string info) { if (this.PropertyChanged != null) diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs index 3c7cb3f2..371b8f8f 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs @@ -12,33 +12,42 @@ namespace CampusAppWP8.Utility.Lui.Templates using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; - using System.Net; using System.Windows; using System.Windows.Controls; - using System.Windows.Navigation; using System.Windows.Media; - using Microsoft.Phone.Controls; - using Microsoft.Phone.Shell; using CampusAppWP8.Model.TimeTable; using CampusAppWP8.Pages.TimeTable; - - + + /// A week view. + /// Fiedler, 06.11.2013. + /// public partial class WeekView : UserControl { + /// The date from property. public static readonly DependencyProperty DateFromProperty = DependencyProperty.Register("DateFrom", typeof(DateTime), typeof(WeekView), new PropertyMetadata(new DateTime(0), OnDateFromChanged)); + /// The date to property. public static readonly DependencyProperty DateToProperty = DependencyProperty.Register("DateTo", typeof(DateTime), typeof(WeekView), new PropertyMetadata(new DateTime(0))); + /// The days property. public static readonly DependencyProperty DaysProperty = DependencyProperty.Register("Days", typeof(int), typeof(WeekView), new PropertyMetadata(5)); + /// The appointments property. public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(ObservableCollection), typeof(WeekView), new PropertyMetadata(null, OnAppointmentsChanged)); + /// The week name property. public static readonly DependencyProperty WeekNameProperty = DependencyProperty.Register("WeekName", typeof(string), typeof(WeekView), new PropertyMetadata("T-Woche")); + /// The week number property. public static readonly DependencyProperty WeekNumberProperty = DependencyProperty.Register("WeekNumber", typeof(int), typeof(WeekView), new PropertyMetadata(-1)); + /// List of borders. private List borderList = new List(); + /// List of days. private List dayList = new List(); + /// The time strings. private string[] timeStrings = new string[24]; + /// The monitor strings. private string[] monStrings = new string[24]; - + /// Initializes a new instance of the WeekView class. + /// Fiedler, 06.11.2013. public WeekView() { this.InitializeComponent(); @@ -46,6 +55,10 @@ namespace CampusAppWP8.Utility.Lui.Templates this.InitLayout(); } + /// Raises the dependency property changed event. + /// Fiedler, 06.11.2013. + /// The DependencyObject to process. + /// Event information to send to registered event handlers. private static void OnDateFromChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { (o as WeekView).SetValue(DateToProperty, ((DateTime)e.NewValue).AddDays(6)); @@ -61,8 +74,16 @@ namespace CampusAppWP8.Utility.Lui.Templates { (o as WeekView).SetColumnBackground(diff.Days, new SolidColorBrush(Colors.Orange)); } + else + { + (o as WeekView).ClearBackground(); + } } + /// Raises the dependency property changed event. + /// Fiedler, 06.11.2013. + /// The DependencyObject to process. + /// Event information to send to registered event handlers. private static void OnAppointmentsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { if (e.NewValue != null) @@ -77,6 +98,10 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Raises the notify collection changed event. + /// Fiedler, 06.11.2013. + /// The object to process. + /// Event information to send to registered event handlers. private void OnAppointmentListChanged(object s, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) @@ -93,8 +118,25 @@ namespace CampusAppWP8.Utility.Lui.Templates this.SeperateAppointments(e.OldItems[i] as AppointmentModel, e.Action); } } + else if (e.Action == NotifyCollectionChangedAction.Reset) + { + this.ClearDays(); + } } + /// Clears the days. + /// Fiedler, 06.11.2013. + private void ClearDays() + { + for (int i = 0; i < this.dayList.Count; i++) + { + this.dayList[i].Appointments.Clear(); + } + } + + /// Seperate appointments. + /// Fiedler, 06.11.2013. + /// The list. private void SeperateAppointments(ObservableCollection list) { foreach (AppointmentModel m in list) @@ -103,9 +145,13 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Seperate appointments. + /// Fiedler, 06.11.2013. + /// The model. + /// The action. private void SeperateAppointments(AppointmentModel model, NotifyCollectionChangedAction action) { - for(int i = 0; i < this.Days; i++) + for(int i = 0; i < this.dayList.Count; i++) { if (model.IsDate(this.DateFrom.AddDays(i)) == 0) { @@ -121,6 +167,8 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Gets or sets the Date/Time of the date from. + /// The date from. public DateTime DateFrom { get @@ -134,6 +182,8 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Gets or sets the Date/Time of the date to. + /// The date to. public DateTime DateTo { get @@ -147,6 +197,8 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Gets or sets the days. + /// The days. public int Days { get @@ -160,6 +212,8 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Gets or sets the appointments. + /// The appointments. public ObservableCollection Appointments { get @@ -173,6 +227,8 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Gets or sets the name of the week. + /// The name of the week. public string WeekName { get @@ -187,6 +243,8 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Gets or sets the week number. + /// The week number. public int WeekNumber { get @@ -200,6 +258,10 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Sets column background. + /// Fiedler, 06.11.2013. + /// The column. + /// (Optional) the brush. public void SetColumnBackground(int column, Brush brush = null) { if (column < this.borderList.Count()) @@ -208,6 +270,20 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Clears the background. + /// Fiedler, 06.11.2013. + public void ClearBackground() + { + SolidColorBrush newBrush = new SolidColorBrush(Colors.Transparent); + + for (int i = 0; i < this.borderList.Count; i++) + { + this.borderList[i].Background = newBrush; + } + } + + /// Initialises the layout. + /// Fiedler, 06.11.2013. private void InitLayout() { for (int i = 0; i < 24; i++) @@ -231,6 +307,10 @@ namespace CampusAppWP8.Utility.Lui.Templates this.TimeList.ItemsSource = this.timeStrings; } + /// Automatic scroll. + /// Fiedler, 06.11.2013. + /// Source of the event. + /// Routed event information. private void AutoScroll(object sender, RoutedEventArgs e) { this.TheScrollView.ScrollToVerticalOffset((TimeTable.Setting_Hour_Spacing * 7) + 2); diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs index 4d67b4ce..f6df4edc 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs @@ -23,17 +23,27 @@ namespace CampusAppWP8.Utility.Lui.Templates using System.Windows.Media; using System.Windows.Data; using CampusAppWP8.Model.TimeTable; - + + /// A week view day. + /// Fiedler, 06.11.2013. + /// public partial class WeekViewDay : UserControl { + /// The background list elements property. public static readonly DependencyProperty BgListElementsProperty = DependencyProperty.Register("BgListElements", typeof(int), typeof(WeekViewDay), new PropertyMetadata(null)); + + /// The background list element height property. public static readonly DependencyProperty BgListElementHeightProperty = DependencyProperty.Register("BgListElementHeight", typeof(double), typeof(WeekViewDay), new PropertyMetadata(null)); + + /// The date property. public static readonly DependencyProperty DateProperty = DependencyProperty.Register("Date", typeof(DateTime), typeof(WeekViewDay), new PropertyMetadata(DateTime.Today)); + + /// The appointments property. public static readonly DependencyProperty AppointmentsProperty = DependencyProperty.Register("Appointments", typeof(ObservableCollection), typeof(WeekViewDay), new PropertyMetadata(null, OnAppointmentsChanged)); + /// The stacks. private List> stacks = new List>(); - /// Initializes a new instance of the WeekViewDay class. /// Fiedler, 22.10.2013. public WeekViewDay() @@ -43,6 +53,10 @@ namespace CampusAppWP8.Utility.Lui.Templates this.InitializeComponent(); } + /// Raises the dependency property changed event. + /// Fiedler, 06.11.2013. + /// The DependencyObject to process. + /// Event information to send to registered event handlers. private static void OnAppointmentsChanged(DependencyObject o, DependencyPropertyChangedEventArgs e) { if(e.NewValue != null) @@ -56,6 +70,10 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Raises the notify collection changed event. + /// Fiedler, 06.11.2013. + /// The object to process. + /// Event information to send to registered event handlers. private void OnAppointmentListChanged(object s, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Add) @@ -72,8 +90,15 @@ namespace CampusAppWP8.Utility.Lui.Templates this.CheckStackRemove(e.OldItems[i] as AppointmentModel); } } + else if (e.Action == NotifyCollectionChangedAction.Reset) + { + this.UserCanvas.Children.Clear(); + this.stacks.Clear(); + } } + /// Gets or sets the appointments. + /// The appointments. public ObservableCollection Appointments { get @@ -87,6 +112,8 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Gets or sets the Date/Time of the date. + /// The date. public DateTime Date { get @@ -99,7 +126,7 @@ namespace CampusAppWP8.Utility.Lui.Templates this.SetValue(DateProperty, value); } } - + /// Gets or sets the background list elements. /// The background list elements. public int BgListElements @@ -140,6 +167,9 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Check stack add. + /// Fiedler, 06.11.2013. + /// The model. private void CheckStackAdd(AppointmentModel model) { int[] intersect = model.IntersectArray(this.Appointments.ToArray()); @@ -207,6 +237,9 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Check stack remove. + /// Fiedler, 06.11.2013. + /// The model. private void CheckStackRemove(AppointmentModel model) { int stackIndex = -1; @@ -247,6 +280,10 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Draw stack. + /// Fiedler, 06.11.2013. + /// The new model. + /// The stack. private void DrawStack(AppointmentModel newModel, List stack) { for (int i = 0; i < stack.Count; i++) @@ -262,6 +299,10 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Manipulate application canvas. + /// Fiedler, 06.11.2013. + /// The model. + /// Zero-based index of the stack. private void ManipulateAppCanvas(AppointmentModel model, int stackIndex) { if (stackIndex < this.stacks.Count) @@ -270,6 +311,10 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Manipulate application canvas. + /// Fiedler, 06.11.2013. + /// The model. + /// The list. private void ManipulateAppCanvas(AppointmentModel model, List list) { int index = list.IndexOf(model); @@ -280,6 +325,11 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Manipulate application canvas. + /// Fiedler, 06.11.2013. + /// The model. + /// Zero-based index of the. + /// Number of. private void ManipulateAppCanvas(AppointmentModel model, int index, int count) { AppointmentCanvas can = null; @@ -298,6 +348,10 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Draw application. + /// Fiedler, 06.11.2013. + /// The model. + /// (Optional) Zero-based index of the stack. private void DrawApp(AppointmentModel model, int stackIndex = -1) { if (stackIndex >= 0) @@ -310,6 +364,10 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /// Draw application. + /// Fiedler, 06.11.2013. + /// The model. + /// (Optional) The stack. private void DrawApp(AppointmentModel model, List stack = null) { AppointmentCanvas newCan = new AppointmentCanvas(model, this.Date); @@ -329,6 +387,9 @@ namespace CampusAppWP8.Utility.Lui.Templates this.UserCanvas.Children.Add(newCan); } + /// Un draw application. + /// Fiedler, 06.11.2013. + /// The model. private void UnDrawApp(AppointmentModel model) { int index = -1; From d89b544cf04c27f6160e4cb83ec0a47a628d8186 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Fri, 8 Nov 2013 18:25:22 +0100 Subject: [PATCH 08/22] DayView done --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 2 + .../Pages/TimeTable/DayViewPageItem.cs | 73 ++++ .../Pages/TimeTable/TimeTableDay.xaml | 20 +- .../Pages/TimeTable/TimeTableDay.xaml.cs | 353 ++---------------- .../Pages/TimeTable/TimeTableWeek.xaml | 4 +- .../Utility/DoubleNaNConverter.cs | 22 ++ .../Utility/Lui/Templates/WeekView.xaml | 123 ++++-- .../Utility/Lui/Templates/WeekView.xaml.cs | 147 +++++++- .../Utility/Lui/Templates/WeekViewDay.xaml | 11 +- .../Utility/Lui/Templates/WeekViewDay.xaml.cs | 29 +- 10 files changed, 429 insertions(+), 355 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/Pages/TimeTable/DayViewPageItem.cs create mode 100644 CampusAppWP8/CampusAppWP8/Utility/DoubleNaNConverter.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 9be602ad..8f2dbfdb 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -142,6 +142,7 @@ AppointmentEdit.xaml + TimeTableDay.xaml @@ -153,6 +154,7 @@ TimeTableWeek.xaml + 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/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 c6db0614..22981d0c 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; @@ -34,14 +35,7 @@ namespace CampusAppWP8.Pages.TimeTable 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 +47,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(); @@ -96,8 +91,11 @@ namespace CampusAppWP8.Pages.TimeTable } 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 +110,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 +121,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.Feed.Model.Appointments.IndexOf((sender as Canvas).Tag as AppointmentModel); + int index = TimeTable.Feed.Model.Appointments.IndexOf(model); if (index >= 0) { TimeTable.Feed.Model.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(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; @@ -152,6 +148,7 @@ 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; @@ -184,14 +181,7 @@ namespace CampusAppWP8.Pages.TimeTable 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.Setting_AutoScrollToHour); - } + */ } private void OnClickWeek(object sender, EventArgs e) @@ -203,6 +193,7 @@ namespace CampusAppWP8.Pages.TimeTable 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; @@ -212,6 +203,7 @@ namespace CampusAppWP8.Pages.TimeTable this.SetupPage(i); } + */ } private void OnClickProperties(object sender, EventArgs e) @@ -232,6 +224,7 @@ namespace CampusAppWP8.Pages.TimeTable private void OnListChanged(object sender, NotifyCollectionChangedEventArgs e) { + /* AppointmentModel tempModel = null; if (e.Action == NotifyCollectionChangedAction.Add) @@ -253,236 +246,42 @@ namespace CampusAppWP8.Pages.TimeTable } } } + */ } - private void AddContentUIElement(int index, UIElement elem) + private void CheckAppointments(int index = -1) { - 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) + if (index < 0) { - 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))) + for (int m = 0; m < TimeTable.Feed.Model.Appointments.Count; m++) { - if ((tempCan.Tag as AppointmentModel).Equals(model)) + AppointmentModel temp = TimeTable.Feed.Model.Appointments[m]; + + for (int i = 0; i < PIVOT_ITEM_PAGES; i++) { - 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.Feed.Model.Appointments.Count(); i++) - { - int appointmentIndex = -1; - - if ((appointmentIndex = TimeTable.Feed.Model.Appointments[i].IsDate(this.itemPages[index].Date)) > -1) - { - tempList.Add(TimeTable.Feed.Model.Appointments[i]); - } - } - // ------------------------------------------------------------- - for (int i = 0; i < tempList.Count(); i++) - { - int[] intersectIndex = tempList[i].IntersectArray(tempList.ToArray()); - - if (intersectIndex.Count() == 0) - { - 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) - { -/* TODO - 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(); @@ -514,79 +313,7 @@ namespace CampusAppWP8.Pages.TimeTable 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); + //this.AddContentUIElement(stackIndex, can); } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml index caaf9438..9a39756a 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml @@ -32,7 +32,9 @@ DateFrom="{Binding Path=FromDT, Mode=OneWay}" WeekName="{Binding Path=WeekStr, Mode=OneWay}" Appointments="{Binding Path=AppointmentList, Mode=OneWay}" - WeekNumber="{Binding Path=WeekNr, Mode=OneWay}"/> + WeekNumber="{Binding Path=WeekNr, Mode=OneWay}" + Days="5" + ToDayColoring="True"/> 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/Lui/Templates/WeekView.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml index 3b9c5896..962789ad 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml @@ -5,12 +5,17 @@ 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"> + + + + @@ -18,7 +23,7 @@ - + @@ -37,32 +42,90 @@ - - + + - - - - - - + + + + + + + + + + + + + + + + - - + + + - - + + + - - + + + - - + + + - - + + + + + + + + + + + @@ -90,6 +153,10 @@ + + + + @@ -107,25 +174,33 @@ - + - + - + - + - + + + + + + + + + diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs index 371b8f8f..b824d1ef 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs @@ -36,6 +36,10 @@ namespace CampusAppWP8.Utility.Lui.Templates /// The week number property. public static readonly DependencyProperty WeekNumberProperty = DependencyProperty.Register("WeekNumber", typeof(int), typeof(WeekView), new PropertyMetadata(-1)); + 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. @@ -68,15 +72,18 @@ namespace CampusAppWP8.Utility.Lui.Templates (o as WeekView).dayList[i].Date = ((DateTime)e.NewValue).AddDays(i); } - TimeSpan diff = DateTime.Today.Subtract((o as WeekView).DateFrom); + 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(); + if (diff.TotalDays >= 0 && diff.TotalDays < 5) + { + (o as WeekView).SetColumnBackground(diff.Days, new SolidColorBrush(Colors.Orange)); + } + else + { + (o as WeekView).ClearBackground(); + } } } @@ -258,6 +265,130 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + 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. diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml index e466a31e..a85ecd37 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml @@ -3,6 +3,7 @@ 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}" @@ -10,7 +11,11 @@ x:Name="root" > - + + + + + @@ -27,13 +32,13 @@ x:Name="BGCanvas" Canvas.ZIndex="1" Height="{Binding Path=ActualHeight, ElementName=MainCanvas, Mode=OneWay}" - Width="{Binding Path=ActualWidth, ElementName=MainCanvas, Mode=OneWay}" + Width="{Binding Path=Width, ElementName=MainCanvas, Mode=OneWay, Converter={StaticResource NaNConverter}}" /> diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs index f6df4edc..8327b81b 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekViewDay.xaml.cs @@ -23,6 +23,7 @@ namespace CampusAppWP8.Utility.Lui.Templates using System.Windows.Media; using System.Windows.Data; using CampusAppWP8.Model.TimeTable; + using CampusAppWP8.Utility; /// A week view day. /// Fiedler, 06.11.2013. @@ -51,6 +52,13 @@ namespace CampusAppWP8.Utility.Lui.Templates 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. @@ -112,6 +120,8 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + + /// Gets or sets the Date/Time of the date. /// The date. public DateTime Date @@ -374,8 +384,9 @@ namespace CampusAppWP8.Utility.Lui.Templates newCan.DoubleTap += new EventHandler(model.OnCanvasClick); - Binding widthBind = new Binding("ActualWidth"); - widthBind.ElementName = "MainCanvas"; + Binding widthBind = new Binding("Width"); + widthBind.ElementName = "UserCanvas"; + widthBind.Converter = new DoubleNaNConverter(); widthBind.Mode = BindingMode.OneWay; newCan.SetBinding(WidthProperty, widthBind); @@ -387,6 +398,8 @@ namespace CampusAppWP8.Utility.Lui.Templates this.UserCanvas.Children.Add(newCan); } + + /// Un draw application. /// Fiedler, 06.11.2013. /// The model. @@ -408,6 +421,13 @@ namespace CampusAppWP8.Utility.Lui.Templates } } + /* + protected override void OnDoubleTap(System.Windows.Input.GestureEventArgs e) + { + base.OnDoubleTap(e); + } + */ + /// Draw lines. /// Fiedler, 22.10.2013. private void DrawLines() @@ -418,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++) From 6197a4cc12c49fde74f9cc8899932554e75011df Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Mon, 11 Nov 2013 15:15:40 +0100 Subject: [PATCH 09/22] added timespan-from-today relative appointment loading --- .../Feed/TimeTable/AppointmentFeed.cs | 30 ++++++++++++++++++- .../CampusAppWP8/Pages/StartPage.xaml | 1 + .../CampusAppWP8/Pages/StartPage.xaml.cs | 20 +++++++++++++ .../CampusAppWP8/Pages/TimeTable/TimeTable.cs | 16 ++++++++-- .../CampusAppWP8/Properties/WMAppManifest.xml | 2 +- 5 files changed, 65 insertions(+), 4 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs index 2131a7d8..6e52cc16 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs @@ -8,6 +8,7 @@ //----------------------------------------------------------------------- namespace CampusAppWP8.Feed.TimeTable { + using System; using System.Collections.Generic; using System.IO; using System.Text; @@ -23,6 +24,8 @@ namespace CampusAppWP8.Feed.TimeTable /// 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. @@ -39,6 +42,21 @@ namespace CampusAppWP8.Feed.TimeTable } } + 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. @@ -113,7 +131,17 @@ namespace CampusAppWP8.Feed.TimeTable AppointmentModel newAppModel = new AppointmentModel(appStr[i]); - this.Model.Appointments.Add(newAppModel); + if (this.span.Equals(TimeSpan.Zero)) + { + this.Model.Appointments.Add(newAppModel); + } + else + { + if (newAppModel.IsDate(DateTime.Today, this.span.Days) >= 0) + { + this.Model.Appointments.Add(newAppModel); + } + } } } diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml index 06f98638..2203c800 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml @@ -276,6 +276,7 @@ + diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs index 9f84551d..dde76ad0 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(); @@ -462,6 +476,12 @@ 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 } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs index 526ef841..7cdc525c 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTable.cs @@ -68,9 +68,21 @@ namespace CampusAppWP8.Pages.TimeTable /// Fiedler, 06.11.2013. public static void InitFeed() { - if(TimeTable.feed == null) + TimeTable.InitFeed(TimeSpan.Zero); + } + + public static void InitFeed(TimeSpan span) + { + if (TimeTable.feed == null) { - TimeTable.feed = new AppointmentFeed(false); + 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(); } diff --git a/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml b/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml index ebcb1c37..288b01c9 100644 --- a/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml +++ b/CampusAppWP8/CampusAppWP8/Properties/WMAppManifest.xml @@ -13,7 +13,7 @@ - + From 39f70beab7091bbffcc1f0c82cda7381c0047a45 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Mon, 11 Nov 2013 17:46:20 +0100 Subject: [PATCH 10/22] TimeSpan-from-ToDay relative loading --- .../Feed/TimeTable/AppointmentFeed.cs | 2 +- .../Model/TimeTable/AppointmentModel.cs | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs index 6e52cc16..50259e02 100644 --- a/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs +++ b/CampusAppWP8/CampusAppWP8/Feed/TimeTable/AppointmentFeed.cs @@ -137,7 +137,7 @@ namespace CampusAppWP8.Feed.TimeTable } else { - if (newAppModel.IsDate(DateTime.Today, this.span.Days) >= 0) + if (newAppModel.IsInRange(DateTime.Today, this.span)) { this.Model.Appointments.Add(newAppModel); } diff --git a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs index bc731c58..912fab57 100644 --- a/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs +++ b/CampusAppWP8/CampusAppWP8/Model/TimeTable/AppointmentModel.cs @@ -101,6 +101,23 @@ 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. From 8365b5b0dccf13d64faa69a3e03707299def866c Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Tue, 12 Nov 2013 17:19:47 +0100 Subject: [PATCH 11/22] TimeTable done --- .../Pages/TimeTable/TimeTableDay.xaml.cs | 171 +++++++----------- .../Pages/TimeTable/TimeTableWeek.xaml.cs | 108 ----------- .../Utility/Lui/Templates/WeekView.xaml | 150 +++++++-------- .../Utility/Lui/Templates/WeekView.xaml.cs | 13 ++ 4 files changed, 152 insertions(+), 290 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs index 22981d0c..b7efc4e2 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableDay.xaml.cs @@ -24,14 +24,6 @@ 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; @@ -136,7 +128,7 @@ namespace CampusAppWP8.Pages.TimeTable if (index >= 0) { - TimeTable.Feed.Model.Appointments.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged); + TimeTable.Feed.Model.Appointments.CollectionChanged += this.OnListChanged; string urlString = Constants.PathTimeTable_Appointment + "?" + Constants.Param_Appointment_Index + "=" + index; @@ -146,107 +138,102 @@ 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 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); - - this.SetupPage(i); + if (this.itemList[i].Day.Date.Equals(DateTime.Today.Date)) + { + index = 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.Feed.Model.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; - } - else if (e.Action == NotifyCollectionChangedAction.Remove) - { - tempModel = e.OldItems[0] as AppointmentModel; - } - - if (tempModel != null) - { - for (int i = 0; i < PIVOT_ITEM_PAGES; i++) + for(int i = 0; i < e.NewItems.Count; i++) { - if (tempModel.IsDate(this.itemPages[i].Date.Date) > -1) + AppointmentModel m = e.NewItems[i] as AppointmentModel; + + for(int a = 0; a < PIVOT_ITEM_PAGES; a++) { - this.SetupPage(i); + if(m.IsDate(this.itemList[a].Day) == 0) + { + this.itemList[a].AppointmentList.Add(m); + } } } } - */ + else if (e.Action == NotifyCollectionChangedAction.Remove) + { + for (int i = 0; i < e.OldItems.Count; i++) + { + AppointmentModel m = e.OldItems[i] as AppointmentModel; + + 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++) + { + this.itemList[i].AppointmentList.Clear(); + } + } } private void CheckAppointments(int index = -1) @@ -281,39 +268,5 @@ namespace CampusAppWP8.Pages.TimeTable } } } - - 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); - } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs index 8f9aa30e..f259361d 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/TimeTableWeek.xaml.cs @@ -22,9 +22,6 @@ namespace CampusAppWP8.Pages.TimeTable public partial class TimeTableWeek : PhoneApplicationPage { - private static readonly double WEEK_TABLE_CELL_HEIGHT = 40; - private static readonly int WEEK_TABLE_ZINDEX_MAX = 10; - private static readonly int PIVOT_PAGES = 3; private static readonly int PIVOT_PAGES_HALF_DOWN = 1; @@ -244,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; @@ -383,48 +318,5 @@ namespace CampusAppWP8.Pages.TimeTable } } } - - 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); - } } } \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml index 962789ad..a30baecb 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml @@ -14,6 +14,7 @@ + @@ -128,80 +129,83 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ 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 b824d1ef..0dbeb5e8 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/Lui/Templates/WeekView.xaml.cs @@ -15,6 +15,7 @@ namespace CampusAppWP8.Utility.Lui.Templates using System.Windows; using System.Windows.Controls; using System.Windows.Media; + using System.Windows.Shapes; using CampusAppWP8.Model.TimeTable; using CampusAppWP8.Pages.TimeTable; @@ -446,5 +447,17 @@ namespace CampusAppWP8.Utility.Lui.Templates { 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; + + + } } } From fa5d2e17e5c7bac0cfe502cb3d1c843cdf585cf7 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Wed, 13 Nov 2013 13:46:53 +0100 Subject: [PATCH 12/22] #269 done --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 3 +- .../Feed/Openinghours/OpeninghoursFeed.cs | 10 +- .../OpeninghoursInstitutionWp8Model.cs | 156 --------- .../Openinghours/OpeninghoursWp8Model.cs | 20 -- .../Pages/Openinghours/OpeninghoursPage.xaml | 211 ++++++------ .../Openinghours/OpeninghoursPage.xaml.cs | 84 +++-- .../CampusAppWP8/Resources/Constants.resx | 2 +- .../Resources/Constants1.Designer.cs | 2 +- .../Utility/IdToPlaceConverter.cs | 113 +++++++ .../CampusAppWPortalLib8.csproj | 2 + .../Model/Openinghours/OpenhoursDayModel.cs | 217 +++++++++++++ .../OpeninghoursInstitutionModel.cs | 300 +++++++++++++----- .../Openinghours/OpeninghoursLocationModel.cs | 62 ++++ .../Model/Openinghours/OpeninghoursModel.cs | 14 +- 14 files changed, 779 insertions(+), 417 deletions(-) delete mode 100644 CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursInstitutionWp8Model.cs delete mode 100644 CampusAppWP8/CampusAppWP8/Model/Openinghours/OpeninghoursWp8Model.cs create mode 100644 CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpenhoursDayModel.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Openinghours/OpeninghoursLocationModel.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index bad54601..c4b29600 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -236,6 +236,7 @@ + @@ -281,8 +282,6 @@ - - CampusMapPage.xaml 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/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/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/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 1e7fbdef..74dd8ca7 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 diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs index 4aec5b6e..f290ade3 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs @@ -1357,7 +1357,7 @@ 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/openinghours.php?v=2 ähnelt. /// public static string UrlOpeningHours_OpeningHours { get { diff --git a/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs new file mode 100644 index 00000000..4c57f4e7 --- /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 += new PlacesFile.OnIO(this.PlaceFileIsReady); + this.placeFile.OnFailedLoad += new PlacesFile.OnFailed(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/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj index ea952363..4826570b 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj +++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj @@ -63,7 +63,9 @@ + + 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; } } From c7f7566e5ac0ff74569e4873b9acbd5002b82aa3 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Wed, 13 Nov 2013 14:39:23 +0100 Subject: [PATCH 13/22] Rotation functions added --- .../Model/Utility/MapPoint.cs | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) 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 } } From 96075183185731ec2296f928b4ad83a3bfe09bd3 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Wed, 13 Nov 2013 17:40:10 +0100 Subject: [PATCH 14/22] end of day commit --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 2 + .../CampusAppWP8/Feed/Mensa/PriceFeed.cs | 82 ++++++++ .../CampusAppWP8/Pages/Mensa/MensaPage.xaml | 40 ++-- .../Pages/Mensa/MensaPage.xaml.cs | 7 + .../CampusAppWP8/Resources/Constants.resx | 6 + .../Resources/Constants1.Designer.cs | 18 ++ .../Utility/IdToPlaceConverter.cs | 4 +- .../Utility/MealIdToPriceConverter.cs | 46 +++++ .../CampusAppWPortalLib8.csproj | 3 + .../Model/Mensa/PriceCanteenModel.cs | 185 ++++++++++++++++++ .../Model/Mensa/PriceMealModel.cs | 172 ++++++++++++++++ .../Model/Mensa/PriceModel.cs | 64 ++++++ 12 files changed, 615 insertions(+), 14 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/Feed/Mensa/PriceFeed.cs create mode 100644 CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceCanteenModel.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs create mode 100644 CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index c4b29600..43b27b8b 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -102,6 +102,7 @@ App.xaml + @@ -255,6 +256,7 @@ WeekViewDay.xaml + NFC.xaml 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/Pages/Mensa/MensaPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml index 6377d8db..ac82d84d 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml @@ -10,12 +10,19 @@ xmlns:header="clr-namespace:CampusAppWP8.Utility.Lui.Header" 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"> + + + + + @@ -44,18 +51,27 @@ - - - - - - - - + + + + + + + + + + + + + + + + - - - + + + + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs index 376a77a4..73cd21d2 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs @@ -48,6 +48,8 @@ namespace CampusAppWP8.Pages.Mensa /// Flag for forcing webLoad. private bool forceLoad = false; + public int LocationID { get; set; } + #endregion #region Constructor @@ -56,6 +58,8 @@ 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; @@ -341,6 +345,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 +356,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 +367,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); } diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 74dd8ca7..4470f195 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -594,4 +594,10 @@ CurrentPositionPoint + + 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 f290ade3..372a03ba 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs @@ -375,6 +375,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. /// @@ -1356,6 +1365,15 @@ namespace CampusAppWP8.Resources { } } + /// + /// 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. /// diff --git a/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs index 4c57f4e7..07a8dd99 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/IdToPlaceConverter.cs @@ -26,8 +26,8 @@ namespace CampusAppWP8.Utility public IdToPlaceConverter() { this.placeFile = new PlacesFile(); - this.placeFile.OnLoaded += new PlacesFile.OnIO(this.PlaceFileIsReady); - this.placeFile.OnFailedLoad += new PlacesFile.OnFailed(this.PlaceFileIsFailed); + this.placeFile.OnLoaded += this.PlaceFileIsReady; + this.placeFile.OnFailedLoad += this.PlaceFileIsFailed; this.placeFile.LoadData(); } diff --git a/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs new file mode 100644 index 00000000..5adfdb57 --- /dev/null +++ b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs @@ -0,0 +1,46 @@ +namespace CampusAppWP8.Utility +{ + using System; + using System.Windows.Data; + using CampusAppWP8.Feed.Mensa; + using CampusAppWPortalLib8.Model.GeoDb; + + public sealed class MealIdToPriceConverter : IValueConverter + { + private PriceFeed priceFeed = null; + + public MealIdToPriceConverter() + { + this.priceFeed = new PriceFeed(); + this.priceFeed.OnLoaded += this.PriceFeedIsReady; + this.priceFeed.OnFailedLoad += this.PriceFeedIsFailed; + this.priceFeed.LoadData(); + } + + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) + { + string retValue = string.Empty; + + if ((parameter is int) && (value is int)) + { + retValue = this.priceFeed.Model.GetCanteen((int)value).GetPriceMealModel((int)parameter).PriceString(); + } + + return retValue; + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo language) + { + return null; + } + + private void PriceFeedIsReady() + { + } + + private void PriceFeedIsFailed() + { + } + } +} \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj index 4826570b..addae01f 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj +++ b/CampusAppWP8/CampusAppWPortalLib8/CampusAppWPortalLib8.csproj @@ -62,6 +62,9 @@ + + + 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..ff3a2526 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs @@ -0,0 +1,172 @@ +//----------------------------------------------------------------------- +// +// 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 string.Format("{0:0.00}", 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 string.Format("{0:00.0}", 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 string.Format("{0:00.0}", 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; + } + } + + /// Gets the price string. + /// Fiedler, 13.11.2013. + /// A string. + public string PriceString() + { + string retValue = string.Empty; + + retValue = "S: " + this.PriceGuestStr + " A: " + this.PriceEmployeeStr + " G: " + this.PriceGuestStr; + + return retValue; + } + } +} diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs new file mode 100644 index 00000000..ff66b109 --- /dev/null +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs @@ -0,0 +1,64 @@ +//----------------------------------------------------------------------- +// +// The MIT License (MIT). Copyright (c) 2013 BTU/IIT. +// +// Fiedler +// 13.11.2013 +// Implements the price model class +//----------------------------------------------------------------------- +namespace CampusAppWPortalLib8.Model.Mensa +{ + using System.Collections.ObjectModel; + using System.Xml.Serialization; + + /// A data Model for the price. + /// Fiedler, 13.11.2013. + [XmlRoot("Canteens")] + 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. + [XmlElement("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; + + for (int i = 0; i < this.canteens.Count; i++) + { + if (this.canteens[i].Id.Equals(id)) + { + retValue = this.canteens[i]; + } + } + + return retValue; + } + } +} \ No newline at end of file From 4ecc87f8636e9f6f1c99f7f9be308a35598faf6c Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Thu, 14 Nov 2013 18:18:02 +0100 Subject: [PATCH 15/22] #204 --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 7 ++ .../CampusAppWP8/Pages/Mensa/MensaPage.xaml | 3 +- .../Pages/Mensa/MensaPage.xaml.cs | 20 +++- .../Resources/AppResources.Designer.cs | 27 ++++++ .../CampusAppWP8/Resources/AppResources.resx | 9 ++ .../Utility/Lui/MultiValueTextBlock.xaml | 18 ++++ .../Utility/Lui/MultiValueTextBlock.xaml.cs | 94 +++++++++++++++++++ .../Utility/MealIdToPriceConverter.cs | 62 ++++++++++-- .../Model/Mensa/PriceMealModel.cs | 19 ++-- .../Model/Mensa/PriceModel.cs | 5 +- 10 files changed, 242 insertions(+), 22 deletions(-) create mode 100644 CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml create mode 100644 CampusAppWP8/CampusAppWP8/Utility/Lui/MultiValueTextBlock.xaml.cs diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index 43b27b8b..698e02d7 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -249,6 +249,9 @@ WeekViewPivotHeader.xaml + + MultiValueTextBlock.xaml + WeekView.xaml @@ -532,6 +535,10 @@ Designer MSBuild:Compile + + Designer + MSBuild:Compile + Designer MSBuild:Compile diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml index ac82d84d..3b83b591 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml @@ -8,6 +8,7 @@ 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" @@ -71,7 +72,7 @@ - + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs index 73cd21d2..8952c549 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs @@ -48,7 +48,8 @@ namespace CampusAppWP8.Pages.Mensa /// Flag for forcing webLoad. private bool forceLoad = false; - public int LocationID { get; set; } + /// Identifier for the location. + public int locationID = -1; #endregion @@ -58,7 +59,7 @@ namespace CampusAppWP8.Pages.Mensa /// Stubbfel, 15.10.2013. public MensaPage() { - this.LocationID = 0; + this.locationID = 0; this.InitializeComponent(); ApplicationBarMenuItem menuItem1 = ApplicationBar.MenuItems[0] as ApplicationBarMenuItem; @@ -85,6 +86,21 @@ namespace CampusAppWP8.Pages.Mensa #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 diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index dffe834c..5ab45237 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -375,6 +375,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 +429,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. /// @@ -1266,6 +1284,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..9297b6cd 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -596,4 +596,13 @@ Mi + + Angestellte + + + Gäste + + + Studenten + \ No newline at end of file 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/MealIdToPriceConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs index 5adfdb57..dad09bf1 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs @@ -1,14 +1,29 @@ -namespace CampusAppWP8.Utility +//----------------------------------------------------------------------- +// +// 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 CampusAppWPortalLib8.Model.GeoDb; + 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(); @@ -17,28 +32,63 @@ 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; - - if ((parameter is int) && (value is int)) + int intVal = -1; + int intParam = -1; + + if (value is int) { - retValue = this.priceFeed.Model.GetCanteen((int)value).GetPriceMealModel((int)parameter).PriceString(); + 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)) + { + 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() { } + /// Price feed is failed. + /// Fiedler, 14.11.2013. private void PriceFeedIsFailed() { } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs index ff3a2526..460322f6 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceMealModel.cs @@ -68,7 +68,7 @@ namespace CampusAppWPortalLib8.Model.Mensa { get { - return string.Format("{0:0.00}", this.priceStudent); + return this.CurrencyString(this.priceStudent); } set @@ -100,7 +100,7 @@ namespace CampusAppWPortalLib8.Model.Mensa { get { - return string.Format("{0:00.0}", this.priceEmployee); + return this.CurrencyString(this.priceEmployee); } set @@ -132,7 +132,7 @@ namespace CampusAppWPortalLib8.Model.Mensa { get { - return string.Format("{0:00.0}", this.priceGuest); + return this.CurrencyString(this.priceGuest); } set @@ -157,16 +157,13 @@ namespace CampusAppWPortalLib8.Model.Mensa } } - /// Gets the price string. - /// Fiedler, 13.11.2013. + /// Currency string. + /// Fiedler, 14.11.2013. + /// The value. /// A string. - public string PriceString() + private string CurrencyString(double val) { - string retValue = string.Empty; - - retValue = "S: " + this.PriceGuestStr + " A: " + this.PriceEmployeeStr + " G: " + this.PriceGuestStr; - - return retValue; + return string.Format("{0:0.00}", val); } } } diff --git a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs index ff66b109..3a62b506 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs @@ -13,7 +13,7 @@ namespace CampusAppWPortalLib8.Model.Mensa /// A data Model for the price. /// Fiedler, 13.11.2013. - [XmlRoot("Canteens")] + [XmlRoot("root")] public class PriceModel { /// The canteens. @@ -28,7 +28,8 @@ namespace CampusAppWPortalLib8.Model.Mensa /// Gets or sets the canteens. /// The canteens. - [XmlElement("Canteen")] + [XmlArray("Canteens")] + [XmlArrayItem("Canteen")] public ObservableCollection Canteens { get From d264900b13b5d656cf312dfac030095a50e4893c Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Thu, 14 Nov 2013 20:50:04 +0100 Subject: [PATCH 16/22] nearly done --- .../Pages/Campusmap/RoomListPage.xaml | 68 +++++++++++-------- .../Pages/Campusmap/RoomListPage.xaml.cs | 56 +++++++++++---- 2 files changed, 82 insertions(+), 42 deletions(-) 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..074b1529 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,16 @@ namespace CampusAppWP8.Pages.Campusmap #endregion + private void ZoomIn_Tap(object sender, System.Windows.Input.GestureEventArgs e) + { + throw new NotImplementedException("TODO"); + } + + private void ZoomOut_Tap(object sender, System.Windows.Input.GestureEventArgs e) + { + throw new NotImplementedException("TODO"); + } + #endregion } } \ No newline at end of file From 91c90bce28ccc41b97cca894bdcab4afc57a6db6 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Fri, 15 Nov 2013 14:57:08 +0100 Subject: [PATCH 17/22] done, but not final --- .../Pages/Campusmap/RoomListPage.xaml.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml.cs index 074b1529..69fb12ef 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Campusmap/RoomListPage.xaml.cs @@ -420,14 +420,26 @@ 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"); + //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"); + //throw new NotImplementedException("TODO"); + (this.MapCanvas.RenderTransform as ScaleTransform).ScaleX /= 1.5; + (this.MapCanvas.RenderTransform as ScaleTransform).ScaleY /= 1.5; } #endregion From 940718e805b062890361f1cc33f6bc9d16155bda Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Fri, 15 Nov 2013 17:34:42 +0100 Subject: [PATCH 18/22] intermediat commit --- .../CampusAppWP8/Pages/StartPage.xaml | 1 + .../CampusAppWP8/Pages/StartPage.xaml.cs | 33 +++++++++++++++++-- .../Pages/TimeTable/AppointmentEdit.xaml.cs | 9 +++++ .../CampusAppWP8/Resources/Constants.resx | 3 ++ .../Resources/Constants1.Designer.cs | 9 +++++ 5 files changed, 52 insertions(+), 3 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml index 2203c800..99b2348a 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml @@ -277,6 +277,7 @@ + diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs index dde76ad0..a89a5840 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs @@ -419,6 +419,8 @@ namespace CampusAppWP8.Pages } else { + this.GoToAppointment(nfcContent); + /* removed for testing if (AppSettings.BTUTagDefaultHandler.CampusMap == Settings.AppSetting.TagDefaultHandler) { // search for placeId @@ -435,6 +437,7 @@ namespace CampusAppWP8.Pages this.ShowBtuTagMessageBox(); } } + */ } this.ndefId = this.device.SubscribeForMessage(Constants.NCFMessageType_NDEF, this.NDEFHandler); @@ -446,9 +449,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) { @@ -483,5 +504,11 @@ namespace CampusAppWP8.Pages } #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/AppointmentEdit.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs index ec213f5b..5103f340 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs @@ -24,6 +24,8 @@ namespace CampusAppWP8.Pages.TimeTable public partial class AppointmentEdit : PortraitLandscapePage { + //private Place + 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" }; @@ -61,8 +63,10 @@ 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); @@ -89,6 +93,11 @@ 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; + this.InLocation.Text = pid; + } else { this.HeadLine.Text = AppResources.Creating; diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 7db93ad9..45f447f5 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -597,4 +597,7 @@ Appointments.xaml + + pid + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs index 7e7836cf..708bb57c 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs @@ -717,6 +717,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. /// From 03b60a40ffd382d32a586944dbe28b37b3b09b25 Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Fri, 15 Nov 2013 18:17:02 +0100 Subject: [PATCH 19/22] nearly done #270 --- .../Pages/TimeTable/AppointmentEdit.xaml.cs | 44 ++++++++++++++++++- .../CampusAppWP8/Resources/Constants.resx | 3 ++ .../Resources/Constants1.Designer.cs | 9 ++++ 3 files changed, 54 insertions(+), 2 deletions(-) diff --git a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs index 5103f340..952a1922 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/TimeTable/AppointmentEdit.xaml.cs @@ -16,6 +16,7 @@ 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; @@ -24,7 +25,7 @@ namespace CampusAppWP8.Pages.TimeTable public partial class AppointmentEdit : PortraitLandscapePage { - //private Place + 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" }; @@ -44,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; @@ -96,7 +102,33 @@ namespace CampusAppWP8.Pages.TimeTable else if(NavigationContext.QueryString.TryGetValue(Constants.ParamPID, out pid)) { this.HeadLine.Text = AppResources.Creating; - this.InLocation.Text = pid; + 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 { @@ -104,6 +136,14 @@ namespace CampusAppWP8.Pages.TimeTable } } + private void PlaceFileIsReady() + { + } + + private void PlaceFileIsFailed() + { + } + private void OnClickSaveBtn(object sender, EventArgs e) { AppointmentModel newItem = new AppointmentModel(); diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 45f447f5..5d487472 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -600,4 +600,7 @@ pid + + Raumnummer + \ No newline at end of file diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs index 708bb57c..cdd89127 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants1.Designer.cs @@ -1194,6 +1194,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. /// From 6e5d7c308c0276e8d02cfd7a45666b4a2838f5d7 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Mon, 18 Nov 2013 13:06:59 +0100 Subject: [PATCH 20/22] add accuracy paramter and save command --- CampusAppWP8/CampusAppWP8/App.xaml.cs | 9 +++++- .../CampusAppWP8/Pages/StartPage.xaml.cs | 9 +++++- .../Utility/MealIdToPriceConverter.cs | 8 +++-- .../CampusAppWP8/Utility/Utilities.cs | 29 ++++++++++++------- 4 files changed, 41 insertions(+), 14 deletions(-) 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/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs index e6daa710..27858c92 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs @@ -307,7 +307,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 +316,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. diff --git a/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs index dad09bf1..73caa561 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/MealIdToPriceConverter.cs @@ -63,8 +63,11 @@ namespace CampusAppWP8.Utility if ((intVal >= 0) && (intParam >= 0)) { - PriceMealModel model = this.priceFeed.Model.GetCanteen(intParam).GetPriceMealModel(intVal); - retValue = AppResources.Students + ": " + model.PriceStudentStr + " € " + AppResources.Employees + ": " + model.PriceEmployeeStr + " € " + AppResources.Guests + ": " + model.PriceGuestStr + " €"; + 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; @@ -85,6 +88,7 @@ namespace CampusAppWP8.Utility /// Fiedler, 14.11.2013. private void PriceFeedIsReady() { + this.priceFeed.SaveData(); } /// Price feed is failed. 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; From b139e9e0e315cc5408c631fce4fe0fff84b3cc30 Mon Sep 17 00:00:00 2001 From: stubbfel Date: Mon, 18 Nov 2013 15:41:35 +0100 Subject: [PATCH 21/22] new copyfunction and guifixes (mensapige) --- .../CampusAppWP8/Feed/Mensa/MensaFeed.cs | 89 +++++++++++++++++ .../Feed/Mensa/MensaFeedCBMain.cs | 1 + .../Feed/Mensa/MensaFeedCBNorth.cs | 1 + .../Feed/Mensa/MensaFeedCBSouth.cs | 1 + .../Feed/Mensa/MensaFeedSBFMain.cs | 1 + .../CampusAppWP8/Pages/Mensa/MensaPage.xaml | 16 ++- .../Pages/Mensa/MensaPage.xaml.cs | 99 +++++++++++++++++-- .../Resources/AppResources.Designer.cs | 27 +++++ .../CampusAppWP8/Resources/AppResources.resx | 9 ++ .../Model/Mensa/MealModel.cs | 4 + .../Model/Mensa/PriceModel.cs | 17 +++- 11 files changed, 247 insertions(+), 18 deletions(-) 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/Pages/Mensa/MensaPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml index 3b83b591..ea1339ba 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml @@ -19,11 +19,7 @@ SupportedOrientations="PortraitOrLandscape" Orientation="Portrait" shell:SystemTray.IsVisible="True" x:Name="root"> - - - - - + @@ -33,7 +29,7 @@ - + @@ -56,7 +52,7 @@ - + @@ -71,8 +67,7 @@ - - + @@ -96,6 +91,9 @@ + + + diff --git a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs index 8952c549..e837fc79 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/Mensa/MensaPage.xaml.cs @@ -65,6 +65,8 @@ namespace CampusAppWP8.Pages.Mensa 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) { @@ -81,6 +83,16 @@ 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; } @@ -185,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. @@ -234,6 +246,7 @@ namespace CampusAppWP8.Pages.Mensa /// Stubbfel, 15.10.2013. private void FeedIsReady() { + this.feed.SetPrices(); this.SetupMensaPivot(); this.DefHeader.ProgressVisibility = Visibility.Collapsed; } @@ -404,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/Resources/AppResources.Designer.cs b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs index 5ab45237..c58ee146 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.Designer.cs @@ -276,6 +276,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. /// @@ -744,6 +753,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. /// @@ -762,6 +780,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. /// diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 9297b6cd..f21e5f63 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -605,4 +605,13 @@ Studenten + + Kopieren + + + Tagesplan + + + Wochenplan + \ No newline at end of file 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/PriceModel.cs b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs index 3a62b506..5630e72a 100644 --- a/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs +++ b/CampusAppWP8/CampusAppWPortalLib8/Model/Mensa/PriceModel.cs @@ -8,6 +8,7 @@ //----------------------------------------------------------------------- namespace CampusAppWPortalLib8.Model.Mensa { + using CampusAppWPortalLib8.Model.Settings; using System.Collections.ObjectModel; using System.Xml.Serialization; @@ -51,15 +52,25 @@ namespace CampusAppWPortalLib8.Model.Mensa { PriceCanteenModel retValue = null; - for (int i = 0; i < this.canteens.Count; i++) + foreach (PriceCanteenModel prize in this.canteens) { - if (this.canteens[i].Id.Equals(id)) + if (prize.Id == id) { - retValue = this.canteens[i]; + 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 From cf56df35d3a0373e695a944540590ac6aaa02edc Mon Sep 17 00:00:00 2001 From: Christian Fiedler Date: Mon, 18 Nov 2013 16:08:05 +0100 Subject: [PATCH 22/22] merged with develop --- CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj | 3 ++- CampusAppWP8/CampusAppWP8/Resources/AppResources.resx | 1 + CampusAppWP8/CampusAppWP8/Resources/Constants.resx | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj index fefe0d7d..00e17b16 100644 --- a/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj +++ b/CampusAppWP8/CampusAppWP8/CampusAppWP8.csproj @@ -255,6 +255,7 @@ AppointmentCanvas.xaml + MultiValueTextBlock.xaml @@ -541,7 +542,7 @@ Designer MSBuild:Compile - + Designer MSBuild:Compile diff --git a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx index 6bdddefb..4d494990 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/AppResources.resx @@ -598,6 +598,7 @@ KW + Angestellte diff --git a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx index 28a28b70..a7a62d34 100644 --- a/CampusAppWP8/CampusAppWP8/Resources/Constants.resx +++ b/CampusAppWP8/CampusAppWP8/Resources/Constants.resx @@ -602,6 +602,7 @@ Raumnummer + mensaprice.xml