From e38e911bfaaf675bd46590211d41e50d23534631 Mon Sep 17 00:00:00 2001 From: Rudy Huyn Date: Tue, 5 Nov 2019 15:04:28 -0800 Subject: [PATCH] Modify how Calculator manages the visibility of the History button (#712) * Modify how Calculator manages the History button + code cleaning * remove extra include --- src/CalcViewModel/CalcViewModel.vcxproj | 2 - .../CalcViewModel.vcxproj.filters | 5 ++- src/CalcViewModel/Common/Utils.cpp | 1 - src/CalcViewModel/ViewState.cpp | 19 ---------- src/CalcViewModel/ViewState.h | 15 -------- src/Calculator/App.xaml.cpp | 26 ------------- src/Calculator/App.xaml.h | 5 +-- src/Calculator/Views/Calculator.xaml | 35 ++++++++--------- src/Calculator/Views/Calculator.xaml.cpp | 38 +++++++++---------- 9 files changed, 41 insertions(+), 105 deletions(-) delete mode 100644 src/CalcViewModel/ViewState.cpp delete mode 100644 src/CalcViewModel/ViewState.h diff --git a/src/CalcViewModel/CalcViewModel.vcxproj b/src/CalcViewModel/CalcViewModel.vcxproj index 284640c6..8eaefc4d 100644 --- a/src/CalcViewModel/CalcViewModel.vcxproj +++ b/src/CalcViewModel/CalcViewModel.vcxproj @@ -354,7 +354,6 @@ - @@ -395,7 +394,6 @@ - diff --git a/src/CalcViewModel/CalcViewModel.vcxproj.filters b/src/CalcViewModel/CalcViewModel.vcxproj.filters index 625cb915..91b5b8b4 100644 --- a/src/CalcViewModel/CalcViewModel.vcxproj.filters +++ b/src/CalcViewModel/CalcViewModel.vcxproj.filters @@ -20,7 +20,6 @@ - Common @@ -95,7 +94,6 @@ - Common @@ -205,4 +203,7 @@ + + + \ No newline at end of file diff --git a/src/CalcViewModel/Common/Utils.cpp b/src/CalcViewModel/Common/Utils.cpp index c688c395..c0e1f5a1 100644 --- a/src/CalcViewModel/Common/Utils.cpp +++ b/src/CalcViewModel/Common/Utils.cpp @@ -10,7 +10,6 @@ #include "Common/AppResourceProvider.h" #include "Common/ExpressionCommandSerializer.h" #include "Common/ExpressionCommandDeserializer.h" -#include "ViewState.h" using namespace CalculatorApp; using namespace CalculatorApp::Common; diff --git a/src/CalcViewModel/ViewState.cpp b/src/CalcViewModel/ViewState.cpp deleted file mode 100644 index 63a5d30e..00000000 --- a/src/CalcViewModel/ViewState.cpp +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#include "pch.h" -#include "ViewState.h" - -namespace CalculatorApp -{ - namespace ViewState - { - Platform::StringReference Snap(L"Snap"); - Platform::StringReference DockedView(L"DockedView"); - - bool IsValidViewState(Platform::String ^ viewState) - { - return viewState->Equals(ViewState::Snap) || viewState->Equals(ViewState::DockedView); - } - } -} diff --git a/src/CalcViewModel/ViewState.h b/src/CalcViewModel/ViewState.h deleted file mode 100644 index 0a103d09..00000000 --- a/src/CalcViewModel/ViewState.h +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -#pragma once - -namespace CalculatorApp -{ - namespace ViewState - { - extern Platform::StringReference Snap; - extern Platform::StringReference DockedView; - - bool IsValidViewState(Platform::String ^ viewState); - } -} diff --git a/src/Calculator/App.xaml.cpp b/src/Calculator/App.xaml.cpp index 1ee9c19e..ade73f03 100644 --- a/src/Calculator/App.xaml.cpp +++ b/src/Calculator/App.xaml.cpp @@ -12,7 +12,6 @@ #include "CalcViewModel/Common/Automation/NarratorNotifier.h" #include "CalcViewModel/Common/AppResourceProvider.h" #include "CalcViewModel/Common/LocalizationSettings.h" -#include "CalcViewModel/ViewState.h" #include "Views/MainPage.xaml.h" using namespace CalculatorApp; @@ -94,26 +93,6 @@ bool App::IsAnimationEnabled() return App::m_isAnimationEnabled; } -/// -/// Return the current application view state. The value -/// will match one of the constants in the ViewState namespace. -/// -String ^ App::GetAppViewState() -{ - String ^ newViewState; - CoreWindow ^ window = CoreWindow::GetForCurrentThread(); - if ((window->Bounds.Width >= 560) && (window->Bounds.Height >= 356)) - { - newViewState = ViewState::DockedView; - } - else - { - newViewState = ViewState::Snap; - } - - return newViewState; -} - void App::AddWindowToMap(_In_ WindowFrameService ^ frameService) { reader_writer_lock::scoped_lock lock(m_windowsMapLock); @@ -468,10 +447,5 @@ void App::DismissedEventHandler(SplashScreen ^ sender, Object ^ e) SetupJumpList(); } -float App::GetAppWindowHeight() -{ - CoreWindow ^ window = CoreWindow::GetForCurrentThread(); - return window->Bounds.Height; -} diff --git a/src/Calculator/App.xaml.h b/src/Calculator/App.xaml.h index 44e3499f..bc6a4eb2 100644 --- a/src/Calculator/App.xaml.h +++ b/src/Calculator/App.xaml.h @@ -29,9 +29,8 @@ namespace CalculatorApp virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs ^ args) override; virtual void OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs ^ args) override; - internal : static bool IsAnimationEnabled(); - static Platform::String ^ GetAppViewState(); - static float GetAppWindowHeight(); + internal : + static bool IsAnimationEnabled(); void RemoveWindow(_In_ WindowFrameService ^ frameService); void RemoveSecondaryWindow(_In_ WindowFrameService ^ frameService); diff --git a/src/Calculator/Views/Calculator.xaml b/src/Calculator/Views/Calculator.xaml index f748d6b6..1ffba5df 100644 --- a/src/Calculator/Views/Calculator.xaml +++ b/src/Calculator/Views/Calculator.xaml @@ -491,6 +491,7 @@ + @@ -644,17 +645,17 @@ + Visibility="{x:Bind Model.IsProgrammer, Mode=OneWay}" + IsEnabled="{x:Bind Model.IsProgrammer, Mode=OneWay}" + x:Load="False"/> + Visibility="{x:Bind Model.IsProgrammer, Mode=OneWay}" + IsEnabled="{x:Bind Model.IsProgrammer, Mode=OneWay}" + x:Load="False"/>