diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml index a022cd2e..d6f646de 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml @@ -13,7 +13,6 @@ FontSize="{StaticResource PhoneFontSizeNormal}" Foreground="{StaticResource PhoneForegroundBrush}" SupportedOrientations="PortraitOrLandscape" Orientation="Portrait" - OrientationChanged="PhoneApplicationPage_OrientationChanged" mc:Ignorable="d" shell:SystemTray.IsVisible="True"> @@ -270,7 +269,7 @@ - + diff --git a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs index bed4dfcf..2c29cf78 100644 --- a/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs +++ b/CampusAppWP8/CampusAppWP8/Pages/StartPage.xaml.cs @@ -39,9 +39,6 @@ namespace CampusAppWP8.Pages /// List of initialise courses. private CourseFeed initCourseList; - /// The previous orientation. - private PageOrientation prevOrientation; - /// Identifier for the ndef. private long ndefId; @@ -121,15 +118,6 @@ namespace CampusAppWP8.Pages protected override void OnNavigatedTo(NavigationEventArgs e) { base.OnNavigatedTo(e); - if (this.Orientation.Equals(PageOrientation.PortraitUp) || this.Orientation.Equals(PageOrientation.PortraitDown) || this.Orientation.Equals(PageOrientation.Portrait)) - { - this.prevOrientation = PageOrientation.Portrait; - } - else - { - this.prevOrientation = PageOrientation.Landscape; - } - this.ndefId = this.device.SubscribeForMessage(Constants.NCFMessageType_NDEF, this.NDEFHandler); } @@ -162,50 +150,19 @@ namespace CampusAppWP8.Pages this.initCourseList.SaveData(); } - /// Method handle OrientationPage. - /// Stubbfel, 15.10.2013. - /// Caller of the function. - /// some EventArgs. - private void PhoneApplicationPage_OrientationChanged(object sender, OrientationChangedEventArgs e) + /// Raises the orientation changed event. + /// Fiedler, 22.10.2013. + /// + /// ### Event information to send to registered event handlers. + protected override void OnSwitchedToPortrait(OrientationChangedEventArgs e) { - // Switch the placement of the buttons based on an orientation change. - if (this.Orientation.Equals(PageOrientation.LandscapeLeft)) - { - this.ContentPanel.Margin = new Thickness(24, -24, 76, 0); - this.AppTitle.Margin = new Thickness(12, 17, 0, 28); - if (!this.prevOrientation.Equals(PageOrientation.Landscape)) - { - this.MoveGridToLandscape(); - this.prevOrientation = PageOrientation.Landscape; - } - } - else if (this.Orientation.Equals(PageOrientation.LandscapeRight)) - { - this.ContentPanel.Margin = new Thickness(76, -24, 24, 0); - this.AppTitle.Margin = new Thickness(64, 17, 0, 28); - if (!this.prevOrientation.Equals(PageOrientation.Landscape)) - { - this.MoveGridToLandscape(); - this.prevOrientation = PageOrientation.Landscape; - } - } - else - { - this.ContentPanel.Margin = new Thickness(12, 0, 12, 12); - this.AppTitle.Margin = new Thickness(12, 17, 0, 28); + base.OnSwitchedToPortrait(e); - if (!this.prevOrientation.Equals(PageOrientation.Portrait)) - { - this.MoveToPortrait(); - this.prevOrientation = PageOrientation.Portrait; - } - } - } + this.ApplicationBar.Opacity = 0.5; + + //this.ContentPanel.Margin = new Thickness(12, 0, 12, 12); + //this.AppTitle.Margin = new Thickness(12, 17, 0, 28); - /// Move to Portrait format. - /// Stubbfel, 27.08.2013. - private void MoveToPortrait() - { if (!this.Row0.Children.Contains(this.MailAppButton) && !this.Row1.Children.Contains(this.OpenHoursAppButton) && !this.Row2.Children.Contains(this.LinkAppButton)) @@ -226,10 +183,20 @@ namespace CampusAppWP8.Pages this.LinkAppButton.SetValue(Grid.ColumnProperty, 2); } - /// Move Grid to landscape format. - /// Stubbfel, 27.08.2013. - private void MoveGridToLandscape() + /// Raises the orientation changed event. + /// Fiedler, 22.10.2013. + /// + /// ### Event information to send to registered event handlers. + protected override void OnSwitchedToLandscape(OrientationChangedEventArgs e) { + base.OnSwitchedToLandscape(e); + + this.ApplicationBar.Opacity = 1.0; + + //this.ContentPanel.Margin = new Thickness(76, -24, 24, 0); // LandscapeRight + //this.ContentPanel.Margin = new Thickness(24, -24, 76, 0); // LandscapeLeft + //this.AppTitle.Margin = new Thickness(12, 17, 0, 28); + if (!this.Row3.Children.Contains(this.MailAppButton) && !this.Row3.Children.Contains(this.OpenHoursAppButton) && !this.Row3.Children.Contains(this.LinkAppButton)) diff --git a/CampusAppWP8/CampusAppWP8/Utility/PortraitLandscapePage.cs b/CampusAppWP8/CampusAppWP8/Utility/PortraitLandscapePage.cs index 5d962215..c19837e4 100644 --- a/CampusAppWP8/CampusAppWP8/Utility/PortraitLandscapePage.cs +++ b/CampusAppWP8/CampusAppWP8/Utility/PortraitLandscapePage.cs @@ -19,7 +19,12 @@ namespace CampusAppWP8.Utility { /// The default application bar mode. private ApplicationBarMode defaultApplicationBarMode; + /// true if this object is default mode set. private bool isDefaultModeSet = false; + /// The last orientation. + private PageOrientation lastOrientation; + /// true to suppress application bar mode change. + private bool suppressApplicationBarModeChange = false; /// Initializes a new instance of the PortraitLandscapePage class. /// Fiedler, 21.10.2013. @@ -27,6 +32,14 @@ namespace CampusAppWP8.Utility { } + /// Sets suppress mode. + /// Fiedler, 22.10.2013. + /// the suppress. + protected void SetSuppressMode(bool suppress) + { + this.suppressApplicationBarModeChange = suppress; + } + /// Wird aufgerufen, wenn eine Seite die aktive Seite in einem Frame wird. /// Fiedler, 21.10.2013. /// @@ -40,7 +53,16 @@ namespace CampusAppWP8.Utility base.OnNavigatedTo(e); - if (this.ApplicationBar != null) + if (this.Orientation.Equals(PageOrientation.Landscape) || this.Orientation.Equals(PageOrientation.LandscapeLeft) || this.Orientation.Equals(PageOrientation.LandscapeRight)) + { + this.lastOrientation = PageOrientation.Landscape; + } + else + { + this.lastOrientation = PageOrientation.Portrait; + } + + if (this.ApplicationBar != null && this.suppressApplicationBarModeChange == false) { if (this.Orientation.Equals(PageOrientation.Landscape) || this.Orientation.Equals(PageOrientation.LandscapeLeft) || this.Orientation.Equals(PageOrientation.LandscapeRight)) { @@ -54,24 +76,40 @@ namespace CampusAppWP8.Utility /// protected override void OnOrientationChanged(OrientationChangedEventArgs e) { - if (this.ApplicationBar != null) + if (this.ApplicationBar != null && this.suppressApplicationBarModeChange == false) { if (this.defaultApplicationBarMode.Equals(ApplicationBarMode.Minimized)) { if (e.Orientation.Equals(PageOrientation.Landscape) || e.Orientation.Equals(PageOrientation.LandscapeLeft) || e.Orientation.Equals(PageOrientation.LandscapeRight)) { this.ApplicationBar.Mode = ApplicationBarMode.Default; - this.OnSwitchedToLandscape(e); } else { this.ApplicationBar.Mode = ApplicationBarMode.Minimized; - this.OnSwitchedToPortrait(e); } - } } + if (e.Orientation.Equals(PageOrientation.Landscape) || e.Orientation.Equals(PageOrientation.LandscapeLeft) || e.Orientation.Equals(PageOrientation.LandscapeRight)) + { + if (this.lastOrientation.Equals(PageOrientation.Portrait)) + { + this.OnSwitchedToLandscape(e); + } + + this.lastOrientation = PageOrientation.Landscape; + } + else + { + if (this.lastOrientation.Equals(PageOrientation.Landscape)) + { + this.OnSwitchedToPortrait(e); + } + + this.lastOrientation = PageOrientation.Portrait; + } + base.OnOrientationChanged(e); }