This commit is contained in:
Christian Fiedler
2013-11-25 14:14:03 +01:00
parent 1589220445
commit edefc17879
2 changed files with 71 additions and 7 deletions

View File

@@ -22,15 +22,24 @@ namespace CampusAppWP8.Pages.TimeTable
using CampusAppWP8.Model.TimeTable;
using CampusAppWP8.Resources;
/// <summary> A time table day. </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
/// <seealso cref="T:Microsoft.Phone.Controls.PhoneApplicationPage"/>
public partial class TimeTableDay : PhoneApplicationPage
{
/// <summary> The pivot item pages. </summary>
private static readonly int PIVOT_ITEM_PAGES = 5;
/// <summary> The pivot item pages half down. </summary>
private static readonly int PIVOT_ITEM_PAGES_HALF_DOWN = 2;
/// <summary> List of items. </summary>
private ObservableCollection<DayViewPageItem> itemList = new ObservableCollection<DayViewPageItem>();
/// <summary> Zero-based index of the last selected. </summary>
private int lastSelectedIndex = 0;
/// <summary> Initializes a new instance of the TimeTableDay class. </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
public TimeTableDay()
{
this.InitializeComponent();
@@ -73,6 +82,9 @@ namespace CampusAppWP8.Pages.TimeTable
ApplicationBar.Buttons.Add(addBtn);
}
/// <summary> Wird aufgerufen, wenn eine Seite die aktive Seite in einem Frame wird. </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
/// <seealso cref="M:System.Windows.Controls.Page.OnNavigatedTo(NavigationEventArgs)"/>
protected override void OnNavigatedTo(NavigationEventArgs e)
{
base.OnNavigatedTo(e);
@@ -91,6 +103,29 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
/// <summary>
/// Wird aufgerufen, wenn eine Seite nicht mehr die aktive Seite in einem Frame ist.
/// </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
/// <seealso cref="M:System.Windows.Controls.Page.OnNavigatedFrom(NavigationEventArgs)"/>
protected override void OnNavigatedFrom(NavigationEventArgs e)
{
base.OnNavigatedFrom(e);
List<JournalEntry> backStack = new List<JournalEntry>(NavigationService.BackStack);
if (backStack.Count > 0
&& backStack[0].Source.OriginalString.Contains(Constants.PathTimeTable_Day)
&& e.Uri.OriginalString.Contains(Constants.PathTimeTable_Week))
{
NavigationService.RemoveBackEntry();
}
}
/// <summary> Event pivot selection changed. </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
/// <param name="sender"> Source of the event. </param>
/// <param name="e"> Selection changed event information. </param>
private void EventPivotSelectionChanged(object sender, SelectionChangedEventArgs e)
{
int indexToChange = 0;
@@ -122,6 +157,9 @@ namespace CampusAppWP8.Pages.TimeTable
this.lastSelectedIndex = this.ThePivot.SelectedIndex;
}
/// <summary> Executes the appointment click action. </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
/// <param name="model"> The model. </param>
private void OnAppointmentClick(AppointmentModel model)
{
int index = TimeTable.Feed.Model.Appointments.IndexOf(model);
@@ -138,6 +176,10 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
/// <summary> Raises the click week event. </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
/// <param name="sender"> Source of the event. </param>
/// <param name="e"> Event information to send to registered event handlers. </param>
private void OnClickWeek(object sender, EventArgs e)
{
Uri url = new Uri(Constants.PathTimeTable_Week, UriKind.Relative);
@@ -145,6 +187,10 @@ namespace CampusAppWP8.Pages.TimeTable
page.NavigationService.Navigate(url);
}
/// <summary> Raises the click to day event. </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
/// <param name="sender"> Source of the event. </param>
/// <param name="e"> Event information to send to registered event handlers. </param>
private void OnClickToDay(object sender, EventArgs e)
{
int index = -1;
@@ -179,6 +225,10 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
/// <summary> Raises the click properties event. </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
/// <param name="sender"> Source of the event. </param>
/// <param name="e"> Event information to send to registered event handlers. </param>
private void OnClickProperties(object sender, EventArgs e)
{
Uri url = new Uri(Constants.PathTimeTable_Properties, UriKind.Relative);
@@ -186,6 +236,10 @@ namespace CampusAppWP8.Pages.TimeTable
page.NavigationService.Navigate(url);
}
/// <summary> Raises the click add event. </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
/// <param name="sender"> Source of the event. </param>
/// <param name="e"> Event information to send to registered event handlers. </param>
private void OnClickAdd(object sender, EventArgs e)
{
TimeTable.Feed.Model.Appointments.CollectionChanged += this.OnListChanged;
@@ -195,6 +249,10 @@ namespace CampusAppWP8.Pages.TimeTable
page.NavigationService.Navigate(url);
}
/// <summary> Raises the notify collection changed event. </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
/// <param name="sender"> Source of the event. </param>
/// <param name="e"> Event information to send to registered event handlers. </param>
private void OnListChanged(object sender, NotifyCollectionChangedEventArgs e)
{
if (e.Action == NotifyCollectionChangedAction.Add)
@@ -236,6 +294,9 @@ namespace CampusAppWP8.Pages.TimeTable
}
}
/// <summary> Check appointments. </summary>
/// <remarks> Fiedler, 25.11.2013. </remarks>
/// <param name="index"> (Optional) zero-based index of the. </param>
private void CheckAppointments(int index = -1)
{
if (index < 0)

View File

@@ -98,12 +98,6 @@ namespace CampusAppWP8.Pages.TimeTable
}
else
{
//List<JournalEntry> backStack = NavigationService.BackStack;
List<JournalEntry> backStack = new List<JournalEntry>(NavigationService.BackStack);
JournalEntry entry = backStack[0];
Console.Write(entry.ToString());
this.ThePivot.ItemsSource = this.itemList;
this.lastSelectedIndex = PIVOT_PAGES_HALF_DOWN;
this.ThePivot.SelectedIndex = PIVOT_PAGES_HALF_DOWN;
@@ -121,6 +115,15 @@ namespace CampusAppWP8.Pages.TimeTable
{
base.OnNavigatedFrom(e);
List<JournalEntry> backStack = new List<JournalEntry>(NavigationService.BackStack);
if (backStack.Count > 0
&& backStack[0].Source.OriginalString.Contains(Constants.PathTimeTable_Week)
&& e.Uri.OriginalString.Contains(Constants.PathTimeTable_Day))
{
NavigationService.RemoveBackEntry();
}
TimeTable.Feed.SaveData();
}