private void auth_Completed(object sender, global::Xamarin.Auth._MobileServices.AuthenticatorCompletedEventArgs e) { if (e.IsAuthenticated) { // e.Account contains info: // e.AccountProperties[""] // // use access tokenmore detailed user info from the API this.AccountProperties = e.Account.Properties; } else { // The user cancelled } // dismiss UI on iOS, because it was manually created //DismissViewController(true, null); // possibly do something to dismiss THIS viewcontroller, // or else login screen does not disappear var rv = System.Windows.Application.Current.RootVisual; Microsoft.Phone.Controls.PhoneApplicationFrame paf = null; paf = rv as Microsoft.Phone.Controls.PhoneApplicationFrame; //paf.GoBack(); return; }
private void Login(HolisticWare.Auth.OAuth1 oauth1) { global::Xamarin.Auth._MobileServices.OAuth1Authenticator auth = new global::Xamarin.Auth._MobileServices.OAuth1Authenticator ( consumerKey: oauth1.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer, consumerSecret: oauth1.OAuth1_SecretKey_ConsumerSecret_APISecret, requestTokenUrl: oauth1.OAuth1_UriRequestToken, authorizeUrl: oauth1.OAuth_UriAuthorization, accessTokenUrl: oauth1.OAuth1_UriAccessToken, callbackUrl: oauth1.OAuth_UriCallbackAKARedirect, getUsernameAsync: null ); auth.Completed += auth_Completed; //PresentViewController (auth.GetUI (), true, null); Uri uri = auth.GetUI(); var rv = System.Windows.Application.Current.RootVisual; Microsoft.Phone.Controls.PhoneApplicationFrame paf = null; paf = rv as Microsoft.Phone.Controls.PhoneApplicationFrame; paf.Navigate(uri); return; }
public GameViewModel(CardDeck SelectedDeck) { _selectedDeck = SelectedDeck; Quit = new DelegateCommand(() => { #if !SILVERLIGHT Application.Current.Shutdown(); #endif }); Cancel = new DelegateCommand(() => { #if !WINDOWS_PHONE MainViewModel.Instance.CurrentView = MainViewModel.Instance.Decks; #else Microsoft.Phone.Controls.PhoneApplicationFrame frame = Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame; frame.GoBack(); #endif #if !SILVERLIGHT Taskbar.UpdateTaskBarStatus(0, SelectedDeck.Count / 2); #endif }); HelpCommand = new DelegateCommand(() => { #if !SILVERLIGHT MessageBox.Show((string)Application.Current.FindResource("Resource_MessageBox_ShowHelp")); #endif }); }
public InfoLinkDecal() { MetaData = new InfoLinkMetaData() { Source = "http://" }; Stretch = System.Windows.Media.Stretch.Uniform; Size = 1; CanResize = false; Stretch = System.Windows.Media.Stretch.None; Center = new System.Windows.Point(1, 1); PinPoint = new System.Windows.Point(1, 1); CanMove = false; OpenUrl = new DelegateCommand(() => { if (!MetaData.Source.StartsWith("http://")) { MetaData.Source = "http://" + MetaData.Source; } #if WINDOWS_PHONE Microsoft.Phone.Controls.PhoneApplicationFrame frame = Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame; frame.Navigate(new Uri(MetaData.Source)); #elif SILVERLIGHT HtmlPage.Window.Navigate(new Uri(MetaData.Source), "_blank"); #else Process.Start(MetaData.Source); #endif }, CanOpenUrl); }
private void Login(HolisticWare.Auth.OAuth2 oauth2) { global::Xamarin.Auth.OAuth2Authenticator auth = null; if ( null == oauth2.OAuth1_UriAccessToken) { try { auth = new global::Xamarin.Auth.OAuth2Authenticator( clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer, scope: oauth2.OAuth2_Scope, authorizeUrl: oauth2.OAuth_UriAuthorization, redirectUrl: oauth2.OAuth_UriCallbackAKARedirect, getUsernameAsync: null ); } catch (System.Exception exc) { throw exc; } } else { try { auth = new global::Xamarin.Auth.OAuth2Authenticator ( clientId: oauth2.OAuth_IdApplication_IdAPI_KeyAPI_IdClient_IdCustomer, clientSecret: oauth2.OAuth1_SecretKey_ConsumerSecret_APISecret, scope: oauth2.OAuth2_Scope, authorizeUrl: oauth2.OAuth_UriAuthorization, redirectUrl: oauth2.OAuth_UriCallbackAKARedirect, accessTokenUrl: oauth2.OAuth1_UriAccessToken, getUsernameAsync: null ); } catch (System.Exception exc) { throw exc; } } auth.Completed += auth_Completed; Uri uri = auth.GetUI(); var rv = System.Windows.Application.Current.RootVisual; Microsoft.Phone.Controls.PhoneApplicationFrame paf = null; paf = rv as Microsoft.Phone.Controls.PhoneApplicationFrame; paf.Navigate(uri); return; }
public Navigator( ISerializer serializer, IContainer container #if WINDOWS_PHONE , Microsoft.Phone.Controls.PhoneApplicationFrame frame #endif // WINDOWS_PHONE ) { this.serializer = serializer; this.container = container; #if WINDOWS_PHONE this.frame = frame; #endif // WINDOWS_PHONE }
private static void _instance_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName != "GameMode") { return; } Microsoft.Phone.Controls.PhoneApplicationFrame phoneApplicationFrame = (Application.Current.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame); switch (MainViewModel.Instance.GameMode) { case GameModes.DownloadDeck: if (phoneApplicationFrame.Source.ToString() != "/Views/DownloadPage.xaml") { phoneApplicationFrame.Navigate(new Uri("/Views/DownloadPage.xaml", UriKind.Relative)); } break; case GameModes.GameSelect: if (phoneApplicationFrame.Source.ToString() != "/Views/SelectGamePage.xaml") { phoneApplicationFrame.Navigate(new Uri("/Views/SelectGamePage.xaml", UriKind.Relative)); } break; case GameModes.LearningGame: if (phoneApplicationFrame.Source.ToString() != "/Views/LearningPage.xaml") { phoneApplicationFrame.Navigate(new Uri("/Views/LearningPage.xaml", UriKind.Relative)); } break; case GameModes.MatchingGame: if (phoneApplicationFrame.Source.ToString() != "/Views/MatchingPage.xaml") { phoneApplicationFrame.Navigate(new Uri("/Views/MatchingPage.xaml", UriKind.Relative)); } break; case GameModes.MemoryGame: if (phoneApplicationFrame.Source.ToString() != "/Views/MatchingPage.xaml") { phoneApplicationFrame.Navigate(new Uri("/Views/MatchingPage.xaml", UriKind.Relative)); } break; } }
/// <summary> /// Completely clear the navigational backstack /// </summary> /// <param name="rootFrame">The starting point for the purging of the backstack</param> public void PurgeNavigationalBackStack(Microsoft.Phone.Controls.PhoneApplicationFrame rootFrame) { var purgeList = new System.Collections.Generic.List <System.Windows.Navigation.JournalEntry>(); foreach (var entry in rootFrame.BackStack) { purgeList.Add(entry); } foreach (var entry in purgeList) { if (rootFrame.CanGoBack) { rootFrame.RemoveBackEntry(); } } }
// Do not add any additional code to this method private void InitializePhoneApplication() { if (phoneApplicationInitialized) { return; } // Create the frame but don't set it as RootVisual yet; this allows the splash // screen to remain active until the application is ready to render. RootFrame = new Microsoft.Phone.Controls.PhoneApplicationFrame(); RootFrame.Navigated += CompleteInitializePhoneApplication; // Handle navigation failures RootFrame.NavigationFailed += RootFrame_NavigationFailed; // Handle reset requests for clearing the backstack RootFrame.Navigated += CheckForResetNavigation; // Ensure we don't initialize again phoneApplicationInitialized = true; }
/// <summary>Called when the message box's XAML popup has just been closed and is no longer on screen.</summary> /// <param name="sender">The popup that raised this event.</param> /// <param name="e">Empty event arguments.</param> private void OnClosed(object sender, EventArgs e) { // Remove event handlers. fPopup.LayoutUpdated -= OnLayoutUpdated; fPopup.Opened -= OnOpened; fPopup.Closed -= OnClosed; if (fRootFrame != null) { fRootFrame.BackKeyPress -= OnBackKeyPressed; } // Remove this message box instance from the global "shown" message box collection. // Note: This collection tracks the z-order of all currently displayed message boxes. sShownMessageBoxes.Remove(this); // Drop the reference to the page that is behind this message box. This allows it to be garbage collected. fRootFrame = null; // Notify the owner that this message box has been closed. if (this.Closed != null) { this.Closed.Invoke(this, CoronaLabs.WinRT.EmptyEventArgs.Instance); } }
/// <summary> /// <para>Creates a new message box initialized with empty text and no buttons.</para> /// <para> /// You are expected to set the returned message box's <see cref="Title"/>, <see cref="Message"/>, /// and <see cref="ButtonLabels"/> properties before showing it. /// </para> /// </summary> public CoronaMessageBox() { // Set the root frame to null until the message box is shown. fRootFrame = null; // Create the message box's settings, initialized to its defaults. fSettings = new Corona.WinRT.Interop.UI.MessageBoxSettings(); // Initialize last button pressed index to an invalid index. fLastButtonIndexPressed = -1; // Create the popup control. fPopup = new System.Windows.Controls.Primitives.Popup(); // Fetch the system UI's default settings needed by this message box. var application = System.Windows.Application.Current; object resourceValue = application.Resources["PhoneFontSizeLarge"]; double defaultTitleFontSize = (resourceValue is double) ? (double)resourceValue : 32.0; resourceValue = application.Resources["PhoneFontSizeMedium"]; double defaultContentFontSize = (resourceValue is double) ? (double)resourceValue : 22.667; var defaultMessageBoxColor = System.Windows.Media.Color.FromArgb(255, 32, 32, 32); resourceValue = application.Resources["PhoneChromeColor"]; if (resourceValue is System.Windows.Media.Color) { defaultMessageBoxColor = (System.Windows.Media.Color)resourceValue; } var defaultFontColor = System.Windows.Media.Colors.White; resourceValue = application.Resources["PhoneForegroundColor"]; if (resourceValue is System.Windows.Media.Color) { defaultFontColor = (System.Windows.Media.Color)resourceValue; } // Create a dark fullscreen transparent background. // This allows the end user to see what's behind the message box and also steals all touch/tap events. fFullscreenBackground = new System.Windows.Controls.Border(); fFullscreenBackground.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(128, 0, 0, 0)); fFullscreenBackground.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; fFullscreenBackground.VerticalAlignment = System.Windows.VerticalAlignment.Center; fPopup.Child = fFullscreenBackground; // Create a border panel that will host all of the content within the message box window. var messageBoxBorder = new System.Windows.Controls.Border(); messageBoxBorder.BorderBrush = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Black); messageBoxBorder.BorderThickness = new System.Windows.Thickness(2); messageBoxBorder.VerticalAlignment = System.Windows.VerticalAlignment.Center; messageBoxBorder.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; fFullscreenBackground.Child = messageBoxBorder; // Create the main message box stack panel used to display the title, message, buttons, and background. var mainStackPanel = new System.Windows.Controls.StackPanel(); mainStackPanel.Background = new System.Windows.Media.SolidColorBrush(defaultMessageBoxColor); mainStackPanel.Orientation = System.Windows.Controls.Orientation.Vertical; messageBoxBorder.Child = mainStackPanel; // Create the title text block. fTitleTextBlock = new System.Windows.Controls.TextBlock(); fTitleTextBlock.TextWrapping = System.Windows.TextWrapping.NoWrap; fTitleTextBlock.TextTrimming = System.Windows.TextTrimming.WordEllipsis; fTitleTextBlock.FontSize = defaultTitleFontSize; fTitleTextBlock.FontWeight = System.Windows.FontWeights.SemiBold; fTitleTextBlock.Margin = new System.Windows.Thickness(20, 20, 20, 10); fTitleTextBlock.Foreground = new System.Windows.Media.SolidColorBrush(defaultFontColor); mainStackPanel.Children.Add(fTitleTextBlock); // Create the dividing line control used to separate the title and message text blocks. fTitleDividingLine = new System.Windows.Shapes.Rectangle(); fTitleDividingLine.Height = 1; fTitleDividingLine.Margin = new System.Windows.Thickness(0); fTitleDividingLine.Fill = messageBoxBorder.BorderBrush; mainStackPanel.Children.Add(fTitleDividingLine); // Create the message scroll view container. // Note: This container will only be scrollable if the message text is too big to fit onscreen. fMessageScrollViewer = new System.Windows.Controls.ScrollViewer(); fMessageScrollViewer.Padding = new System.Windows.Thickness(20, 20, 20, 20); fMessageScrollViewer.HorizontalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Disabled; mainStackPanel.Children.Add(fMessageScrollViewer); // Create the message text block. fMessageTextBlock = new System.Windows.Controls.TextBlock(); fMessageTextBlock.TextWrapping = System.Windows.TextWrapping.Wrap; fMessageTextBlock.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; fMessageTextBlock.FontSize = defaultContentFontSize; fMessageTextBlock.Foreground = new System.Windows.Media.SolidColorBrush(defaultFontColor); fMessageTextBlock.Margin = new System.Windows.Thickness(0); fMessageTextBlock.Padding = new System.Windows.Thickness(0); fMessageScrollViewer.Content = fMessageTextBlock; // Create the dividing line control used to separate the message text block and the buttons container. fButtonPanelDividingLine = new System.Windows.Shapes.Rectangle(); fButtonPanelDividingLine.Height = 1; fButtonPanelDividingLine.Margin = new System.Windows.Thickness(0); fButtonPanelDividingLine.Fill = messageBoxBorder.BorderBrush; mainStackPanel.Children.Add(fButtonPanelDividingLine); // Create the button scroller and panel containers. fButtonScrollViewer = new System.Windows.Controls.ScrollViewer(); fButtonScrollViewer.Padding = new System.Windows.Thickness(10, 10, 10, 10); fButtonScrollViewer.HorizontalScrollBarVisibility = System.Windows.Controls.ScrollBarVisibility.Disabled; mainStackPanel.Children.Add(fButtonScrollViewer); fButtonStackPanel = new System.Windows.Controls.StackPanel(); fButtonStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal; fButtonScrollViewer.Content = fButtonStackPanel; }
/// <summary> /// <para> /// Updates the layout of the message box's title text, message text, and buttons to best fit its content. /// </para> /// <para> /// This method should be called whenever the page layout changes onscreen as well, /// such as after an orientation change or a resize. /// </para> /// </summary> private void UpdateLayout() { // Fetch the application object. var application = System.Windows.Application.Current; if (application == null) { return; } // Fetch the main message box container. var messageBox = fFullscreenBackground.Child as System.Windows.FrameworkElement; if (messageBox == null) { return; } // Check if the application page under this message box has changed. var rootFrame = application.RootVisual as Microsoft.Phone.Controls.PhoneApplicationFrame; if ((rootFrame != null) && (rootFrame != fRootFrame)) { // Remove event handlers from the previous page. if (fRootFrame != null) { fRootFrame.BackKeyPress -= OnBackKeyPressed; } // Keep a reference to the current page and listen for its events. fRootFrame = rootFrame; fRootFrame.BackKeyPress += OnBackKeyPressed; } // Rotate the popup if the application's current page is landscape. bool isPagePortrait = true; if (fRootFrame != null) { switch (fRootFrame.Orientation) { case Microsoft.Phone.Controls.PageOrientation.Landscape: case Microsoft.Phone.Controls.PageOrientation.LandscapeLeft: case Microsoft.Phone.Controls.PageOrientation.LandscapeRight: isPagePortrait = false; break; } fFullscreenBackground.RenderTransform = fRootFrame.RenderTransform; } else { fFullscreenBackground.RenderTransform = null; } // Resize the semi-transparent background to fill the screen. // Note: XAML popups are displayed relative to portrait. So, we must swap width/height when app is landscape. if (isPagePortrait) { fFullscreenBackground.Width = application.Host.Content.ActualWidth; fFullscreenBackground.Height = application.Host.Content.ActualHeight; } else { fFullscreenBackground.Width = application.Host.Content.ActualHeight; fFullscreenBackground.Height = application.Host.Content.ActualWidth; } // Resize the message box to best fit the current page orientation. if (isPagePortrait) { messageBox.Width = fFullscreenBackground.Width - 40; } else { messageBox.Width = fFullscreenBackground.Width * 0.8; } messageBox.MaxHeight = fFullscreenBackground.Height - 40; // Layout the buttons to best fit the message box if (fButtonStackPanel.Children.Count > 0) { if (isPagePortrait && (fButtonStackPanel.Children.Count <= 2)) { fButtonStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal; } else if (!isPagePortrait && (fButtonStackPanel.Children.Count <= 3)) { fButtonStackPanel.Orientation = System.Windows.Controls.Orientation.Horizontal; } else { fButtonStackPanel.Orientation = System.Windows.Controls.Orientation.Vertical; } double minButtonWidth; double maxButtonWidth; if (fButtonStackPanel.Orientation == System.Windows.Controls.Orientation.Horizontal) { minButtonWidth = fButtonScrollViewer.ActualWidth; minButtonWidth -= fButtonScrollViewer.Padding.Left + fButtonScrollViewer.Padding.Right; if (fButtonStackPanel.Children.Count >= 3) { minButtonWidth /= (double)fButtonStackPanel.Children.Count; } else { minButtonWidth /= 2.0; } if (minButtonWidth < 0) { minButtonWidth = 0; } maxButtonWidth = minButtonWidth; if (fButtonStackPanel.Children.Count == 1) { maxButtonWidth = fButtonScrollViewer.ActualWidth; } fButtonStackPanel.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; } else { minButtonWidth = 0; maxButtonWidth = double.PositiveInfinity; fButtonStackPanel.HorizontalAlignment = System.Windows.HorizontalAlignment.Stretch; } foreach (var uiElement in fButtonStackPanel.Children) { var frameworkElement = uiElement as System.Windows.FrameworkElement; if (frameworkElement != null) { frameworkElement.MinWidth = minButtonWidth; frameworkElement.MaxWidth = maxButtonWidth; } } } // Resize the message text and button panels to best fill the message box. if (messageBox.ActualHeight > 0) { // Set the size of the button panel first. if (fButtonStackPanel.Children.Count > 0) { // Calculate the height of a button, including its padding. double buttonHeight; if (fButtonStackPanel.Orientation == System.Windows.Controls.Orientation.Horizontal) { buttonHeight = fButtonStackPanel.ActualHeight; } else { buttonHeight = fButtonStackPanel.ActualHeight / fButtonStackPanel.Children.Count; } // Calculate what the minimum height of the button panel must be. double minButtonPanelHeight; if (fButtonStackPanel.Orientation == System.Windows.Controls.Orientation.Horizontal) { minButtonPanelHeight = fButtonStackPanel.ActualHeight; } else if (isPagePortrait && (fButtonStackPanel.Children.Count > 3)) { minButtonPanelHeight = buttonHeight * 3.5; } else if (!isPagePortrait && (fButtonStackPanel.Children.Count > 2)) { minButtonPanelHeight = buttonHeight * 2.5; } else { minButtonPanelHeight = fButtonStackPanel.ActualHeight; } minButtonPanelHeight += fButtonScrollViewer.Margin.Top; minButtonPanelHeight += fButtonScrollViewer.Padding.Top; minButtonPanelHeight += fButtonScrollViewer.Padding.Bottom; minButtonPanelHeight += fButtonScrollViewer.Margin.Bottom; // Calculate the current height of all elements in the message box, excluding the button panel. double heightsExcludingButtons = 0; if (fTitleTextBlock.Visibility != System.Windows.Visibility.Collapsed) { heightsExcludingButtons += fTitleTextBlock.Margin.Top; heightsExcludingButtons += fTitleTextBlock.ActualHeight; heightsExcludingButtons += fTitleTextBlock.Margin.Bottom; } if (fTitleDividingLine.Visibility != System.Windows.Visibility.Collapsed) { heightsExcludingButtons += fTitleDividingLine.Margin.Top; heightsExcludingButtons += fTitleDividingLine.ActualHeight; heightsExcludingButtons += fTitleDividingLine.Margin.Bottom; } if (fMessageScrollViewer.Visibility != System.Windows.Visibility.Collapsed) { heightsExcludingButtons += fMessageScrollViewer.Margin.Top; if (fMessageTextBlock.Visibility != System.Windows.Visibility.Collapsed) { heightsExcludingButtons += fMessageScrollViewer.Padding.Top; heightsExcludingButtons += fMessageTextBlock.ActualHeight; heightsExcludingButtons += fMessageScrollViewer.Padding.Bottom; } heightsExcludingButtons += fMessageScrollViewer.Margin.Bottom; } if (fButtonPanelDividingLine.Visibility != System.Windows.Visibility.Collapsed) { heightsExcludingButtons += fButtonPanelDividingLine.Margin.Top; heightsExcludingButtons += fButtonPanelDividingLine.ActualHeight; heightsExcludingButtons += fButtonPanelDividingLine.Margin.Bottom; } heightsExcludingButtons += fButtonScrollViewer.Margin.Top; heightsExcludingButtons += fButtonScrollViewer.Padding.Top; heightsExcludingButtons += fButtonScrollViewer.Padding.Bottom; heightsExcludingButtons += fButtonScrollViewer.Margin.Bottom; // Calculate what the maximum height of the button panel can be to best fit all of its buttons. // Note that this prioritizes the title and message text over button, but there still must be // a minimum button height so that the end user can still tap them. double maxButtonPanelHeight = minButtonPanelHeight; if ((heightsExcludingButtons + minButtonPanelHeight) < messageBox.MaxHeight) { // This is the max button panel height. maxButtonPanelHeight = messageBox.MaxHeight - heightsExcludingButtons; // Now we shave the button panel height down so that half a button appears in its scroll view. // This makes it more obvious to the end user that there are more button that they can scroll to. double unpaddedButtonPanelHeight = maxButtonPanelHeight; unpaddedButtonPanelHeight -= fButtonScrollViewer.Margin.Top; unpaddedButtonPanelHeight -= fButtonScrollViewer.Padding.Top; unpaddedButtonPanelHeight -= fButtonScrollViewer.Padding.Bottom; unpaddedButtonPanelHeight -= fButtonScrollViewer.Margin.Bottom; if (unpaddedButtonPanelHeight < fButtonStackPanel.ActualHeight) { double delta = unpaddedButtonPanelHeight % buttonHeight; if (delta > (buttonHeight * 0.75)) { maxButtonPanelHeight -= delta; maxButtonPanelHeight += buttonHeight / 2.0; } else if (delta < (buttonHeight * 0.25)) { maxButtonPanelHeight -= delta; maxButtonPanelHeight -= buttonHeight / 2.0; } } } // Apply a maximum button panel height constraint. fButtonScrollViewer.MaxHeight = maxButtonPanelHeight; } else { // There are no buttons in the message box. Remove the maximum height constraint. fButtonStackPanel.MaxHeight = double.PositiveInfinity; } // Set the height of the main message text panel. // This must be done after setting the button panel's height. if ((fMessageScrollViewer.Visibility != System.Windows.Visibility.Collapsed) && (fMessageTextBlock.Visibility != System.Windows.Visibility.Collapsed)) { // Calculate the height of all elements in the message box, excluding the message text panel. double heightsExcludingMessage = 0; if (fTitleTextBlock.Visibility != System.Windows.Visibility.Collapsed) { heightsExcludingMessage += fTitleTextBlock.Margin.Top; heightsExcludingMessage += fTitleTextBlock.ActualHeight; heightsExcludingMessage += fTitleTextBlock.Margin.Bottom; } if (fTitleDividingLine.Visibility != System.Windows.Visibility.Collapsed) { heightsExcludingMessage += fTitleDividingLine.Margin.Top; heightsExcludingMessage += fTitleDividingLine.ActualHeight; heightsExcludingMessage += fTitleDividingLine.Margin.Bottom; } if (fButtonPanelDividingLine.Visibility != System.Windows.Visibility.Collapsed) { heightsExcludingMessage += fButtonPanelDividingLine.Margin.Top; heightsExcludingMessage += fButtonPanelDividingLine.ActualHeight; heightsExcludingMessage += fButtonPanelDividingLine.Margin.Bottom; } if (fButtonScrollViewer.Visibility != System.Windows.Visibility.Collapsed) { if (fButtonScrollViewer.MaxHeight != double.PositiveInfinity) { heightsExcludingMessage += fButtonScrollViewer.MaxHeight; } else { heightsExcludingMessage += fButtonScrollViewer.Margin.Top; heightsExcludingMessage += fButtonScrollViewer.Margin.Bottom; } } // Apply a maximum text panel height constraint. fMessageScrollViewer.MaxHeight = messageBox.MaxHeight - heightsExcludingMessage; } else { // There is no message text. Remove the maximum height constraint. fMessageScrollViewer.MaxHeight = double.PositiveInfinity; } } else { // The heights for all controls have not been calculated by the framework yet. // So, set the message panel's height to a default value until the XAML frameworks calls this method again. if (isPagePortrait || (fButtonStackPanel.Children.Count <= 0)) { fMessageScrollViewer.MaxHeight = fFullscreenBackground.Height / 2; } else { fMessageScrollViewer.MaxHeight = fFullscreenBackground.Height / 3; } } // Enable/disable message text scrolling. double paddingHeight = fMessageScrollViewer.Padding.Top + fMessageScrollViewer.Padding.Bottom; if ((fMessageTextBlock.ActualHeight + paddingHeight) > fMessageScrollViewer.MaxHeight) { var visibilityMode = System.Windows.Controls.ScrollBarVisibility.Visible; if (fMessageScrollViewer.VerticalScrollBarVisibility != visibilityMode) { fMessageScrollViewer.VerticalScrollBarVisibility = visibilityMode; fMessageScrollViewer.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 64, 64)); } } else { var visibilityMode = System.Windows.Controls.ScrollBarVisibility.Disabled; if (fMessageScrollViewer.VerticalScrollBarVisibility != visibilityMode) { fMessageScrollViewer.VerticalScrollBarVisibility = visibilityMode; fMessageScrollViewer.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Transparent); } } // Enable/disable button scrolling. paddingHeight = fButtonScrollViewer.Padding.Top + fButtonScrollViewer.Padding.Bottom; if ((fButtonStackPanel.Orientation == System.Windows.Controls.Orientation.Horizontal) || ((fButtonStackPanel.ActualHeight + paddingHeight) <= fButtonScrollViewer.ActualHeight)) { var visibilityMode = System.Windows.Controls.ScrollBarVisibility.Disabled; if (fButtonScrollViewer.VerticalScrollBarVisibility != visibilityMode) { fButtonScrollViewer.VerticalScrollBarVisibility = visibilityMode; fButtonScrollViewer.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Colors.Transparent); } } else { var visibilityMode = System.Windows.Controls.ScrollBarVisibility.Visible; if (fButtonScrollViewer.VerticalScrollBarVisibility != visibilityMode) { fButtonScrollViewer.VerticalScrollBarVisibility = visibilityMode; fButtonScrollViewer.Background = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(255, 64, 64, 64)); } } // Show a dividing line under the title if: // 1) The message text block is set up to scroll. // 2) There is no message text and the button panel is set up to scroll. bool showTitleDividingLine = false; if (fTitleTextBlock.Visibility != System.Windows.Visibility.Collapsed) { if ((fMessageScrollViewer.Visibility != System.Windows.Visibility.Collapsed) && (fMessageScrollViewer.VerticalScrollBarVisibility == System.Windows.Controls.ScrollBarVisibility.Visible)) { showTitleDividingLine = true; } else if ((fMessageScrollViewer.Visibility == System.Windows.Visibility.Collapsed) && (fButtonScrollViewer.Visibility != System.Windows.Visibility.Collapsed) && (fButtonScrollViewer.VerticalScrollBarVisibility == System.Windows.Controls.ScrollBarVisibility.Visible)) { showTitleDividingLine = true; } } fTitleDividingLine.Opacity = showTitleDividingLine ? 1.0 : 0; // Show a dividing line above the button panel if: // 1) The message text block is set up to scroll. // 2) The button panel is set up to scroll. bool showButtonPanelDividingLine = false; if (fButtonScrollViewer.Visibility != System.Windows.Visibility.Collapsed) { if ((fMessageScrollViewer.Visibility != System.Windows.Visibility.Collapsed) && (fMessageScrollViewer.VerticalScrollBarVisibility == System.Windows.Controls.ScrollBarVisibility.Visible)) { showButtonPanelDividingLine = true; } else if (fButtonScrollViewer.VerticalScrollBarVisibility == System.Windows.Controls.ScrollBarVisibility.Visible) { if ((fTitleTextBlock.Visibility != System.Windows.Visibility.Collapsed) || (fMessageScrollViewer.Visibility != System.Windows.Visibility.Collapsed)) { showButtonPanelDividingLine = true; } } } fButtonPanelDividingLine.Opacity = showButtonPanelDividingLine ? 1.0 : 0; }