-
Notifications
You must be signed in to change notification settings - Fork 705
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add CornerRadiusFilterConverter and fix FlipView corner radius #967
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
18b55e0
Add converter
90053ff
Fix FlipView CornerRadius
4f08ca1
Add test and address cr feedback
415a7e6
cr feedback2
db56d68
Move to api test
987c7d6
Merge branch 'master' into user/kaiguo/corner-radius-converter
c728c7f
cr feedbacks
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,60 @@ | ||
// 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 "Converters.h" | ||
|
||
CppWinRTActivatableClassWithBasicFactory(CornerRadiusFilterConverter) | ||
|
||
CornerRadiusFilterConverter::CornerRadiusFilterConverter() | ||
{ | ||
} | ||
|
||
winrt::IInspectable CornerRadiusFilterConverter::Convert( | ||
winrt::IInspectable const& value, | ||
winrt::TypeName const& targetType, | ||
winrt::IInspectable const& parameter, | ||
winrt::hstring const& language) | ||
{ | ||
auto radius = unbox_value<winrt::CornerRadius>(value); | ||
auto filter = unbox_value<winrt::hstring>(parameter); | ||
|
||
winrt::CornerRadius result; | ||
kaiguo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
result.TopLeft = radius.TopLeft; | ||
result.TopRight = radius.TopRight; | ||
result.BottomRight = radius.BottomRight; | ||
result.BottomLeft = radius.BottomLeft; | ||
|
||
if (filter == L"Top") | ||
{ | ||
result.BottomLeft = 0; | ||
result.BottomRight = 0; | ||
} | ||
else if (filter == L"Right") | ||
{ | ||
result.TopLeft = 0; | ||
result.BottomLeft = 0; | ||
} | ||
else if (filter == L"Bottom") | ||
{ | ||
result.TopLeft = 0; | ||
result.TopRight = 0; | ||
} | ||
else if (filter == L"Left") | ||
{ | ||
result.TopRight = 0; | ||
result.BottomRight = 0; | ||
} | ||
|
||
return box_value(result); | ||
kaiguo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
winrt::IInspectable CornerRadiusFilterConverter::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,24 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT License. See LICENSE in the project root for license information. | ||
|
||
#pragma once | ||
#include "CornerRadiusFilterConverter.g.h" | ||
|
||
class CornerRadiusFilterConverter : | ||
public winrt::implementation::CornerRadiusFilterConverterT<CornerRadiusFilterConverter> | ||
{ | ||
public: | ||
CornerRadiusFilterConverter(); | ||
|
||
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,14 @@ | ||
namespace MU_XC_NAMESPACE | ||
kaiguo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{ | ||
|
||
[bindable] | ||
[WUXC_VERSION_PREVIEW] | ||
[webhosthidden] | ||
runtimeclass CornerRadiusFilterConverter : Windows.UI.Xaml.Data.IValueConverter | ||
{ | ||
CornerRadiusFilterConverter(); | ||
Object Convert(Object value, Windows.UI.Xaml.Interop.TypeName targetType, Object parameter, String language); | ||
kaiguo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Object ConvertBack(Object value, Windows.UI.Xaml.Interop.TypeName targetType, Object parameter, String 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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to make this an enum? Or does that make things more complicated to author in the markup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just tried but looks like the auto string-enum conversion only works in style setters, and using the enum type directly in xaml didn't seem to work either.
I've added an invalid arg exception to help enforce the values.