Skip to content

Commit

Permalink
[UWP] Sync release branch with main (#8330)
Browse files Browse the repository at this point in the history
* 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 <Joseph.Woo@microsoft.com>

* [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 <Joseph.Woo@microsoft.com>

* [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 <raamleka@microsoft.com>

* Custom.props to 1.0.0 for Object model build

* Update dependency version

Co-authored-by: Rahul Amlekar <rahul.amlekar@mail.mcgill.ca>
Co-authored-by: RahulAmlekar <raamleka@microsoft.com>
Co-authored-by: Rebecca Muraira <rebecch@microsoft.com>

* Remove blank lines

Co-authored-by: almedina-ms <35784165+almedina-ms@users.noreply.github.com>
Co-authored-by: Rahul Amlekar <rahul.amlekar@mail.mcgill.ca>
Co-authored-by: RahulAmlekar <raamleka@microsoft.com>
Co-authored-by: Rebecca Muraira <rebecch@microsoft.com>

* [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 <Joseph.Woo@microsoft.com>
Co-authored-by: almedina-ms <35784165+almedina-ms@users.noreply.github.com>
Co-authored-by: Rahul Amlekar <rahul.amlekar@mail.mcgill.ca>
Co-authored-by: RahulAmlekar <raamleka@microsoft.com>
Co-authored-by: Rebecca Muraira <rebecch@microsoft.com>
  • Loading branch information
6 people authored Mar 21, 2023
1 parent 50a7c52 commit 3faa6de
Show file tree
Hide file tree
Showing 9 changed files with 478 additions and 148 deletions.
4 changes: 2 additions & 2 deletions custom.props
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Label="Version">
<VersionMajor>1</VersionMajor>
<VersionMajor>3</VersionMajor>
<VersionMinor>1</VersionMinor>
<!-- The nuget package version should be incremented when we produce QFEs -->
<NuGetPackVersion>1.1.0</NuGetPackVersion>
<NuGetPackVersion>3.1.1</NuGetPackVersion>
<VersionInfoProductName>AdaptiveCards</VersionInfoProductName>
</PropertyGroup>
</Project>
65 changes: 65 additions & 0 deletions samples/v1.5/Tests/Image.Svg.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion source/uwp/NuGet/AdaptiveCards.Rendering.Uwp.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<license type="file">EULA-Windows.txt</license>
<copyright>© Microsoft Corporation. All rights reserved.</copyright>
<dependencies>
<dependency id="AdaptiveCards.ObjectModel.Uwp" version="1.0.0" />
<dependency id="AdaptiveCards.ObjectModel.Uwp" version="1.1.0" />
</dependencies>
</metadata>
<files>
Expand Down
451 changes: 321 additions & 130 deletions source/uwp/SharedRenderer/lib/AdaptiveImageRenderer.cpp

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions source/uwp/SharedRenderer/lib/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,19 @@ std::string HStringToUTF8(winrt::hstring const& in)
return WStringToString(in);
}

std::optional<double> TryHStringToDouble(winrt::hstring const& in)
{
try
{
return std::stod(winrt::to_string(in));
}
catch (std::invalid_argument)
{
// in was not a valid double
return {};
}
}

// Get a Color object from color string
// Expected formats are "#AARRGGBB" (with alpha channel) and "#RRGGBB" (without alpha channel)
winrt::Windows::UI::Color GetColorFromString(const std::string& colorString)
Expand Down
2 changes: 2 additions & 0 deletions source/uwp/SharedRenderer/lib/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ template<typename TStored> struct property_opt
std::string WStringToString(std::wstring_view in);
std::wstring StringToWString(std::string_view in);

std::optional<double> TryHStringToDouble(winrt::hstring const& in);

// This function is needed to deal with the fact that non-windows platforms handle Unicode without the need for wchar_t.
// (which has a platform specific implementation) It converts a std::string to an HSTRING.
winrt::hstring UTF8ToHString(std::string_view in);
Expand Down
64 changes: 49 additions & 15 deletions source/uwp/SharedRenderer/lib/XamlBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ namespace AdaptiveCards::Rendering::Xaml_Rendering
public:
XamlBuilder();

template<typename TElement>
struct ImageProperties
{
TElement uiElement;
bool isAutoSize;
winrt::IInspectable parentElement;
winrt::IInspectable imageContainer;
bool isVisible;
boolean isImageSvg;
winrt::Stretch stretch = winrt::Stretch::UniformToFill;
};

// IImageLoadTrackerListener
void AllImagesLoaded() override;
void ImagesLoadingHadError() override;
Expand Down Expand Up @@ -54,34 +66,56 @@ namespace AdaptiveCards::Rendering::Xaml_Rendering
winrt::AdaptiveRenderArgs const& renderArgs,
XamlBuilder* xamlBuilder);

template<typename T>
void SetAutoSize(T const& destination,
template<typename TDest>
void SetAutoSize(TDest const& destination,
winrt::IInspectable const& parentElement,
winrt::IInspectable const& imageContainer,
bool isVisible,
bool imageFiresOpenEvent);

template<typename T>
void SetImageSource(T const& destination, winrt::ImageSource const& imageSource, winrt::Stretch stretch = winrt::Stretch::UniformToFill);
template<typename TDest>
void SetImageSource(TDest const& destination, winrt::ImageSource const& imageSource, winrt::Stretch stretch = winrt::Stretch::UniformToFill);

template<typename T>
void SetImageOnUIElement(winrt::Uri const& imageUrl,
T const& uiElement,
winrt::AdaptiveCardResourceResolvers const& resolvers,
bool isAutoSize,
winrt::IInspectable const& parentElement,
winrt::IInspectable const& imageContainer,
bool isVisible,
bool isImageSvg = false,
winrt::Stretch stretch = winrt::Stretch::UniformToFill);
template<typename TElement>
winrt::ImageSource SetImageOnUIElement(winrt::Uri const& imageUrl,
winrt::AdaptiveCardResourceResolvers const& resolvers,
ImageProperties<TElement> const& imgProperties);

winrt::ImageSource CreateImageSource(bool isImageSvg);

template<typename T> void PopulateImageFromUrlAsync(winrt::Uri const& imageUrl, T const& imageControl, bool const& isImageSvg);
template<typename TElement>
winrt::ImageSource PopulateImageFromUrlAsync(winrt::Uri const& imageUrl,
ImageProperties<TElement> const& imgProperties);

template<typename TElement, typename TStream>
void HandleAccessStreamForImageSource(ImageProperties<TElement> const& imgProperties,
TStream const& stream,
winrt::ImageSource const& imageSource);

winrt::fire_and_forget SetSvgUriSource(winrt::SvgImageSource const imageSourceRef,
winrt::Uri const uriRef);

template<typename TElement, typename TStream>
winrt::IAsyncAction SetSvgImageSourceAsync(winrt::SvgImageSource const imageSourceRef,
TStream const streamRef,
ImageProperties<TElement> const imgProperties);

boolean IsSvgImage(std::string url);

void FireAllImagesLoaded();
void FireImagesLoadingHadError();

bool ParseXmlForHeightAndWidth(winrt::XmlDocument const& xmlDoc,
winrt::SvgImageSource const& imageSourceRef);

winrt::fire_and_forget SetRasterizedPixelHeightAsync(winrt::SvgImageSource const imageSourceRef,
double const imageSize,
bool const dropIfUnset = false);
winrt::fire_and_forget SetRasterizedPixelWidthAsync(winrt::SvgImageSource const imageSourceRef,
double const imageSize,
bool const dropIfUnset = false);

void SetRasterizedPixelHeight(winrt::ImageSource const& imageSource, double const& imageSize);
void SetRasterizedPixelWidth(winrt::ImageSource const& imageSource, double const& imageSize);
};
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions source/uwp/SharedVisualizer/SharedVisualizer.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</PropertyGroup>
<ItemGroup>
<Content Include="$(MSBuildThisFileDirectory)Assets\Symbols\adaptive-card.svg" />
<Content Include="$(MSBuildThisFileDirectory)Assets\Symbols\adaptive-card-fixed-height.svg" />
<Content Include="$(MSBuildThisFileDirectory)Assets\Symbols\down.png" />
<Content Include="$(MSBuildThisFileDirectory)Assets\Symbols\up.png" />
<Content Include="$(MSBuildThisFileDirectory)HostConfigs\DefaultHostConfigHighContrastNightSky.json" />
Expand Down

0 comments on commit 3faa6de

Please sign in to comment.