Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions source/uwp/Renderer/AdaptiveCardRenderer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,12 @@
</ClCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="lib\ActionHelpers.cpp" />
<ClCompile Include="lib\AdaptiveHighlightColorConfig.cpp" />
<ClCompile Include="lib\AdaptiveRequirement.cpp" />
<ClCompile Include="lib\ElementTagContent.cpp" />
<ClCompile Include="lib\XamlHelpers.cpp" />
<ClInclude Include="lib\ActionHelpers.h" />
<ClInclude Include="lib\AdaptiveActionElement.h" />
<ClInclude Include="lib\AdaptiveActionInvoker.h" />
<ClInclude Include="lib\AdaptiveActionParserRegistration.h" />
Expand Down
5 changes: 4 additions & 1 deletion source/uwp/Renderer/AdaptiveCardRenderer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@
<ClCompile Include="lib\AdaptiveFontTypeDefinition.cpp" />
<ClCompile Include="lib\AdaptiveFontTypesDefinition.cpp" />
<ClCompile Include="lib\AdaptiveRequirement.cpp" />
<ClCompile Include="lib\ActionHelpers.cpp" />
<ClCompile Include="lib\XamlHelpers.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="lib\AdaptiveCard.h" />
Expand Down Expand Up @@ -231,8 +233,9 @@
<ClInclude Include="lib\AdaptiveFontTypeDefinition.h" />
<ClInclude Include="lib\AdaptiveFontTypesDefinition.h" />
<ClInclude Include="lib\AdaptiveRequirement.h" />
<ClInclude Include="lib\ActionHelpers.h" />
</ItemGroup>
<ItemGroup>
<Midl Include="idl\AdaptiveCards.Rendering.Uwp.idl" />
</ItemGroup>
</Project>
</Project>
595 changes: 595 additions & 0 deletions source/uwp/Renderer/lib/ActionHelpers.cpp

Large diffs are not rendered by default.

39 changes: 39 additions & 0 deletions source/uwp/Renderer/lib/ActionHelpers.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#pragma once

namespace AdaptiveNamespace::ActionHelpers
{
HRESULT BuildAction(_In_ ABI::AdaptiveNamespace::IAdaptiveActionElement* adaptiveActionElement,
_In_ ABI::AdaptiveNamespace::IAdaptiveRenderContext* renderContext,
_In_ ABI::AdaptiveNamespace::IAdaptiveRenderArgs* renderArgs,
_Outptr_ ABI::Windows::UI::Xaml::IUIElement** actionControl);

HRESULT GetButtonMargin(_In_ ABI::AdaptiveNamespace::IAdaptiveActionsConfig* actionsConfig,
ABI::Windows::UI::Xaml::Thickness& buttonMargin) noexcept;

void ArrangeButtonContent(_In_ ABI::AdaptiveNamespace::IAdaptiveActionElement* action,
_In_ ABI::AdaptiveNamespace::IAdaptiveActionsConfig* actionsConfig,
_In_ ABI::AdaptiveNamespace::IAdaptiveRenderContext* renderContext,
ABI::AdaptiveNamespace::ContainerStyle containerStyle,
_In_ ABI::AdaptiveNamespace::IAdaptiveHostConfig* hostConfig,
bool allActionsHaveIcons,
_In_ ABI::Windows::UI::Xaml::Controls::IButton* button);

HRESULT SetMatchingHeight(_In_ ABI::Windows::UI::Xaml::IFrameworkElement* elementToChange,
_In_ ABI::Windows::UI::Xaml::IFrameworkElement* elementToMatch);

HRESULT HandleActionStyling(_In_ ABI::AdaptiveNamespace::IAdaptiveActionElement* adaptiveActionElement,
_In_ ABI::Windows::UI::Xaml::IFrameworkElement* buttonFrameworkElement,
_In_ ABI::AdaptiveNamespace::IAdaptiveRenderContext* renderContext);

bool WarnForInlineShowCard(_In_ ABI::AdaptiveNamespace::IAdaptiveRenderContext* renderContext,
_In_ ABI::AdaptiveNamespace::IAdaptiveActionElement* action,
const std::wstring& warning);

void HandleInlineAction(_In_ ABI::AdaptiveNamespace::IAdaptiveRenderContext* renderContext,
_In_ ABI::AdaptiveNamespace::IAdaptiveRenderArgs* renderArgs,
_In_ ABI::Windows::UI::Xaml::Controls::ITextBox* textBox,
_In_ ABI::AdaptiveNamespace::IAdaptiveActionElement* inlineAction,
_COM_Outptr_ ABI::Windows::UI::Xaml::IUIElement** textBoxWithInlineAction);
}
1 change: 0 additions & 1 deletion source/uwp/Renderer/lib/AdaptiveActionElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.
#include "pch.h"
#include "AdaptiveActionElement.h"
#include "Util.h"

