diff --git a/src/Calculator/Views/MainPage.xaml b/src/Calculator/Views/MainPage.xaml index 1e40cd6..8fac3ea 100644 --- a/src/Calculator/Views/MainPage.xaml +++ b/src/Calculator/Views/MainPage.xaml @@ -2,14 +2,11 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:automation="using:CalculatorApp.ViewModel.Common.Automation" - xmlns:common="using:CalculatorApp.Common" - xmlns:controls="using:CalculatorApp.Controls" xmlns:converters="using:CalculatorApp.Converters" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="using:CalculatorApp" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" - xmlns:vm="using:CalculatorApp.ViewModel" x:Name="PageRoot" muxc:BackdropMaterial.ApplyToRootOrPageBackground="True" Loaded="OnPageLoaded" @@ -85,8 +82,7 @@ + Opened="Popup_Opened"> @@ -172,7 +167,7 @@ - + diff --git a/src/Calculator/Views/MainPage.xaml.cs b/src/Calculator/Views/MainPage.xaml.cs index 1862b19..04c68a1 100644 --- a/src/Calculator/Views/MainPage.xaml.cs +++ b/src/Calculator/Views/MainPage.xaml.cs @@ -154,7 +154,7 @@ private void UpdatePopupSize(Windows.UI.Core.WindowSizeChangedEventArgs e) if(PopupContent != null) { PopupContent.Width = e.Size.Width; - PopupContent.Height = e.Size.Height - AppTitleBar.ActualHeight; + PopupContent.Height = e.Size.Height; } } @@ -300,7 +300,7 @@ private void EnsurePopupContent() var windowBounds = Window.Current.Bounds; PopupContent.Width = windowBounds.Width; - PopupContent.Height = windowBounds.Height - AppTitleBar.ActualHeight; + PopupContent.Height = windowBounds.Height; } } @@ -578,14 +578,9 @@ private void AnnounceCategoryName() NarratorNotifier.Announce(announcement); } - private void TitleBarBackButtonClick(object sender, RoutedEventArgs e) + private bool ShouldShowBackButton(bool isAlwaysOnTop, bool isPopupOpen) { - CloseSettingsPopup(); - } - - private Visibility ShouldShowBackButton(bool isAlwaysOnTop, bool isPopupOpen) - { - return !isAlwaysOnTop && isPopupOpen ? Visibility.Visible : Visibility.Collapsed; + return !isAlwaysOnTop && isPopupOpen; } private double NavigationViewOpenPaneLength(bool isAlwaysOnTop) @@ -593,6 +588,16 @@ private double NavigationViewOpenPaneLength(bool isAlwaysOnTop) return isAlwaysOnTop ? 0 : (double)Application.Current.Resources["SplitViewOpenPaneLength"]; } + private GridLength DoubleToGridLength(double value) + { + return new GridLength(value); + } + + private void Settings_BackButtonClick(object sender, RoutedEventArgs e) + { + CloseSettingsPopup(); + } + private CalculatorApp.Calculator m_calculator; private GraphingCalculator m_graphingCalculator; private CalculatorApp.UnitConverter m_converter; diff --git a/src/Calculator/Views/Settings.xaml b/src/Calculator/Views/Settings.xaml index 3c699cd..e25dc4d 100644 --- a/src/Calculator/Views/Settings.xaml +++ b/src/Calculator/Views/Settings.xaml @@ -3,7 +3,6 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:automation="using:CalculatorApp.ViewModel.Common.Automation" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="using:CalculatorApp" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:muxc="using:Microsoft.UI.Xaml.Controls" Loaded="OnLoaded" @@ -40,6 +39,10 @@ + + + + @@ -77,7 +80,20 @@ - + + @@ -86,7 +102,8 @@ Style="{StaticResource CategoryNameTextBlockStyle}"/> - diff --git a/src/Calculator/Views/Settings.xaml.cs b/src/Calculator/Views/Settings.xaml.cs index 715f3b1..b2a54d0 100644 --- a/src/Calculator/Views/Settings.xaml.cs +++ b/src/Calculator/Views/Settings.xaml.cs @@ -12,12 +12,10 @@ using Windows.System; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; -using Windows.UI.Xaml.Controls.Primitives; -using Windows.UI.Xaml.Data; -using Windows.UI.Xaml.Input; -using Windows.UI.Xaml.Media; -using Windows.UI.Xaml.Navigation; using CalculatorApp.ViewModel.Common.Automation; +using Windows.UI.Core; +using Windows.UI.Xaml.Automation.Peers; +using Windows.UI.Xaml.Automation.Provider; // The User Control item template is documented at https://go.microsoft.com/fwlink/?LinkId=234236 @@ -29,6 +27,16 @@ public sealed partial class Settings : UserControl // BUILD_YEAR was a C++/CX macro and may update the value from the pipeline private const string BUILD_YEAR = "2021"; + public event Windows.UI.Xaml.RoutedEventHandler BackButtonClick; + + public GridLength TitleBarHeight + { + get { return (GridLength)GetValue(TitleBarHeightProperty); } + set { SetValue(TitleBarHeightProperty, value); } + } + public static readonly DependencyProperty TitleBarHeightProperty = + DependencyProperty.Register(nameof(TitleBarHeight), typeof(GridLength), typeof(Settings), new PropertyMetadata(default(GridLength))); + public Settings() { var locService = LocalizationService.GetInstance(); @@ -63,6 +71,8 @@ public void SetDefaultFocus() // OnLoaded would be invoked by Popup several times while contructed once private void OnLoaded(object sender, RoutedEventArgs args) { + SystemNavigationManager.GetForCurrentView().BackRequested += System_BackRequested; + AnnouncePageOpened(); var currentTheme = ThemeHelper.RootTheme.ToString(); @@ -83,6 +93,8 @@ private void OnUnloaded(object sender, RoutedEventArgs e) { // back to the default state AppThemeExpander.IsExpanded = false; + + SystemNavigationManager.GetForCurrentView().BackRequested -= System_BackRequested; } private void FeedbackButton_Click(object sender, RoutedEventArgs e) @@ -131,5 +143,22 @@ private void InitializeContributeTextBlock() ContributeRunLink.Text = contributeTextLink; ContributeRunAfterLink.Text = contributeTextAfterHyperlink; } + + private void System_BackRequested(object sender, BackRequestedEventArgs e) + { + if (!e.Handled && BackButton.IsEnabled) + { + var buttonPeer = new ButtonAutomationPeer(BackButton); + IInvokeProvider invokeProvider = buttonPeer.GetPattern(PatternInterface.Invoke) as IInvokeProvider; + invokeProvider.Invoke(); + + e.Handled = true; + } + } + + private void BackButton_Click(object sender, RoutedEventArgs e) + { + BackButtonClick?.Invoke(this, e); + } } } diff --git a/src/Calculator/Views/TitleBar.xaml b/src/Calculator/Views/TitleBar.xaml index a9da216..afb0eba 100644 --- a/src/Calculator/Views/TitleBar.xaml +++ b/src/Calculator/Views/TitleBar.xaml @@ -27,9 +27,7 @@ - - - + @@ -47,19 +45,6 @@ -