Take windows setting into account to Disable/Enable animations (#748)

This commit is contained in:
Rudy Huyn 2020-01-06 14:36:45 -08:00 committed by Matt Cooley
parent 563404fd99
commit 22f57aab3f
5 changed files with 6 additions and 25 deletions

View File

@ -83,16 +83,6 @@ App::App()
#endif
}
bool App::m_isAnimationEnabled = true;
/// <summary>
/// Return True if animation is enabled by user setting.
/// </summary>
bool App::IsAnimationEnabled()
{
return App::m_isAnimationEnabled;
}
void App::AddWindowToMap(_In_ WindowFrameService ^ frameService)
{
reader_writer_lock::scoped_lock lock(m_windowsMapLock);
@ -218,9 +208,6 @@ void App::OnAppLaunch(IActivatedEventArgs ^ args, String ^ argument)
// }
//#endif
auto userSettings = ref new Windows::UI::ViewManagement::UISettings();
m_isAnimationEnabled = userSettings->AnimationsEnabled;
args->SplashScreen->Dismissed += ref new TypedEventHandler<SplashScreen ^, Object ^>(this, &App::DismissedEventHandler);
auto rootFrame = dynamic_cast<Frame ^>(Window::Current->Content);

View File

@ -29,8 +29,7 @@ namespace CalculatorApp
virtual void OnLaunched(Windows::ApplicationModel::Activation::LaunchActivatedEventArgs ^ args) override;
virtual void OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs ^ args) override;
internal :
static bool IsAnimationEnabled();
internal:
void RemoveWindow(_In_ WindowFrameService ^ frameService);
void RemoveSecondaryWindow(_In_ WindowFrameService ^ frameService);
@ -88,7 +87,5 @@ namespace CalculatorApp
bool m_preLaunched;
Windows::UI::Xaml::Controls::Primitives::Popup ^ m_aboutPopup;
static bool m_isAnimationEnabled;
};
}

View File

@ -195,7 +195,8 @@ void Calculator::UpdateViewState()
void Calculator::AnimateCalculator(bool resultAnimate)
{
if (App::IsAnimationEnabled())
static auto uiSettings = ref new UISettings();
if (uiSettings->AnimationsEnabled)
{
m_doAnimate = true;
m_resultAnimate = resultAnimate;

View File

@ -46,7 +46,6 @@ static const long long DURATION_500_MS = 10000 * 500;
UnitConverter::UnitConverter()
: m_meteredConnectionOverride(false)
, m_isAnimationEnabled(false)
{
m_layoutDirection = LocalizationService::GetInstance()->GetFlowDirection();
m_FlowDirectionHorizontalAlignment = m_layoutDirection == ::FlowDirection::RightToLeft ? ::HorizontalAlignment::Right : ::HorizontalAlignment::Left;
@ -60,9 +59,6 @@ UnitConverter::UnitConverter()
bool preferRight = LocalizationSettings::GetInstance().GetCurrencySymbolPrecedence() == 0;
VisualStateManager::GoToState(this, preferRight ? "CurrencySymbolRightState" : "CurrencySymbolLeftState", false);
auto userSettings = ref new UISettings();
m_isAnimationEnabled = userSettings->AnimationsEnabled;
auto resLoader = AppResourceProvider::GetInstance();
m_chargesMayApplyText = resLoader->GetResourceString(L"DataChargesMayApply");
m_failedToRefreshText = resLoader->GetResourceString(L"FailedToRefresh");
@ -250,7 +246,8 @@ void UnitConverter::OnPasteMenuItemClicked(_In_ Object ^ sender, _In_ RoutedEven
void UnitConverter::AnimateConverter()
{
if (App::IsAnimationEnabled())
static auto uiSettings = ref new UISettings();
if (uiSettings->AnimationsEnabled)
{
AnimationStory->Begin();
}
@ -332,7 +329,7 @@ void UnitConverter::OnIsDisplayVisibleChanged()
if (Model->IsCurrencyCurrentCategory && !Model->CurrencyTimestamp->IsEmpty())
{
VisualStateManager::GoToState(this, L"CurrencyLoadedState", m_isAnimationEnabled);
VisualStateManager::GoToState(this, L"CurrencyLoadedState", true);
}
}
}

View File

@ -87,7 +87,6 @@ namespace CalculatorApp
Windows::UI::Xaml::DispatcherTimer ^ m_delayTimer;
bool m_isAnimationEnabled;
void SupplementaryResultsPanelInGrid_SizeChanged(Platform::Object ^ sender, Windows::UI::Xaml::SizeChangedEventArgs ^ e);
void OnVisualStateChanged(Platform::Object ^ sender, Windows::UI::Xaml::VisualStateChangedEventArgs ^ e);
};