-
Notifications
You must be signed in to change notification settings - Fork 693
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Teaching Tip's Rounded Corners (#1305)
* Attempt to fix a rare crash in calculator app. * Do proper event token clean up. * Use the routedEventHelpers instead of doing these events by hand * Clean up * Fix a silly mistake * rename handler to revoker * PTR: Fix high contrast list item display, remove background and add border to display PTR correctly in test page * Fix teaching tips adorners to be compatible with rounded corners. * Rename the converter peices * UseNonstandardConditionalXaml * move converter definitions out of the teaching tip style.
- Loading branch information
1 parent
96b64c0
commit a29c1b4
Showing
12 changed files
with
303 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
#include <pch.h> | ||
#include <common.h> | ||
#include "CornerRadiusToThicknessConverter.h" | ||
|
||
winrt::Thickness CornerRadiusToThicknessConverter::Convert(winrt::CornerRadius const& radius, winrt::CornerRadiusToThicknessConverterKind const& filterKind) | ||
{ | ||
auto result = winrt::Thickness{}; | ||
|
||
switch (filterKind) | ||
{ | ||
case winrt::CornerRadiusToThicknessConverterKind::FilterLeftAndRightFromTop: | ||
result.Left = radius.TopLeft; | ||
result.Right = radius.TopRight; | ||
result.Top = 0; | ||
result.Bottom = 0; | ||
break; | ||
case winrt::CornerRadiusToThicknessConverterKind::FilterLeftAndRightFromBottom: | ||
result.Left = radius.BottomLeft; | ||
result.Right = radius.BottomRight; | ||
result.Top = 0; | ||
result.Bottom = 0; | ||
break; | ||
case winrt::CornerRadiusToThicknessConverterKind::FilterTopAndBottomFromLeft: | ||
result.Left = 0; | ||
result.Right = 0; | ||
result.Top = radius.TopLeft; | ||
result.Bottom = radius.BottomLeft; | ||
break; | ||
case winrt::CornerRadiusToThicknessConverterKind::FilterTopAndBottomFromRight: | ||
result.Left = 0; | ||
result.Right = 0; | ||
result.Top = radius.TopRight; | ||
result.Bottom = radius.BottomRight; | ||
break; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
winrt::IInspectable CornerRadiusToThicknessConverter::Convert( | ||
winrt::IInspectable const& value, | ||
winrt::TypeName const& targetType, | ||
winrt::IInspectable const& parameter, | ||
winrt::hstring const& language) | ||
{ | ||
auto radius = unbox_value<winrt::CornerRadius>(value); | ||
|
||
return box_value(Convert(radius, ConversionKind())); | ||
} | ||
|
||
winrt::IInspectable CornerRadiusToThicknessConverter::ConvertBack( | ||
winrt::IInspectable const& value, | ||
winrt::TypeName const& targetType, | ||
winrt::IInspectable const& parameter, | ||
winrt::hstring const& language) | ||
{ | ||
winrt::throw_hresult(E_NOTIMPL); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
#pragma once | ||
#include "CornerRadiusToThicknessConverter.g.h" | ||
#include "CornerRadiusToThicknessConverter.properties.h" | ||
|
||
class CornerRadiusToThicknessConverter : | ||
public winrt::implementation::CornerRadiusToThicknessConverterT<CornerRadiusToThicknessConverter>, | ||
public CornerRadiusToThicknessConverterProperties | ||
{ | ||
public: | ||
winrt::Thickness Convert( | ||
winrt::CornerRadius const& radius, | ||
winrt::CornerRadiusToThicknessConverterKind const& filterKind); | ||
|
||
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); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
namespace MU_XCP_NAMESPACE | ||
{ | ||
|
||
[WUXC_VERSION_MUXONLY] | ||
[webhosthidden] | ||
[default_interface] | ||
runtimeclass CornerRadiusToThicknessConverter : Windows.UI.Xaml.DependencyObject, Windows.UI.Xaml.Data.IValueConverter | ||
{ | ||
CornerRadiusToThicknessConverter(); | ||
|
||
[MUX_DEFAULT_VALUE("winrt::CornerRadiusToThicknessConverterKind::FilterLeftAndRightFromTop")] | ||
CornerRadiusToThicknessConverterKind ConversionKind{ get; set; }; | ||
|
||
static Windows.UI.Xaml.DependencyProperty ConversionKindProperty{ get; }; | ||
}; | ||
|
||
[WUXC_VERSION_MUXONLY] | ||
[webhosthidden] | ||
enum CornerRadiusToThicknessConverterKind | ||
{ | ||
FilterTopAndBottomFromLeft, | ||
FilterTopAndBottomFromRight, | ||
FilterLeftAndRightFromTop, | ||
FilterLeftAndRightFromBottom, | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
dev/Generated/CornerRadiusToThicknessConverter.properties.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// 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 "CornerRadiusToThicknessConverter.h" | ||
|
||
CppWinRTActivatableClassWithDPFactory(CornerRadiusToThicknessConverter) | ||
|
||
GlobalDependencyProperty CornerRadiusToThicknessConverterProperties::s_ConversionKindProperty{ nullptr }; | ||
|
||
CornerRadiusToThicknessConverterProperties::CornerRadiusToThicknessConverterProperties() | ||
{ | ||
EnsureProperties(); | ||
} | ||
|
||
void CornerRadiusToThicknessConverterProperties::EnsureProperties() | ||
{ | ||
if (!s_ConversionKindProperty) | ||
{ | ||
s_ConversionKindProperty = | ||
InitializeDependencyProperty( | ||
L"ConversionKind", | ||
winrt::name_of<winrt::CornerRadiusToThicknessConverterKind>(), | ||
winrt::name_of<winrt::CornerRadiusToThicknessConverter>(), | ||
false /* isAttached */, | ||
ValueHelper<winrt::CornerRadiusToThicknessConverterKind>::BoxValueIfNecessary(winrt::CornerRadiusToThicknessConverterKind::FilterLeftAndRightFromTop), | ||
nullptr); | ||
} | ||
} | ||
|
||
void CornerRadiusToThicknessConverterProperties::ClearProperties() | ||
{ | ||
s_ConversionKindProperty = nullptr; | ||
} | ||
|
||
void CornerRadiusToThicknessConverterProperties::ConversionKind(winrt::CornerRadiusToThicknessConverterKind const& value) | ||
{ | ||
static_cast<CornerRadiusToThicknessConverter*>(this)->SetValue(s_ConversionKindProperty, ValueHelper<winrt::CornerRadiusToThicknessConverterKind>::BoxValueIfNecessary(value)); | ||
} | ||
|
||
winrt::CornerRadiusToThicknessConverterKind CornerRadiusToThicknessConverterProperties::ConversionKind() | ||
{ | ||
return ValueHelper<winrt::CornerRadiusToThicknessConverterKind>::CastOrUnbox(static_cast<CornerRadiusToThicknessConverter*>(this)->GetValue(s_ConversionKindProperty)); | ||
} |
21 changes: 21 additions & 0 deletions
21
dev/Generated/CornerRadiusToThicknessConverter.properties.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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 | ||
#pragma once | ||
|
||
class CornerRadiusToThicknessConverterProperties | ||
{ | ||
public: | ||
CornerRadiusToThicknessConverterProperties(); | ||
|
||
void ConversionKind(winrt::CornerRadiusToThicknessConverterKind const& value); | ||
winrt::CornerRadiusToThicknessConverterKind ConversionKind(); | ||
|
||
static winrt::DependencyProperty ConversionKindProperty() { return s_ConversionKindProperty; } | ||
|
||
static GlobalDependencyProperty s_ConversionKindProperty; | ||
|
||
static void EnsureProperties(); | ||
static void ClearProperties(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// 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 "ThicknessFilterConverter.h" | ||
|
||
CppWinRTActivatableClassWithDPFactory(ThicknessFilterConverter) | ||
|
||
GlobalDependencyProperty ThicknessFilterConverterProperties::s_FilterProperty{ nullptr }; | ||
|
||
ThicknessFilterConverterProperties::ThicknessFilterConverterProperties() | ||
{ | ||
EnsureProperties(); | ||
} | ||
|
||
void ThicknessFilterConverterProperties::EnsureProperties() | ||
{ | ||
if (!s_FilterProperty) | ||
{ | ||
s_FilterProperty = | ||
InitializeDependencyProperty( | ||
L"Filter", | ||
winrt::name_of<winrt::ThicknessFilterConverterKind>(), | ||
winrt::name_of<winrt::ThicknessFilterConverter>(), | ||
false /* isAttached */, | ||
ValueHelper<winrt::ThicknessFilterConverterKind>::BoxValueIfNecessary(winrt::ThicknessFilterConverterKind::Top), | ||
nullptr); | ||
} | ||
} | ||
|
||
void ThicknessFilterConverterProperties::ClearProperties() | ||
{ | ||
s_FilterProperty = nullptr; | ||
} | ||
|
||
void ThicknessFilterConverterProperties::Filter(winrt::ThicknessFilterConverterKind const& value) | ||
{ | ||
static_cast<ThicknessFilterConverter*>(this)->SetValue(s_FilterProperty, ValueHelper<winrt::ThicknessFilterConverterKind>::BoxValueIfNecessary(value)); | ||
} | ||
|
||
winrt::ThicknessFilterConverterKind ThicknessFilterConverterProperties::Filter() | ||
{ | ||
return ValueHelper<winrt::ThicknessFilterConverterKind>::CastOrUnbox(static_cast<ThicknessFilterConverter*>(this)->GetValue(s_FilterProperty)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// 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 | ||
#pragma once | ||
|
||
class ThicknessFilterConverterProperties | ||
{ | ||
public: | ||
ThicknessFilterConverterProperties(); | ||
|
||
void Filter(winrt::ThicknessFilterConverterKind const& value); | ||
winrt::ThicknessFilterConverterKind Filter(); | ||
|
||
static winrt::DependencyProperty FilterProperty() { return s_FilterProperty; } | ||
|
||
static GlobalDependencyProperty s_FilterProperty; | ||
|
||
static void EnsureProperties(); | ||
static void ClearProperties(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.