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++)