diff --git a/src/CalcViewModel/ApplicationViewModel.h b/src/CalcViewModel/ApplicationViewModel.h index c35595e..8a293ea 100644 --- a/src/CalcViewModel/ApplicationViewModel.h +++ b/src/CalcViewModel/ApplicationViewModel.h @@ -23,10 +23,11 @@ namespace CalculatorApp OBSERVABLE_PROPERTY_RW(DateCalculatorViewModel ^, DateCalcViewModel); OBSERVABLE_PROPERTY_RW(UnitConverterViewModel ^, ConverterViewModel); OBSERVABLE_PROPERTY_RW(CalculatorApp::Common::ViewMode, PreviousMode); + OBSERVABLE_PROPERTY_R(bool, IsAlwaysOnTop); OBSERVABLE_NAMED_PROPERTY_RW(Platform::String ^, CategoryName); // Indicates whether calculator is currently in standard mode _and_ supports CompactOverlay _and_ is not in Always-on-Top mode - OBSERVABLE_PROPERTY_RW(bool, DisplayNormalAlwaysOnTopOption); + OBSERVABLE_PROPERTY_R(bool, DisplayNormalAlwaysOnTopOption); COMMAND_FOR_METHOD(CopyCommand, ApplicationViewModel::OnCopyCommand); COMMAND_FOR_METHOD(PasteCommand, ApplicationViewModel::OnPasteCommand); @@ -91,22 +92,6 @@ namespace CalculatorApp } } - property bool IsAlwaysOnTop - { - bool get() - { - return m_isAlwaysOnTop; - } - void set(bool value) - { - if (m_isAlwaysOnTop != value) - { - m_isAlwaysOnTop = value; - RaisePropertyChanged(L"IsAlwaysOnTop"); - } - } - } - void ToggleAlwaysOnTop(float width, float height); private: @@ -123,8 +108,6 @@ namespace CalculatorApp Windows::Foundation::Collections::IObservableVector ^ m_categories; Concurrency::task HandleToggleAlwaysOnTop(float width, float height); void SetDisplayNormalAlwaysOnTopOption(); - - bool m_isAlwaysOnTop; }; } } diff --git a/src/Calculator/Views/MainPage.xaml b/src/Calculator/Views/MainPage.xaml index ca372ea..a275e9c 100644 --- a/src/Calculator/Views/MainPage.xaml +++ b/src/Calculator/Views/MainPage.xaml @@ -86,9 +86,9 @@ Command="{x:Bind Model.PasteCommand}"/> - - + + diff --git a/src/Calculator/Views/MainPage.xaml.cpp b/src/Calculator/Views/MainPage.xaml.cpp index 61d00bf..74a79e1 100644 --- a/src/Calculator/Views/MainPage.xaml.cpp +++ b/src/Calculator/Views/MainPage.xaml.cpp @@ -546,7 +546,13 @@ void MainPage::OnNavItemInvoked(MUXC::NavigationView ^ /*sender*/, _In_ MUXC::Na NavView->IsPaneOpen = false; } -void MainPage::AlwaysOnTopButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e) +void MainPage::TitleBarAlwaysOnTopButtonClick(_In_ Object ^ /*sender*/, _In_ RoutedEventArgs ^ /*e*/) +{ + auto bounds = Window::Current->Bounds; + Model->ToggleAlwaysOnTop(bounds.Width, bounds.Height); +} + +void MainPage::AlwaysOnTopButtonClick(_In_ Object ^ /*sender*/, _In_ RoutedEventArgs ^ /*e*/) { Model->ToggleAlwaysOnTop(0, 0); } diff --git a/src/Calculator/Views/MainPage.xaml.h b/src/Calculator/Views/MainPage.xaml.h index 3f16cd3..c7a2e98 100644 --- a/src/Calculator/Views/MainPage.xaml.h +++ b/src/Calculator/Views/MainPage.xaml.h @@ -57,6 +57,7 @@ public void OnAboutFlyoutOpened(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e); void OnAboutFlyoutClosed(_In_ Platform::Object ^ sender, _In_ Platform::Object ^ e); void AlwaysOnTopButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); + void TitleBarAlwaysOnTopButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e); Microsoft::UI::Xaml::Controls::NavigationViewItemHeader ^ CreateNavViewHeaderFromGroup(CalculatorApp::Common::NavCategoryGroup ^ group); Microsoft::UI::Xaml::Controls::NavigationViewItem ^ CreateNavViewItemFromCategory(CalculatorApp::Common::NavCategory ^ category); diff --git a/src/Calculator/Views/TitleBar.xaml b/src/Calculator/Views/TitleBar.xaml index 1c7615f..94d13fa 100644 --- a/src/Calculator/Views/TitleBar.xaml +++ b/src/Calculator/Views/TitleBar.xaml @@ -3,11 +3,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" - xmlns:converters="using:CalculatorApp.Converters" mc:Ignorable="d"> - - - @@ -20,37 +16,44 @@ + + + + + + + + + + Height="32" + Background="Transparent"> + x:Uid="AppName" + Margin="12,0,12,0" + HorizontalAlignment="Left" + VerticalAlignment="Center" + Foreground="{ThemeResource TitleBarForegroundBaseHighBrush}" + FontSize="12" + TextAlignment="Left" + TextTrimming="CharacterEllipsis"/> -