mirror of
https://github.com/Microsoft/calculator.git
synced 2025-08-19 21:03:11 -07:00
Always-on-Top mode implemented (#579)
This commit is contained in:
parent
af8322617f
commit
796d171960
30 changed files with 849 additions and 125 deletions
|
@ -70,7 +70,9 @@ MainPage::MainPage()
|
|||
|
||||
KeyboardShortcutManager::Initialize();
|
||||
|
||||
Application::Current->Suspending += ref new SuspendingEventHandler(this, &MainPage::App_Suspending);
|
||||
m_model->PropertyChanged += ref new PropertyChangedEventHandler(this, &MainPage::OnAppPropertyChanged);
|
||||
m_accessibilitySettings = ref new AccessibilitySettings();
|
||||
|
||||
double sizeInInches = 0.0;
|
||||
|
||||
|
@ -243,6 +245,8 @@ void MainPage::OnPageLoaded(_In_ Object ^, _In_ RoutedEventArgs ^ args)
|
|||
}
|
||||
|
||||
m_windowSizeEventToken = Window::Current->SizeChanged += ref new WindowSizeChangedEventHandler(this, &MainPage::WindowSizeChanged);
|
||||
m_accessibilitySettingsToken = m_accessibilitySettings->HighContrastChanged +=
|
||||
ref new Windows::Foundation::TypedEventHandler<AccessibilitySettings ^, Object ^>(this, &CalculatorApp::MainPage::OnHighContrastChanged);
|
||||
UpdateViewState();
|
||||
|
||||
SetHeaderAutomationName();
|
||||
|
@ -259,6 +263,15 @@ void MainPage::OnPageLoaded(_In_ Object ^, _In_ RoutedEventArgs ^ args)
|
|||
}));
|
||||
}
|
||||
|
||||
void MainPage::OnHighContrastChanged(_In_ AccessibilitySettings ^ /*sender*/, _In_ Object ^ /*args*/)
|
||||
{
|
||||
if (Model->IsAlwaysOnTop && this->ActualHeight < 394)
|
||||
{
|
||||
// Sets to default always-on-top size to force re-layout
|
||||
ApplicationView::GetForCurrentView()->TryResizeView(Size(320, 394));
|
||||
}
|
||||
}
|
||||
|
||||
void MainPage::SetDefaultFocus()
|
||||
{
|
||||
if (m_calculator != nullptr && m_calculator->Visibility == ::Visibility::Visible)
|
||||
|
@ -292,13 +305,16 @@ void MainPage::EnsureCalculator()
|
|||
Binding ^ isProgramerBinding = ref new Binding();
|
||||
isProgramerBinding->Path = ref new PropertyPath(L"IsProgrammer");
|
||||
m_calculator->SetBinding(m_calculator->IsProgrammerProperty, isProgramerBinding);
|
||||
Binding ^ isAlwaysOnTopBinding = ref new Binding();
|
||||
isAlwaysOnTopBinding->Path = ref new PropertyPath(L"IsAlwaysOnTop");
|
||||
m_calculator->SetBinding(m_calculator->IsAlwaysOnTopProperty, isAlwaysOnTopBinding);
|
||||
m_calculator->Style = CalculatorBaseStyle;
|
||||
|
||||
CalcHolder->Child = m_calculator;
|
||||
|
||||
// Calculator's "default" state is visible, but if we get delay loaded
|
||||
// when in converter, we should not be visible. This is not a problem for converter
|
||||
// since it's default state is hidden.
|
||||
// since its default state is hidden.
|
||||
ShowHideControls(this->Model->Mode);
|
||||
}
|
||||
|
||||
|
@ -477,6 +493,8 @@ void MainPage::UnregisterEventHandlers()
|
|||
{
|
||||
Window::Current->SizeChanged -= m_windowSizeEventToken;
|
||||
m_windowSizeEventToken.Value = 0;
|
||||
m_accessibilitySettings->HighContrastChanged -= m_accessibilitySettingsToken;
|
||||
m_accessibilitySettingsToken.Value = 0;
|
||||
|
||||
if (m_calculator != nullptr)
|
||||
{
|
||||
|
@ -527,3 +545,18 @@ void MainPage::OnNavItemInvoked(MUXC::NavigationView ^ /*sender*/, _In_ MUXC::Na
|
|||
{
|
||||
NavView->IsPaneOpen = false;
|
||||
}
|
||||
|
||||
void MainPage::AlwaysOnTopButtonClick(Platform::Object ^ sender, Windows::UI::Xaml::RoutedEventArgs ^ e)
|
||||
{
|
||||
Model->ToggleAlwaysOnTop(0, 0);
|
||||
}
|
||||
|
||||
void MainPage::App_Suspending(Object ^ sender, Windows::ApplicationModel::SuspendingEventArgs ^ e)
|
||||
{
|
||||
if (m_model->IsAlwaysOnTop)
|
||||
{
|
||||
ApplicationDataContainer ^ localSettings = ApplicationData::Current->LocalSettings;
|
||||
localSettings->Values->Insert(ApplicationViewModel::WidthLocalSettings, this->ActualWidth);
|
||||
localSettings->Values->Insert(ApplicationViewModel::HeightLocalSettings, this->ActualHeight);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue