Skip to content

Commit 3faa6de

Browse files
anna-dinglerjwoo-msftalmedina-msrahulamlekarRahulAmlekar
authored
[UWP] Sync release branch with main (#8330)
* Switch to gotFocus (#8148) (#8150) * Update custom.props * [UWP] Update custom.props for object model release (#8225) * Update custom.props for object model release * Updated Xcode version (#8222) * removed build step as they are redundant (#8201) * removed build step as they are redundant * added pod installation step Co-authored-by: Joseph Woo <[email protected]> * [UWP Renderer] Add a null check to inline action rendering (#8228) * Update custom.props for object model release * Updated Xcode version (#8222) * removed build step as they are redundant (#8201) * removed build step as they are redundant * added pod installation step * Add a null check for inline Actions Co-authored-by: Joseph Woo <[email protected]> * [UWP][Infra] Update nuget files for release (#6576) (#8240) * [UWP][Infra] Update nuget files for release (#6576) * Add new nuspec files * Fix nuspec * Update build copy script * Add dependency to renderer * 1.5 website schema explorer updates (#6550) * Updating schema explorer properties * adding tableCell to toc and attempting whitespace fix * indentation fix indentation fix * Removing filtered prop Removing filtered prop - it's auto generated in our build Co-authored-by: RahulAmlekar <[email protected]> * Custom.props to 1.0.0 for Object model build * Update dependency version Co-authored-by: Rahul Amlekar <[email protected]> Co-authored-by: RahulAmlekar <[email protected]> Co-authored-by: Rebecca Muraira <[email protected]> * Remove blank lines Co-authored-by: almedina-ms <[email protected]> Co-authored-by: Rahul Amlekar <[email protected]> Co-authored-by: RahulAmlekar <[email protected]> Co-authored-by: Rebecca Muraira <[email protected]> * [UWP Renderer] Parse for SVG width and height (#8256) * WIP: set raster height and width * WIP: add template method * WIP: parse svg for size * Update resources and spacing * update visualizer csproj * Only set height * Resolve PR comments * Remove try catch blocks * [UWP] Remove weak_ref from method headers and pass by value (#8295) * Temp branch * svg updates * Pass by value * Remove temp var * Use make_weak * Fix spacing * Resolve PR comments * Use image properties struct * Resolve PR comments and handle errors * Add test json * Update custom props (#8329) * Update the object model dependency (#8331) --------- Co-authored-by: Joseph Woo <[email protected]> Co-authored-by: almedina-ms <[email protected]> Co-authored-by: Rahul Amlekar <[email protected]> Co-authored-by: RahulAmlekar <[email protected]> Co-authored-by: Rebecca Muraira <[email protected]>
1 parent 50a7c52 commit 3faa6de

File tree

9 files changed

+478
-148
lines changed

9 files changed

+478
-148
lines changed

custom.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup Label="Version">
4-
<VersionMajor>1</VersionMajor>
4+
<VersionMajor>3</VersionMajor>
55
<VersionMinor>1</VersionMinor>
66
<!-- The nuget package version should be incremented when we produce QFEs -->
7-
<NuGetPackVersion>1.1.0</NuGetPackVersion>
7+
<NuGetPackVersion>3.1.1</NuGetPackVersion>
88
<VersionInfoProductName>AdaptiveCards</VersionInfoProductName>
99
</PropertyGroup>
1010
</Project>

samples/v1.5/Tests/Image.Svg.json

Lines changed: 65 additions & 0 deletions
Large diffs are not rendered by default.

source/uwp/NuGet/AdaptiveCards.Rendering.Uwp.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<license type="file">EULA-Windows.txt</license>
1414
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
1515
<dependencies>
16-
<dependency id="AdaptiveCards.ObjectModel.Uwp" version="1.0.0" />
16+
<dependency id="AdaptiveCards.ObjectModel.Uwp" version="1.1.0" />
1717
</dependencies>
1818
</metadata>
1919
<files>

source/uwp/SharedRenderer/lib/AdaptiveImageRenderer.cpp

Lines changed: 321 additions & 130 deletions
Large diffs are not rendered by default.

source/uwp/SharedRenderer/lib/Util.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,19 @@ std::string HStringToUTF8(winrt::hstring const& in)
9292
return WStringToString(in);
9393
}
9494

95+
std::optional<double> TryHStringToDouble(winrt::hstring const& in)
96+
{
97+
try
98+
{
99+
return std::stod(winrt::to_string(in));
100+
}
101+
catch (std::invalid_argument)
102+
{
103+
// in was not a valid double
104+
return {};
105+
}
106+
}
107+
95108
// Get a Color object from color string
96109
// Expected formats are "#AARRGGBB" (with alpha channel) and "#RRGGBB" (without alpha channel)
97110
winrt::Windows::UI::Color GetColorFromString(const std::string& colorString)

source/uwp/SharedRenderer/lib/Util.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ template<typename TStored> struct property_opt
9595
std::string WStringToString(std::wstring_view in);
9696
std::wstring StringToWString(std::string_view in);
9797

98+
std::optional<double> TryHStringToDouble(winrt::hstring const& in);
99+
98100
// This function is needed to deal with the fact that non-windows platforms handle Unicode without the need for wchar_t.
99101
// (which has a platform specific implementation) It converts a std::string to an HSTRING.
100102
winrt::hstring UTF8ToHString(std::string_view in);

source/uwp/SharedRenderer/lib/XamlBuilder.h

Lines changed: 49 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,18 @@ namespace AdaptiveCards::Rendering::Xaml_Rendering
1313
public:
1414
XamlBuilder();
1515

16+
template<typename TElement>
17+
struct ImageProperties
18+
{
19+
TElement uiElement;
20+
bool isAutoSize;
21+
winrt::IInspectable parentElement;
22+
winrt::IInspectable imageContainer;
23+
bool isVisible;
24+
boolean isImageSvg;
25+
winrt::Stretch stretch = winrt::Stretch::UniformToFill;
26+
};
27+
1628
// IImageLoadTrackerListener
1729
void AllImagesLoaded() override;
1830
void ImagesLoadingHadError() override;
@@ -54,34 +66,56 @@ namespace AdaptiveCards::Rendering::Xaml_Rendering
5466
winrt::AdaptiveRenderArgs const& renderArgs,
5567
XamlBuilder* xamlBuilder);
5668