using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
Expand Down
4 changes: 0 additions & 4 deletions source/uwp/Renderer/lib/AdaptiveActionElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// Licensed under the MIT License.
#pragma once

#include "AdaptiveCards.Rendering.Uwp.h"
#include <windows.foundation.h>
#include "Enums.h"

namespace AdaptiveNamespace
{
class DECLSPEC_UUID("CDCCC115-7C53-4A04-9F5B-754BBC00C80E") AdaptiveActionElementBase : public IUnknown
Expand Down
35 changes: 15 additions & 20 deletions source/uwp/Renderer/lib/AdaptiveActionSet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,26 @@
#include "pch.h"
#include "AdaptiveActionSet.h"

#include "Util.h"
#include "Vector.h"
#include <windows.foundation.collections.h>

using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
using namespace ABI::AdaptiveNamespace;
using namespace ABI::Windows::Foundation::Collections;
using namespace ABI::Windows::UI::Xaml;
using namespace ABI::Windows::UI::Xaml::Controls;

namespace AdaptiveCards { namespace Rendering { namespace Uwp
namespace AdaptiveNamespace
{
AdaptiveActionSet::AdaptiveActionSet()
{
m_actions = Microsoft::WRL::Make<Vector<IAdaptiveActionElement*>>();
}
AdaptiveActionSet::AdaptiveActionSet() { m_actions = Microsoft::WRL::Make<Vector<IAdaptiveActionElement*>>(); }

HRESULT AdaptiveActionSet::RuntimeClassInitialize() noexcept try
{
std::shared_ptr<AdaptiveCards::ActionSet> ActionSet = std::make_shared<AdaptiveCards::ActionSet>();
return RuntimeClassInitialize(ActionSet);
} CATCH_RETURN;
}
CATCH_RETURN;

_Use_decl_annotations_
HRESULT AdaptiveActionSet::RuntimeClassInitialize(const std::shared_ptr<AdaptiveCards::ActionSet>& sharedActionSet) try
_Use_decl_annotations_ HRESULT AdaptiveActionSet::RuntimeClassInitialize(const std::shared_ptr<AdaptiveCards::ActionSet>& sharedActionSet)

@RebeccaAnne RebeccaAnne Sep 18, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use_decl_annotations [](start = 4, length = 22)

While you're here, maybe remove these Use_decl_annotations here. #Closed

try
{
if (sharedActionSet == nullptr)
{
Expand All @@ -38,22 +32,22 @@ namespace AdaptiveCards { namespace Rendering { namespace Uwp
RETURN_IF_FAILED(GenerateActionsProjection(sharedActionSet->GetActions(), m_actions.Get()));
InitializeBaseElement(std::static_pointer_cast<BaseCardElement>(sharedActionSet));
return S_OK;
} CATCH_RETURN;
}
CATCH_RETURN;

_Use_decl_annotations_
HRESULT AdaptiveActionSet::get_Actions(IVector<IAdaptiveActionElement*>** items)
_Use_decl_annotations_ HRESULT AdaptiveActionSet::get_Actions(IVector<IAdaptiveActionElement*>** items)
{
return m_actions.CopyTo(items);
}

_Use_decl_annotations_
HRESULT AdaptiveActionSet::get_ElementType(ElementType* elementType)
_Use_decl_annotations_ HRESULT AdaptiveActionSet::get_ElementType(ElementType* elementType)
{
*elementType = ElementType::ActionSet;
return S_OK;
}

HRESULT AdaptiveActionSet::GetSharedModel(std::shared_ptr<AdaptiveCards::BaseCardElement>& sharedModel) try
HRESULT AdaptiveActionSet::GetSharedModel(std::shared_ptr<AdaptiveCards::BaseCardElement>& sharedModel)
try
{
std::shared_ptr<AdaptiveCards::ActionSet> actionSet = std::make_shared<AdaptiveCards::ActionSet>();
RETURN_IF_FAILED(SetSharedElementProperties(std::static_pointer_cast<AdaptiveCards::BaseCardElement>(actionSet)));
Expand All @@ -62,5 +56,6 @@ namespace AdaptiveCards { namespace Rendering { namespace Uwp

sharedModel = actionSet;
return S_OK;
}CATCH_RETURN;
}}}
}
CATCH_RETURN;
}
9 changes: 3 additions & 6 deletions source/uwp/Renderer/lib/AdaptiveActionSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@
// Licensed under the MIT License.
#pragma once

#include "AdaptiveCards.Rendering.Uwp.h"
#include "Enums.h"
#include "ActionSet.h"
#include <windows.foundation.h>
#include "AdaptiveCardElement.h"

namespace AdaptiveNamespace
{
Expand All @@ -17,9 +13,10 @@ namespace AdaptiveNamespace
Microsoft::WRL::CloakedIid<ITypePeek>,
Microsoft::WRL::CloakedIid<AdaptiveNamespace::AdaptiveCardElementBase>>
{
InspectableClass(RuntimeClass_AdaptiveCards_Rendering_Uwp_AdaptiveActionSet, BaseTrust)
InspectableClass(RuntimeClass_AdaptiveCards_Rendering_Uwp_AdaptiveActionSet, BaseTrust);

public : AdaptiveActionSet();
public:
AdaptiveActionSet();
HRESULT RuntimeClassInitialize() noexcept;
HRESULT RuntimeClassInitialize(_In_ const std::shared_ptr<AdaptiveCards::ActionSet>& sharedActionSet);

Expand Down
47 changes: 35 additions & 12 deletions source/uwp/Renderer/lib/AdaptiveActionSetRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,20 @@

#include "AdaptiveActionSet.h"
#include "AdaptiveActionSetRenderer.h"
#include "AdaptiveShowCardActionRenderer.h"

@RebeccaAnne RebeccaAnne Sep 18, 2019 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? #Closed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope... looks like some of the other ones are also unneeded. Probably snuck in while I was trying to get things building :)


In reply to: 325838868 [](ancestors = 325838868)

#include "AdaptiveElementParserRegistration.h"
#include "enums.h"
#include "Util.h"
#include "XamlBuilder.h"
#include "AdaptiveImage.h"
#include "AdaptiveRenderArgs.h"
#include "ActionHelpers.h"

using namespace Microsoft::WRL;
using namespace Microsoft::WRL::Wrappers;
using namespace ABI::AdaptiveNamespace;
using namespace ABI::Windows::Foundation;
using namespace ABI::Windows::Foundation::Collections;
using namespace ABI::Windows::UI::Xaml;
using namespace ABI::Windows::UI::Xaml::Controls;
using namespace ABI::Windows::UI::Xaml::Controls::Primitives;

namespace AdaptiveNamespace
{
Expand All @@ -22,15 +27,6 @@ namespace AdaptiveNamespace
}
CATCH_RETURN;

HRESULT AdaptiveActionSetRenderer::Render(_In_ IAdaptiveCardElement* cardElement,
_In_ IAdaptiveRenderContext* renderContext,
_In_ IAdaptiveRenderArgs* renderArgs,
_COM_Outptr_ ABI::Windows::UI::Xaml::IUIElement** result) noexcept try
{
return XamlBuilder::BuildActionSet(cardElement, renderContext, renderArgs, result);
}
CATCH_RETURN;

HRESULT AdaptiveActionSetRenderer::FromJson(
_In_ ABI::Windows::Data::Json::IJsonObject* jsonObject,
_In_ ABI::AdaptiveNamespace::IAdaptiveElementParserRegistration* elementParserRegistration,
Expand All @@ -42,4 +38,31 @@ namespace AdaptiveNamespace
jsonObject, elementParserRegistration, actionParserRegistration, adaptiveWarnings, element);
}
CATCH_RETURN;

HRESULT AdaptiveActionSetRenderer::Render(_In_ IAdaptiveCardElement* adaptiveCardElement,
_In_ IAdaptiveRenderContext* renderContext,
_In_ IAdaptiveRenderArgs* renderArgs,
_COM_Outptr_ IUIElement** actionSetControl) noexcept try
{
ComPtr<IAdaptiveHostConfig> hostConfig;
RETURN_IF_FAILED(renderContext->get_HostConfig(&hostConfig));

if (!XamlHelpers::SupportsInteractivity(hostConfig.Get()))
{
renderContext->AddWarning(
ABI::AdaptiveNamespace::WarningStatusCode::InteractivityNotSupported,
HStringReference(L"ActionSet was stripped from card because interactivity is not supported").Get());
return S_OK;
}

ComPtr<IAdaptiveCardElement> cardElement(adaptiveCardElement);
ComPtr<IAdaptiveActionSet> adaptiveActionSet;
RETURN_IF_FAILED(cardElement.As(&adaptiveActionSet));

ComPtr<IVector<IAdaptiveActionElement*>> actions;
RETURN_IF_FAILED(adaptiveActionSet->get_Actions(&actions));

return XamlHelpers::BuildActionSetHelper(nullptr, adaptiveActionSet.Get(), actions.Get(), renderContext, renderArgs, actionSetControl);
}
CATCH_RETURN;
}
7 changes: 3 additions & 4 deletions source/uwp/Renderer/lib/AdaptiveActionSetRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// Licensed under the MIT License.
#pragma once

#include "AdaptiveCards.Rendering.Uwp.h"
#include "Enums.h"
#include "ActionSet.h"

namespace AdaptiveNamespace
Expand All @@ -13,9 +11,10 @@ namespace AdaptiveNamespace
ABI::AdaptiveNamespace::IAdaptiveElementRenderer,
ABI::AdaptiveNamespace::IAdaptiveElementParser>
{
InspectableClass(RuntimeClass_AdaptiveCards_Rendering_Uwp_AdaptiveActionSetRenderer, BaseTrust)
InspectableClass(RuntimeClass_AdaptiveCards_Rendering_Uwp_AdaptiveActionSetRenderer, BaseTrust);

public : HRESULT RuntimeClassInitialize() noexcept;
public:
HRESULT RuntimeClassInitialize() noexcept;

IFACEMETHODIMP Render(_In_ ABI::AdaptiveNamespace::IAdaptiveCardElement* cardElement,
_In_ ABI::AdaptiveNamespace::IAdaptiveRenderContext* renderContext,
Expand Down
1 change: 0 additions & 1 deletion source/uwp/Renderer/lib/AdaptiveActionsConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#include "pch.h"
#include "AdaptiveActionsConfig.h"
#include "AdaptiveShowCardActionConfig.h"
#include "Util.h"

using namespace Microsoft::WRL;
using namespace ABI::AdaptiveNamespace;
Expand Down
4 changes: 0 additions & 4 deletions source/uwp/Renderer/lib/AdaptiveActionsConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// Licensed under the MIT License.
#pragma once

#include "AdaptiveCards.Rendering.Uwp.h"
#include "Enums.h"
#include "HostConfig.h"

namespace AdaptiveNamespace
{
class AdaptiveActionsConfig
Expand Down
3 changes: 0 additions & 3 deletions source/uwp/Renderer/lib/AdaptiveBackgroundImage.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@
// Licensed under the MIT License.
#pragma once

#include "AdaptiveCards.Rendering.Uwp.h"
#include "Enums.h"
#include "BackgroundImage.h"
#include <windows.foundation.h>

namespace AdaptiveNamespace
{
Expand Down
1 change: 0 additions & 1 deletion source/uwp/Renderer/lib/AdaptiveCard.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
// Licensed under the MIT License.
#pragma once

#include "AdaptiveCards.Rendering.Uwp.h"
#include "SharedAdaptiveCard.h"
#include "AdaptiveBackgroundImage.h"

Expand Down
4 changes: 0 additions & 4 deletions source/uwp/Renderer/lib/AdaptiveCardConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
// Licensed under the MIT License.
#pragma once

#include "AdaptiveCards.Rendering.Uwp.h"
#include "Enums.h"
#include "HostConfig.h"

namespace AdaptiveNamespace
{
class AdaptiveCardConfig
Expand Down
3 changes: 1 addition & 2 deletions source/uwp/Renderer/lib/AdaptiveCardElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// Licensed under the MIT License.
#pragma once

#include "AdaptiveCards.Rendering.Uwp.h"
#include "SemanticVersion.h"
#include "Enums.h"
#include "BaseElement.h"

namespace AdaptiveNamespace
{
Expand Down
Loading