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; + + + } } }