From 120928404893b3175ab56ad91699fff039f18630 Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Wed, 26 Aug 2020 17:42:04 +0200 Subject: [PATCH 1/9] Fix issue with color changing when updating value while error state --- dev/Common/Common.vcxitems | 4 ++ .../SolidColorBrushToColorConverter.cpp | 31 ++++++++++ dev/Common/SolidColorBrushToColorConverter.h | 22 ++++++++ .../SolidColorBrushToColorConverter.idl | 11 ++++ dev/CommonStyles/Common_themeresources.xaml | 4 +- ...dColorBrushToColorConverter.properties.cpp | 16 ++++++ dev/ProgressBar/ProgressBar.cpp | 56 ++++++++++++------- dev/ProgressBar/ProgressBar.h | 1 + dev/ProgressBar/ProgressBar.xaml | 25 ++++++++- 9 files changed, 146 insertions(+), 24 deletions(-) create mode 100644 dev/Common/SolidColorBrushToColorConverter.cpp create mode 100644 dev/Common/SolidColorBrushToColorConverter.h create mode 100644 dev/Common/SolidColorBrushToColorConverter.idl create mode 100644 dev/Generated/SolidColorBrushToColorConverter.properties.cpp diff --git a/dev/Common/Common.vcxitems b/dev/Common/Common.vcxitems index ef57d3c6ef..bb46845231 100644 --- a/dev/Common/Common.vcxitems +++ b/dev/Common/Common.vcxitems @@ -14,12 +14,14 @@ + + @@ -27,9 +29,11 @@ + + \ No newline at end of file diff --git a/dev/Common/SolidColorBrushToColorConverter.cpp b/dev/Common/SolidColorBrushToColorConverter.cpp new file mode 100644 index 0000000000..de781c8fbc --- /dev/null +++ b/dev/Common/SolidColorBrushToColorConverter.cpp @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#include +#include +#include "SolidColorBrushToColorConverter.h" + +winrt::IInspectable SolidColorBrushToColorConverter::Convert( + winrt::IInspectable const& value, + winrt::TypeName const& targetType, + winrt::IInspectable const& parameter, + winrt::hstring const& language) +{ + if (const auto brush = unbox_value(value)) + { + return box_value(brush.Color()); + } + else + { + return nullptr; + } +} + +winrt::IInspectable SolidColorBrushToColorConverter::ConvertBack( + winrt::IInspectable const& value, + winrt::TypeName const& targetType, + winrt::IInspectable const& parameter, + winrt::hstring const& language) +{ + winrt::throw_hresult(E_NOTIMPL); +} diff --git a/dev/Common/SolidColorBrushToColorConverter.h b/dev/Common/SolidColorBrushToColorConverter.h new file mode 100644 index 0000000000..5ab687739d --- /dev/null +++ b/dev/Common/SolidColorBrushToColorConverter.h @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +#pragma once +#include "SolidColorBrushToColorConverter.g.h" + +class SolidColorBrushToColorConverter : + public winrt::implementation::SolidColorBrushToColorConverterT +{ +public: + winrt::IInspectable Convert( + winrt::IInspectable const& value, + winrt::TypeName const& targetType, + winrt::IInspectable const& parameter, + winrt::hstring const& language); + + winrt::IInspectable ConvertBack( + winrt::IInspectable const& value, + winrt::TypeName const& targetType, + winrt::IInspectable const& parameter, + winrt::hstring const& language); +}; diff --git a/dev/Common/SolidColorBrushToColorConverter.idl b/dev/Common/SolidColorBrushToColorConverter.idl new file mode 100644 index 0000000000..52535f933e --- /dev/null +++ b/dev/Common/SolidColorBrushToColorConverter.idl @@ -0,0 +1,11 @@ +namespace MU_XCP_NAMESPACE +{ + +[WUXC_VERSION_MUXONLY] +[webhosthidden] +[default_interface] +runtimeclass SolidColorBrushToColorConverter : Windows.UI.Xaml.DependencyObject, Windows.UI.Xaml.Data.IValueConverter +{ + SolidColorBrushToColorConverter(); +}; +} diff --git a/dev/CommonStyles/Common_themeresources.xaml b/dev/CommonStyles/Common_themeresources.xaml index e85e54f91b..6c9978fce7 100644 --- a/dev/CommonStyles/Common_themeresources.xaml +++ b/dev/CommonStyles/Common_themeresources.xaml @@ -1,7 +1,8 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:primitives="using:Microsoft.UI.Xaml.Controls.Primitives"> 0 + diff --git a/dev/Generated/SolidColorBrushToColorConverter.properties.cpp b/dev/Generated/SolidColorBrushToColorConverter.properties.cpp new file mode 100644 index 0000000000..d3193ab515 --- /dev/null +++ b/dev/Generated/SolidColorBrushToColorConverter.properties.cpp @@ -0,0 +1,16 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See LICENSE in the project root for license information. + +// DO NOT EDIT! This file was generated by CustomTasks.DependencyPropertyCodeGen +#include "pch.h" +#include "common.h" +#include "SolidColorBrushToColorConverter.h" + +namespace winrt::Microsoft::UI::Xaml::Controls::Primitives +{ + CppWinRTActivatableClassWithBasicFactory(SolidColorBrushToColorConverter) +} + +#include "SolidColorBrushToColorConverter.g.cpp" + + diff --git a/dev/ProgressBar/ProgressBar.cpp b/dev/ProgressBar/ProgressBar.cpp index 2839064596..f61e125809 100644 --- a/dev/ProgressBar/ProgressBar.cpp +++ b/dev/ProgressBar/ProgressBar.cpp @@ -78,31 +78,38 @@ void ProgressBar::OnShowErrorPropertyChanged(const winrt::DependencyPropertyChan void ProgressBar::UpdateStates() { - if (ShowError() && IsIndeterminate()) - { - winrt::VisualStateManager::GoToState(*this, s_IndeterminateErrorStateName, true); - } - else if (ShowError()) - { - winrt::VisualStateManager::GoToState(*this, s_ErrorStateName, true); - } - else if (ShowPaused() && IsIndeterminate()) - { - winrt::VisualStateManager::GoToState(*this, s_IndeterminatePausedStateName, true); - } - else if (ShowPaused()) - { - winrt::VisualStateManager::GoToState(*this, s_PausedStateName, true); - } - else if (IsIndeterminate()) + if (IsIndeterminate()) { + if (ShowError()) + { + winrt::VisualStateManager::GoToState(*this, s_IndeterminateErrorStateName, true); + } + else if (ShowPaused()) + { + winrt::VisualStateManager::GoToState(*this, s_IndeterminatePausedStateName, true); + } + else + { + winrt::VisualStateManager::GoToState(*this, s_IndeterminateStateName, true); + } UpdateWidthBasedTemplateSettings(); - winrt::VisualStateManager::GoToState(*this, s_IndeterminateStateName, true); } - else if (!IsIndeterminate()) + else { - winrt::VisualStateManager::GoToState(*this, s_DeterminateStateName, true); + if (ShowError()) + { + winrt::VisualStateManager::GoToState(*this, s_ErrorStateName, true); + } + else if(ShowPaused()) + { + winrt::VisualStateManager::GoToState(*this, s_PausedStateName, true); + } + else + { + winrt::VisualStateManager::GoToState(*this, s_DeterminateStateName, true); + } } + } void ProgressBar::SetProgressBarIndicatorWidth() @@ -121,7 +128,14 @@ void ProgressBar::SetProgressBarIndicatorWidth() // Adds "Updating" state in between to trigger RepositionThemeAnimation Visual Transition // in ProgressBar.xaml when reverting back to previous state - winrt::VisualStateManager::GoToState(*this, s_UpdatingStateName, true); + if (ShowError()) + { + winrt::VisualStateManager::GoToState(*this, s_UpdatingWithErrorStateName, true); + } + else + { + winrt::VisualStateManager::GoToState(*this, s_UpdatingStateName, true); + } if (IsIndeterminate()) { diff --git a/dev/ProgressBar/ProgressBar.h b/dev/ProgressBar/ProgressBar.h index 7076872d26..ecf065ec27 100644 --- a/dev/ProgressBar/ProgressBar.h +++ b/dev/ProgressBar/ProgressBar.h @@ -55,4 +55,5 @@ class ProgressBar : static constexpr wstring_view s_IndeterminatePausedStateName{ L"IndeterminatePaused" }; static constexpr wstring_view s_DeterminateStateName{ L"Determinate" }; static constexpr wstring_view s_UpdatingStateName{ L"Updating" }; + static constexpr wstring_view s_UpdatingWithErrorStateName{ L"UpdatingError" }; }; diff --git a/dev/ProgressBar/ProgressBar.xaml b/dev/ProgressBar/ProgressBar.xaml index 5b8808389d..9c9b1616c9 100644 --- a/dev/ProgressBar/ProgressBar.xaml +++ b/dev/ProgressBar/ProgressBar.xaml @@ -30,6 +30,11 @@ + + + + + + + + + + + + + - + Date: Wed, 26 Aug 2020 18:21:46 +0200 Subject: [PATCH 2/9] Switch back to path binding --- dev/Common/Common.vcxitems | 4 --- .../SolidColorBrushToColorConverter.cpp | 31 ------------------- dev/Common/SolidColorBrushToColorConverter.h | 22 ------------- .../SolidColorBrushToColorConverter.idl | 11 ------- dev/CommonStyles/Common_themeresources.xaml | 1 - dev/ProgressBar/ProgressBar.xaml | 6 ++-- 6 files changed, 3 insertions(+), 72 deletions(-) delete mode 100644 dev/Common/SolidColorBrushToColorConverter.cpp delete mode 100644 dev/Common/SolidColorBrushToColorConverter.h delete mode 100644 dev/Common/SolidColorBrushToColorConverter.idl diff --git a/dev/Common/Common.vcxitems b/dev/Common/Common.vcxitems index bb46845231..ef57d3c6ef 100644 --- a/dev/Common/Common.vcxitems +++ b/dev/Common/Common.vcxitems @@ -14,14 +14,12 @@ - - @@ -29,11 +27,9 @@ - - \ No newline at end of file diff --git a/dev/Common/SolidColorBrushToColorConverter.cpp b/dev/Common/SolidColorBrushToColorConverter.cpp deleted file mode 100644 index de781c8fbc..0000000000 --- a/dev/Common/SolidColorBrushToColorConverter.cpp +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See LICENSE in the project root for license information. - -#include -#include -#include "SolidColorBrushToColorConverter.h" - -winrt::IInspectable SolidColorBrushToColorConverter::Convert( - winrt::IInspectable const& value, - winrt::TypeName const& targetType, - winrt::IInspectable const& parameter, - winrt::hstring const& language) -{ - if (const auto brush = unbox_value(value)) - { - return box_value(brush.Color()); - } - else - { - return nullptr; - } -} - -winrt::IInspectable SolidColorBrushToColorConverter::ConvertBack( - winrt::IInspectable const& value, - winrt::TypeName const& targetType, - winrt::IInspectable const& parameter, - winrt::hstring const& language) -{ - winrt::throw_hresult(E_NOTIMPL); -} diff --git a/dev/Common/SolidColorBrushToColorConverter.h b/dev/Common/SolidColorBrushToColorConverter.h deleted file mode 100644 index 5ab687739d..0000000000 --- a/dev/Common/SolidColorBrushToColorConverter.h +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. See LICENSE in the project root for license information. - -#pragma once -#include "SolidColorBrushToColorConverter.g.h" - -class SolidColorBrushToColorConverter : - public winrt::implementation::SolidColorBrushToColorConverterT -{ -public: - winrt::IInspectable Convert( - winrt::IInspectable const& value, - winrt::TypeName const& targetType, - winrt::IInspectable const& parameter, - winrt::hstring const& language); - - winrt::IInspectable ConvertBack( - winrt::IInspectable const& value, - winrt::TypeName const& targetType, - winrt::IInspectable const& parameter, - winrt::hstring const& language); -}; diff --git a/dev/Common/SolidColorBrushToColorConverter.idl b/dev/Common/SolidColorBrushToColorConverter.idl deleted file mode 100644 index 52535f933e..0000000000 --- a/dev/Common/SolidColorBrushToColorConverter.idl +++ /dev/null @@ -1,11 +0,0 @@ -namespace MU_XCP_NAMESPACE -{ - -[WUXC_VERSION_MUXONLY] -[webhosthidden] -[default_interface] -runtimeclass SolidColorBrushToColorConverter : Windows.UI.Xaml.DependencyObject, Windows.UI.Xaml.Data.IValueConverter -{ - SolidColorBrushToColorConverter(); -}; -} diff --git a/dev/CommonStyles/Common_themeresources.xaml b/dev/CommonStyles/Common_themeresources.xaml index 6c9978fce7..8c50cbf79d 100644 --- a/dev/CommonStyles/Common_themeresources.xaml +++ b/dev/CommonStyles/Common_themeresources.xaml @@ -39,5 +39,4 @@ 0 - diff --git a/dev/ProgressBar/ProgressBar.xaml b/dev/ProgressBar/ProgressBar.xaml index 9c9b1616c9..3d3c03e135 100644 --- a/dev/ProgressBar/ProgressBar.xaml +++ b/dev/ProgressBar/ProgressBar.xaml @@ -76,7 +76,7 @@ - + Date: Wed, 26 Aug 2020 18:24:30 +0200 Subject: [PATCH 3/9] Cleanup --- dev/CommonStyles/Common_themeresources.xaml | 3 +-- ...olidColorBrushToColorConverter.properties.cpp | 16 ---------------- 2 files changed, 1 insertion(+), 18 deletions(-) delete mode 100644 dev/Generated/SolidColorBrushToColorConverter.properties.cpp diff --git a/dev/CommonStyles/Common_themeresources.xaml b/dev/CommonStyles/Common_themeresources.xaml index 8c50cbf79d..e85e54f91b 100644 --- a/dev/CommonStyles/Common_themeresources.xaml +++ b/dev/CommonStyles/Common_themeresources.xaml @@ -1,8 +1,7 @@  + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> #C50500 + From 410d297c4b0ead129d1b81b89e49a5d3d07b38ec Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Fri, 11 Sep 2020 09:46:39 +0200 Subject: [PATCH 7/9] Update theme resource file --- dev/CommonStyles/CommonStyles.vcxitems | 5 ----- dev/ProgressBar/ProgressBar.vcxitems | 3 ++- .../ProgressBar_themeresources.xaml | 4 ++-- 3 files changed, 4 insertions(+), 8 deletions(-) rename dev/{CommonStyles => ProgressBar}/ProgressBar_themeresources.xaml (99%) diff --git a/dev/CommonStyles/CommonStyles.vcxitems b/dev/CommonStyles/CommonStyles.vcxitems index fca4fc351e..68c75c96e9 100644 --- a/dev/CommonStyles/CommonStyles.vcxitems +++ b/dev/CommonStyles/CommonStyles.vcxitems @@ -87,11 +87,6 @@ RS1 ThemeResources - - RS1 - ThemeResources - true - RS1 ThemeResources diff --git a/dev/ProgressBar/ProgressBar.vcxitems b/dev/ProgressBar/ProgressBar.vcxitems index 33847bd6e0..ffd8af5304 100644 --- a/dev/ProgressBar/ProgressBar.vcxitems +++ b/dev/ProgressBar/ProgressBar.vcxitems @@ -33,6 +33,7 @@ RS1 DefaultStyle + @@ -40,4 +41,4 @@ - + \ No newline at end of file diff --git a/dev/CommonStyles/ProgressBar_themeresources.xaml b/dev/ProgressBar/ProgressBar_themeresources.xaml similarity index 99% rename from dev/CommonStyles/ProgressBar_themeresources.xaml rename to dev/ProgressBar/ProgressBar_themeresources.xaml index 2f0534fedb..88b2d5caa9 100644 --- a/dev/CommonStyles/ProgressBar_themeresources.xaml +++ b/dev/ProgressBar/ProgressBar_themeresources.xaml @@ -21,8 +21,8 @@ 1 4 1 - #C50500 - + #FFF000 + From 909300a3cb1b1c9ace81b8b94ef71696e0badf3c Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Fri, 11 Sep 2020 21:11:28 +0200 Subject: [PATCH 8/9] Update vcx file --- dev/ProgressBar/ProgressBar.vcxitems | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/dev/ProgressBar/ProgressBar.vcxitems b/dev/ProgressBar/ProgressBar.vcxitems index ffd8af5304..adfd588304 100644 --- a/dev/ProgressBar/ProgressBar.vcxitems +++ b/dev/ProgressBar/ProgressBar.vcxitems @@ -33,7 +33,11 @@ RS1 DefaultStyle - + + RS1 + ThemeResources + true + From 5ab2d71bc11ebde6c3da2754f4d8b2257403a3bd Mon Sep 17 00:00:00 2001 From: Marcel Wagner Date: Fri, 18 Sep 2020 20:13:30 +0200 Subject: [PATCH 9/9] CR feedback --- dev/ProgressBar/ProgressBar_themeresources.xaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dev/ProgressBar/ProgressBar_themeresources.xaml b/dev/ProgressBar/ProgressBar_themeresources.xaml index 88b2d5caa9..4eb5f7f091 100644 --- a/dev/ProgressBar/ProgressBar_themeresources.xaml +++ b/dev/ProgressBar/ProgressBar_themeresources.xaml @@ -11,7 +11,7 @@ 0 #33FFFFFF #FFF000 - + @@ -22,7 +22,7 @@ 4 1 #FFF000 - + @@ -35,7 +35,7 @@ #29C50500 #C50500 - +