Skip to content

Commit

Permalink
Merge pull request MoSync#188 from ciprif/ThreeOne
Browse files Browse the repository at this point in the history
Three one
  • Loading branch information
Anders Malm committed Jun 19, 2012
2 parents 35ad96b + 2ec543b commit 9b1e118
Showing 1 changed file with 30 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,30 +52,18 @@ public PanoramaView()
Grid.SetColumn(mPanorama, 0);
Grid.SetRow(mPanorama, 0);

mPanorama.Loaded += new RoutedEventHandler(
delegate(object from, RoutedEventArgs args)
{
SetApplicationBarVisibility(0);
});

//The application bar is chanded at the SelectionChanged event occurence.
//This allows the user to have more that one application bar / panorama view
mPanorama.SelectionChanged += new EventHandler<SelectionChangedEventArgs>(
delegate(object from, SelectionChangedEventArgs target)
{
bool appBarVisible = (this.mChildren[(from as Microsoft.Phone.Controls.Panorama).SelectedIndex] as Screen).GetApplicationBarVisibility();
if (appBarVisible)
{
mApplicationBar = (this.mChildren[(from as Microsoft.Phone.Controls.Panorama).SelectedIndex] as Screen).GetApplicationBar();
mApplicationBar.IsVisible = true;
((Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Content as
Microsoft.Phone.Controls.PhoneApplicationPage).ApplicationBar = mApplicationBar;
this.SetApplicationBarVisibility(true);
}
else
{
this.SetApplicationBarVisibility(false);
if (((Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Content as
Microsoft.Phone.Controls.PhoneApplicationPage).ApplicationBar != null)
{
((Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Content as
Microsoft.Phone.Controls.PhoneApplicationPage).ApplicationBar.IsVisible = false;
}
}
SetApplicationBarVisibility((from as Microsoft.Phone.Controls.Panorama).SelectedIndex);
});
}

Expand Down Expand Up @@ -217,6 +205,29 @@ public IScreen getSelectedScreen()
{
return mChildren[mPanorama.SelectedIndex] as IScreen;
}

private void SetApplicationBarVisibility(int screenIndex)
{
bool appBarVisible = (this.mChildren[screenIndex] as Screen).GetApplicationBarVisibility();
if (appBarVisible)
{
mApplicationBar = (this.mChildren[screenIndex] as Screen).GetApplicationBar();
mApplicationBar.IsVisible = true;
((Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Content as
Microsoft.Phone.Controls.PhoneApplicationPage).ApplicationBar = mApplicationBar;
this.SetApplicationBarVisibility(true);
}
else
{
this.SetApplicationBarVisibility(false);
if (((Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Content as
Microsoft.Phone.Controls.PhoneApplicationPage).ApplicationBar != null)
{
((Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame).Content as
Microsoft.Phone.Controls.PhoneApplicationPage).ApplicationBar.IsVisible = false;
}
}
}
}
}
}

0 comments on commit 9b1e118

Please sign in to comment.