57-
template<typename T>
58-
void SetAutoSize(T const& destination,
69+
template<typename TDest>
70+
void SetAutoSize(TDest const& destination,
5971
winrt::IInspectable const& parentElement,
6072
winrt::IInspectable const& imageContainer,
6173
bool isVisible,
6274
bool imageFiresOpenEvent);
6375

64-
template<typename T>
65-
void SetImageSource(T const& destination, winrt::ImageSource const& imageSource, winrt::Stretch stretch = winrt::Stretch::UniformToFill);
76+
template<typename TDest>
77+
void SetImageSource(TDest const& destination, winrt::ImageSource const& imageSource, winrt::Stretch stretch = winrt::Stretch::UniformToFill);
6678

67-
template<typename T>
68-
void SetImageOnUIElement(winrt::Uri const& imageUrl,
69-
T const& uiElement,
70-
winrt::AdaptiveCardResourceResolvers const& resolvers,
71-
bool isAutoSize,
72-
winrt::IInspectable const& parentElement,
73-
winrt::IInspectable const& imageContainer,
74-
bool isVisible,
75-
bool isImageSvg = false,
76-
winrt::Stretch stretch = winrt::Stretch::UniformToFill);
79+
template<typename TElement>
80+
winrt::ImageSource SetImageOnUIElement(winrt::Uri const& imageUrl,
81+
winrt::AdaptiveCardResourceResolvers const& resolvers,
82+
ImageProperties<TElement> const& imgProperties);
7783

7884
winrt::ImageSource CreateImageSource(bool isImageSvg);
7985

80-
template<typename T> void PopulateImageFromUrlAsync(winrt::Uri const& imageUrl, T const& imageControl, bool const& isImageSvg);
86+
template<typename TElement>
87+
winrt::ImageSource PopulateImageFromUrlAsync(winrt::Uri const& imageUrl,
88+
ImageProperties<TElement> const& imgProperties);
89+
90+
template<typename TElement, typename TStream>
91+
void HandleAccessStreamForImageSource(ImageProperties<TElement> const& imgProperties,
92+
TStream const& stream,
93+
winrt::ImageSource const& imageSource);
94+
95+
winrt::fire_and_forget SetSvgUriSource(winrt::SvgImageSource const imageSourceRef,
96+
winrt::Uri const uriRef);
97+
98+
template<typename TElement, typename TStream>
99+
winrt::IAsyncAction SetSvgImageSourceAsync(winrt::SvgImageSource const imageSourceRef,
100+
TStream const streamRef,
101+
ImageProperties<TElement> const imgProperties);
81102

82103
boolean IsSvgImage(std::string url);
83104

84105
void FireAllImagesLoaded();
85106
void FireImagesLoadingHadError();
107+
108+
bool ParseXmlForHeightAndWidth(winrt::XmlDocument const& xmlDoc,
109+
winrt::SvgImageSource const& imageSourceRef);
110+
111+
winrt::fire_and_forget SetRasterizedPixelHeightAsync(winrt::SvgImageSource const imageSourceRef,
112+
double const imageSize,
113+
bool const dropIfUnset = false);
114+
winrt::fire_and_forget SetRasterizedPixelWidthAsync(winrt::SvgImageSource const imageSourceRef,
115+
double const imageSize,
116+
bool const dropIfUnset = false);
117+
118+
void SetRasterizedPixelHeight(winrt::ImageSource const& imageSource, double const& imageSize);
119+
void SetRasterizedPixelWidth(winrt::ImageSource const& imageSource, double const& imageSize);
86120
};
87121
}
Lines changed: 24 additions & 0 deletions
Loading

source/uwp/SharedVisualizer/SharedVisualizer.projitems

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</PropertyGroup>
1111
<ItemGroup>
1212
<Content Include="$(MSBuildThisFileDirectory)Assets\Symbols\adaptive-card.svg" />
13+
<Content Include="$(MSBuildThisFileDirectory)Assets\Symbols\adaptive-card-fixed-height.svg" />
1314
<Content Include="$(MSBuildThisFileDirectory)Assets\Symbols\down.png" />
1415
<Content Include="$(MSBuildThisFileDirectory)Assets\Symbols\up.png" />
1516
<Content Include="$(MSBuildThisFileDirectory)HostConfigs\DefaultHostConfigHighContrastNightSky.json" />

0 commit comments

Comments
 (0)