|
|
|
@ -142,50 +142,57 @@ namespace Adaptive_Card_Editor_UWP
|
|
|
|
|
|
|
|
|
|
// clear the grid of existing content |
|
|
|
|
grdCard.Children.Clear(); |
|
|
|
|
grdTemplated.Children.Clear(); |
|
|
|
|
|
|
|
|
|
// render an adaptive card |
|
|
|
|
try |
|
|
|
|
// render the adaptive card content |
|
|
|
|
if (txtInput.Text.Length > 0) |
|
|
|
|
{ |
|
|
|
|
AdaptiveCardRenderer cardRenderer = new AdaptiveCardRenderer(); |
|
|
|
|
AdaptiveCardParseResult parsedCard = AdaptiveCard.FromJsonString(txtInput.Text); |
|
|
|
|
RenderedAdaptiveCard theCard = cardRenderer.RenderAdaptiveCard(parsedCard.AdaptiveCard); |
|
|
|
|
grdCard.Children.Add(theCard.FrameworkElement); |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
// this means bad data was ingested by the adaptive card renderer |
|
|
|
|
// so just display the exception details |
|
|
|
|
cardOutput.Text = ex.ToString(); |
|
|
|
|
grdCard.Children.Add(cardOutput); |
|
|
|
|
} |
|
|
|
|
// render an adaptive card |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
AdaptiveCardRenderer cardRenderer = new AdaptiveCardRenderer(); |
|
|
|
|
AdaptiveCardParseResult parsedCard = AdaptiveCard.FromJsonString(txtInput.Text); |
|
|
|
|
RenderedAdaptiveCard theCard = cardRenderer.RenderAdaptiveCard(parsedCard.AdaptiveCard); |
|
|
|
|
grdCard.Children.Add(theCard.FrameworkElement); |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
// this means bad data was ingested by the adaptive card renderer |
|
|
|
|
// so just display the exception details |
|
|
|
|
cardOutput.Text = ex.ToString(); |
|
|
|
|
grdCard.Children.Add(cardOutput); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// render a card using template and data |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
string template = txtInput.Text; |
|
|
|
|
string data = txtData.Text; |
|
|
|
|
// render a card using template and data |
|
|
|
|
try |
|
|
|
|
{ |
|
|
|
|
string template = txtInput.Text; |
|
|
|
|
string data = txtData.Text; |
|
|
|
|
|
|
|
|
|
string rendered = JsonFromTemplate(template, data); |
|
|
|
|
string rendered = JsonFromTemplate(template, data); |
|
|
|
|
|
|
|
|
|
// render the card from the rendered template + data |
|
|
|
|
AdaptiveCardRenderer cardRenderer = new AdaptiveCardRenderer(); |
|
|
|
|
AdaptiveCardParseResult parsedCard = AdaptiveCard.FromJsonString(rendered); |
|
|
|
|
RenderedAdaptiveCard theCard = cardRenderer.RenderAdaptiveCard(parsedCard.AdaptiveCard); |
|
|
|
|
grdTemplated.Children.Add(theCard.FrameworkElement); |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
// render the text as a plain textbox |
|
|
|
|
TextBlock templateOutput = new TextBlock(); |
|
|
|
|
templateOutput.TextWrapping = TextWrapping.Wrap; |
|
|
|
|
templateOutput.Padding = new Thickness(10); |
|
|
|
|
templateOutput.Text = txtInput.Text; |
|
|
|
|
|
|
|
|
|
// this means bad data was ingested by the adaptive card renderer |
|
|
|
|
// so just display the exception details |
|
|
|
|
templateOutput.Text = ex.ToString(); |
|
|
|
|
grdTemplated.Children.Add(templateOutput); |
|
|
|
|
// render the card from the rendered template + data |
|
|
|
|
AdaptiveCardRenderer cardRenderer = new AdaptiveCardRenderer(); |
|
|
|
|
AdaptiveCardParseResult parsedCard = AdaptiveCard.FromJsonString(rendered); |
|
|
|
|
RenderedAdaptiveCard theCard = cardRenderer.RenderAdaptiveCard(parsedCard.AdaptiveCard); |
|
|
|
|
grdTemplated.Children.Add(theCard.FrameworkElement); |
|
|
|
|
} |
|
|
|
|
catch (Exception ex) |
|
|
|
|
{ |
|
|
|
|
// render the text as a plain textbox |
|
|
|
|
TextBlock templateOutput = new TextBlock(); |
|
|
|
|
templateOutput.TextWrapping = TextWrapping.Wrap; |
|
|
|
|
templateOutput.Padding = new Thickness(10); |
|
|
|
|
templateOutput.Text = txtInput.Text; |
|
|
|
|
|
|
|
|
|
// this means bad data was ingested by the adaptive card renderer |
|
|
|
|
// so just display the exception details |
|
|
|
|
templateOutput.Text = ex.ToString(); |
|
|
|
|
grdTemplated.Children.Add(templateOutput); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// update the XAML layout |
|
|
|
|
grdCard.UpdateLayout(); |
|
|
|
|
|
|
|
|
|
isRendered = true; |
|
|
|
|