@@ -134,6 +134,11 @@ namespace CampusAppWP8.Pages.Departments
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
|
||||
if (this.Orientation.Equals(PageOrientation.Landscape) || this.Orientation.Equals(PageOrientation.LandscapeLeft) || this.Orientation.Equals(PageOrientation.LandscapeRight))
|
||||
{
|
||||
ApplicationBar.Mode = Microsoft.Phone.Shell.ApplicationBarMode.Default;
|
||||
}
|
||||
|
||||
if (NavigationContext.QueryString.ContainsKey(Constants.ParamRemoveBack))
|
||||
{
|
||||
if (NavigationContext.QueryString[Constants.ParamRemoveBack].Equals("true")) {
|
||||
@@ -168,6 +173,14 @@ namespace CampusAppWP8.Pages.Departments
|
||||
/// <param name="e">event args</param>
|
||||
private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
|
||||
{
|
||||
if (e.Orientation.Equals(PageOrientation.Landscape) || e.Orientation.Equals(PageOrientation.LandscapeLeft) || e.Orientation.Equals(PageOrientation.LandscapeRight))
|
||||
{
|
||||
ApplicationBar.Mode = Microsoft.Phone.Shell.ApplicationBarMode.Default;
|
||||
}
|
||||
else
|
||||
{
|
||||
ApplicationBar.Mode = Microsoft.Phone.Shell.ApplicationBarMode.Minimized;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
</phone:Pivot.HeaderTemplate>
|
||||
<phone:Pivot.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<ListBox ItemsSource="{Binding Chairs}">
|
||||
<ListBox ItemsSource="{Binding Chairs}" Loaded="OnListBoxLoaded">
|
||||
<ListBox.ItemContainerStyle>
|
||||
<Style TargetType="ListBoxItem">
|
||||
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
|
||||
|
||||
@@ -23,20 +23,13 @@ namespace CampusAppWP8.Pages.Departments
|
||||
{
|
||||
#region Member
|
||||
|
||||
/// <summary>
|
||||
/// For checking, if the source of the list is already set.
|
||||
/// </summary>
|
||||
private bool isSourceSet = false;
|
||||
|
||||
/// <summary>
|
||||
/// Last clicked button object.
|
||||
/// </summary>
|
||||
private FrameworkElement lastClickedBtn = null;
|
||||
|
||||
/// <summary>
|
||||
/// For checking of the instance is back from tombstone.
|
||||
/// </summary>
|
||||
private bool isNewInstance = false;
|
||||
/// <summary> Index of the pivot. </summary>
|
||||
int pivotIndex = 0;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -49,7 +42,7 @@ namespace CampusAppWP8.Pages.Departments
|
||||
{
|
||||
this.InitializeComponent();
|
||||
|
||||
this.isNewInstance = true;
|
||||
this.DefHeader.ProgressVisibility = Visibility.Visible;
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -66,54 +59,17 @@ namespace CampusAppWP8.Pages.Departments
|
||||
protected override void OnNavigatedTo(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedTo(e);
|
||||
this.DefHeader.ProgressVisibility = Visibility.Visible;
|
||||
|
||||
if (this.isNewInstance)
|
||||
{
|
||||
if ((DepartmentIndexPage.Feed == null) || (DepartmentIndexPage.Feed.Model == null))
|
||||
{
|
||||
DepartmentModel tempModel = null;
|
||||
|
||||
if ((tempModel = App.LoadFromIsolatedStorage<DepartmentModel>(Constants.IsolatedStorage_DepartmentModel)) != null)
|
||||
{
|
||||
if (DepartmentIndexPage.Feed == null)
|
||||
{
|
||||
DepartmentIndexPage.Feed = new Feed.Departments.DepartmentFeed(false);
|
||||
}
|
||||
|
||||
DepartmentIndexPage.Feed.Model = tempModel;
|
||||
this.isSourceSet = false;
|
||||
}
|
||||
}
|
||||
|
||||
this.isNewInstance = false;
|
||||
}
|
||||
|
||||
if (this.isSourceSet == false)
|
||||
{
|
||||
this.DepartmentPivot.ItemsSource = DepartmentIndexPage.GetFeed().Model.Faculties;
|
||||
this.isSourceSet = true;
|
||||
}
|
||||
|
||||
string pivotIndex = string.Empty;
|
||||
|
||||
string pivotIndexStr = string.Empty;
|
||||
|
||||
// Navigate to the selected pivotitem
|
||||
if (NavigationContext.QueryString.TryGetValue("pivotindex", out pivotIndex))
|
||||
|
||||
if (NavigationContext.QueryString.TryGetValue("pivotindex", out pivotIndexStr))
|
||||
{
|
||||
int pivotIndexInt = int.Parse(pivotIndex) - 1;
|
||||
|
||||
// if the index is in the range of the array
|
||||
if ((pivotIndexInt >= 0) && (pivotIndexInt < DepartmentIndexPage.GetFeed().Model.Faculties.Count()))
|
||||
{
|
||||
DepartmentPivot.SelectedIndex = pivotIndexInt;
|
||||
}
|
||||
else
|
||||
{
|
||||
MessageBox.Show("ERROR: pivotIndex out of range!!!");
|
||||
}
|
||||
this.pivotIndex = int.Parse(pivotIndexStr) - 1;
|
||||
}
|
||||
|
||||
this.DefHeader.ProgressVisibility = Visibility.Collapsed;
|
||||
|
||||
DepartmentIndexPage.InitFeed(this.SetPivotSource);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -123,17 +79,44 @@ namespace CampusAppWP8.Pages.Departments
|
||||
protected override void OnNavigatedFrom(NavigationEventArgs e)
|
||||
{
|
||||
base.OnNavigatedFrom(e);
|
||||
|
||||
if (e.NavigationMode != System.Windows.Navigation.NavigationMode.Back)
|
||||
{
|
||||
App.SaveToIsolatedStorage<DepartmentModel>(Constants.IsolatedStorage_DepartmentModel, DepartmentIndexPage.Feed.Model);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region private
|
||||
|
||||
/// <summary> Sets pivot source.</summary>
|
||||
/// <remarks> Fiedler, 15.10.2013. </remarks>
|
||||
private void SetPivotSource()
|
||||
{
|
||||
if (this.pivotIndex >= 0 && this.pivotIndex < DepartmentIndexPage.Feed.Model.Faculties.Count())
|
||||
{
|
||||
this.DepartmentPivot.LoadedPivotItem += new EventHandler<PivotItemEventArgs>(this.OnLoadedPivotItems);
|
||||
|
||||
if (this.DepartmentPivot.ItemsSource == null)
|
||||
{
|
||||
this.DepartmentPivot.ItemsSource = DepartmentIndexPage.Feed.Model.Faculties;
|
||||
}
|
||||
|
||||
this.DepartmentPivot.SelectedIndex = this.pivotIndex;
|
||||
}
|
||||
else
|
||||
{
|
||||
Utility.Lui.MessageBoxes.MessageBoxes.ShowMainModelErrorMessageBox("pivot index out of bound (0 < " + this.pivotIndex + " < " + DepartmentIndexPage.Feed.Model.Faculties.Count() + ")");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnListBoxLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
this.DefHeader.ProgressVisibility = Visibility.Collapsed;
|
||||
}
|
||||
|
||||
private void OnLoadedPivotItems(object sender, PivotItemEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// On orientation changed.
|
||||
/// </summary>
|
||||
|
||||
@@ -146,7 +146,7 @@ namespace CampusAppWP8.Pages.Openinghours
|
||||
this.InstitutionPanel.ItemsSource = this.feed.Model.Institutions;
|
||||
this.DefHeader.ProgressVisibility = Visibility.Collapsed;
|
||||
|
||||
// this.feed.SaveData(true);
|
||||
this.feed.SaveData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -72,6 +72,7 @@ namespace CampusAppWPortalLib8.Model.RSS
|
||||
select elem;
|
||||
|
||||
this.item = new ObservableCollection<RSSModel>(sortedOC);
|
||||
this.FixIndex();
|
||||
this.item.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged);
|
||||
}
|
||||
else
|
||||
@@ -81,6 +82,7 @@ namespace CampusAppWPortalLib8.Model.RSS
|
||||
select elem;
|
||||
|
||||
this.item = new ObservableCollection<RSSModel>(sortedOC);
|
||||
this.FixIndex();
|
||||
this.item.CollectionChanged += new NotifyCollectionChangedEventHandler(this.OnListChanged);
|
||||
}
|
||||
}
|
||||
@@ -102,6 +104,16 @@ namespace CampusAppWPortalLib8.Model.RSS
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Fixes the index property of the items.</summary>
|
||||
/// <remarks>Fiedler, 15.10.2013.</remarks>
|
||||
private void FixIndex()
|
||||
{
|
||||
for (int i = 0; i < this.item.Count(); i++)
|
||||
{
|
||||
this.item[i].Index = i;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user