Skip to content

Commit

Permalink
Merge pull request OfficeDev#1442 from OfficeDev/v-hrajandira/BotForm…
Browse files Browse the repository at this point in the history
…attingCardsFeatures

Added Container Layout, Donut Chart, Gauge Chart, Horizontal Chart, H…
  • Loading branch information
Pawank-MSFT authored Nov 7, 2024
2 parents 8ac9743 + 6d832ef commit 2184b6c
Show file tree
Hide file tree
Showing 108 changed files with 2,436 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -362,5 +362,176 @@ public static Attachment SendCompoundButtonCard()

return CompoundButtonCardAttachment;
}

/// <summary>
/// Container Layout adaptive Card
/// Sends adaptive card showing Container Layout
/// </summary>
/// <returns>Return Microsoft.Bot.Schema.Attachment results.</returns>
public static Attachment SendContainerLayoutCard()
{
var paths = new[] { ".", "Resources", "adaptiveCardContainerLayouts.json" };
var adaptiveCardContainerLayoutJson = File.ReadAllText(Path.Combine(paths));

var ContainerLayoutCardAttachment = new Attachment()
{
ContentType = contentType,
Content = JsonConvert.DeserializeObject(adaptiveCardContainerLayoutJson),
};

return ContainerLayoutCardAttachment;
}

/// <summary>
/// Donut Chart adaptive Card
/// Sends adaptive card showing Donut Chart
/// </summary>
/// <returns>Return Microsoft.Bot.Schema.Attachment results.</returns>
public static Attachment SendDonutChartCard()
{
var paths = new[] { ".", "Resources", "adaptiveCardDonutChart.json" };
var adaptiveCardDonutChartJson = File.ReadAllText(Path.Combine(paths));

var DonutChartCardAttachment = new Attachment()
{
ContentType = contentType,
Content = JsonConvert.DeserializeObject(adaptiveCardDonutChartJson),
};

return DonutChartCardAttachment;
}

/// <summary>
/// Gauge Chart adaptive Card
/// Sends adaptive card showing Gauge Chart
/// </summary>
/// <returns>Return Microsoft.Bot.Schema.Attachment results.</returns>
public static Attachment SendGaugeChartCard()
{
var paths = new[] { ".", "Resources", "adaptiveCardGaugeChart.json" };
var adaptiveCardGaugeChartJson = File.ReadAllText(Path.Combine(paths));

var GaugeChartCardAttachment = new Attachment()
{
ContentType = contentType,
Content = JsonConvert.DeserializeObject(adaptiveCardGaugeChartJson),
};

return GaugeChartCardAttachment;
}

/// <summary>
/// Horizontal Bar Chart adaptive Card
/// Sends adaptive card showing Horizontal Bar Chart
/// </summary>
/// <returns>Return Microsoft.Bot.Schema.Attachment results.</returns>
public static Attachment SendHorizontalBarChartCard()
{
var paths = new[] { ".", "Resources", "adaptiveCardHorizontalBarChart.json" };
var adaptiveCardHorizontalBarChartJson = File.ReadAllText(Path.Combine(paths));

var HorizontalBarChartCardAttachment = new Attachment()
{
ContentType = contentType,
Content = JsonConvert.DeserializeObject(adaptiveCardHorizontalBarChartJson),
};

return HorizontalBarChartCardAttachment;
}

/// <summary>
/// Horizontal Bar Chart adaptive Card
/// Sends adaptive card showing Horizontal Bar Stacked Chart
/// </summary>
/// <returns>Return Microsoft.Bot.Schema.Attachment results.</returns>
public static Attachment SendHorizontalBarStackedChartCard()
{
var paths = new[] { ".", "Resources", "adaptiveCardHorizontalBarStacked.json" };
var adaptiveCardHorizontalBarStackedChartJson = File.ReadAllText(Path.Combine(paths));

var HorizontalBarStackedChartCardAttachment = new Attachment()
{
ContentType = contentType,
Content = JsonConvert.DeserializeObject(adaptiveCardHorizontalBarStackedChartJson),
};

return HorizontalBarStackedChartCardAttachment;
}

/// <summary>
/// Line Chart adaptive Card
/// Sends adaptive card showing Line Chart
/// </summary>
/// <returns>Return Microsoft.Bot.Schema.Attachment results.</returns>
public static Attachment SendLineChartCard()
{
var paths = new[] { ".", "Resources", "adaptiveCardLineChart.json" };
var adaptiveCardLineChartJson = File.ReadAllText(Path.Combine(paths));

var LineChartCardAttachment = new Attachment()
{
ContentType = contentType,
Content = JsonConvert.DeserializeObject(adaptiveCardLineChartJson),
};

return LineChartCardAttachment;
}

/// <summary>
/// Pie Chart adaptive Card
/// Sends adaptive card showing Pie Chart
/// </summary>
/// <returns>Return Microsoft.Bot.Schema.Attachment results.</returns>
public static Attachment SendPieChartCard()
{
var paths = new[] { ".", "Resources", "adaptiveCardPieChart.json" };
var adaptiveCardPieChartJson = File.ReadAllText(Path.Combine(paths));

var PieChartCardAttachment = new Attachment()
{
ContentType = contentType,
Content = JsonConvert.DeserializeObject(adaptiveCardPieChartJson),
};

return PieChartCardAttachment;
}

/// <summary>
/// Vertical Bar Chart adaptive Card
/// Sends adaptive card showing Vertical Bar Chart
/// </summary>
/// <returns>Return Microsoft.Bot.Schema.Attachment results.</returns>
public static Attachment SendVerticalBarChartCard()
{
var paths = new[] { ".", "Resources", "adaptiveCardVerticalBarChart.json" };
var adaptiveCardVerticalBarChartJson = File.ReadAllText(Path.Combine(paths));

var VerticalBarChartCardAttachment = new Attachment()
{
ContentType = contentType,
Content = JsonConvert.DeserializeObject(adaptiveCardVerticalBarChartJson),
};

return VerticalBarChartCardAttachment;
}

/// <summary>
/// Vertical Bar Grouped Chart adaptive Card
/// Sends adaptive card showing Vertical Bar Grouped Chart
/// </summary>
/// <returns>Return Microsoft.Bot.Schema.Attachment results.</returns>
public static Attachment SendVerticalBarGroupedChartCard()
{
var paths = new[] { ".", "Resources", "adaptiveCardVerticalBarGroupedChart.json" };
var adaptiveCardVerticalBarGroupedChartJson = File.ReadAllText(Path.Combine(paths));

var VerticalBarGroupedChartCardAttachment = new Attachment()
{
ContentType = contentType,
Content = JsonConvert.DeserializeObject(adaptiveCardVerticalBarGroupedChartJson),
};

return VerticalBarGroupedChartCardAttachment;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private async Task<DialogTurnResult> SelectCardAsync(WaterfallStepContext stepCo
// Decide which type of card(s) we are going to show the user
switch (((FoundChoice)stepContext.Result).Value)
{

case "InfoMasking":
// Sends Information masking in Adaptive Cards
reply.Attachments.Add(AllCards.sendInfoMasking());
Expand Down Expand Up @@ -149,6 +149,42 @@ private async Task<DialogTurnResult> SelectCardAsync(WaterfallStepContext stepCo
// Adaptive Card Compound Button
reply.Attachments.Add(AllCards.SendCompoundButtonCard());
break;
case "ContainerLayout":
// Adaptive Card Container Layout
reply.Attachments.Add(AllCards.SendContainerLayoutCard());
break;
case "DonutChart":
// Adaptive Card Donut Chart
reply.Attachments.Add(AllCards.SendDonutChartCard());
break;
case "GaugeChart":
// Adaptive Card Gauge Chart
reply.Attachments.Add(AllCards.SendGaugeChartCard());
break;
case "HorizontalChart":
// Adaptive Card Horizontal Bar Chart
reply.Attachments.Add(AllCards.SendHorizontalBarChartCard());
break;
case "HorizontalStacked":
// Adaptive Card Horizontal Bar Stacked Chart
reply.Attachments.Add(AllCards.SendHorizontalBarStackedChartCard());
break;
case "LineChart":
// Adaptive Card Line Chart
reply.Attachments.Add(AllCards.SendLineChartCard());
break;
case "PieChart":
// Adaptive Card Pie Chart
reply.Attachments.Add(AllCards.SendPieChartCard());
break;
case "VerticalBarChart":
// Adaptive Card Vertical Bar Chart
reply.Attachments.Add(AllCards.SendVerticalBarChartCard());
break;
case "VerticalGroupedChart":
// Adaptive Card Vertical Bar Grouped Chart
reply.Attachments.Add(AllCards.SendVerticalBarGroupedChartCard());
break;
default:
reply.Attachments.Add(AllCards.sendInfoMasking());
reply.Attachments.Add(AllCards.sendFullWidthCardAdaptiveCard());
Expand All @@ -167,6 +203,15 @@ private async Task<DialogTurnResult> SelectCardAsync(WaterfallStepContext stepCo
reply.Attachments.Add(AllCards.SendConditionalCard());
reply.Attachments.Add(AllCards.SendScrollableCard());
reply.Attachments.Add(AllCards.SendCompoundButtonCard());
reply.Attachments.Add(AllCards.SendContainerLayoutCard());
reply.Attachments.Add(AllCards.SendDonutChartCard());
reply.Attachments.Add(AllCards.SendGaugeChartCard());
reply.Attachments.Add(AllCards.SendHorizontalBarChartCard());
reply.Attachments.Add(AllCards.SendHorizontalBarStackedChartCard());
reply.Attachments.Add(AllCards.SendLineChartCard());
reply.Attachments.Add(AllCards.SendPieChartCard());
reply.Attachments.Add(AllCards.SendVerticalBarChartCard());
reply.Attachments.Add(AllCards.SendVerticalBarGroupedChartCard());
break;
}

Expand Down Expand Up @@ -208,7 +253,16 @@ private IList<Choice> loadAllCards()
new Choice() { Value = "StarRatings", Synonyms = new List<string>() { "StarRatings" } },
new Choice() { Value = "ConditionalCard", Synonyms = new List<string>() { "ConditionalCard" } },
new Choice() { Value = "ScrollableCard", Synonyms = new List<string>() { "ScrollableCard" } },
new Choice() { Value = "CompoundButton", Synonyms = new List<string>() { "CompoundButton" } }
new Choice() { Value = "CompoundButton", Synonyms = new List<string>() { "CompoundButton" } },
new Choice() { Value = "ContainerLayout", Synonyms = new List<string>() { "ContainerLayout" } },
new Choice() { Value = "DonutChart", Synonyms = new List<string>() { "DonutChart" } },
new Choice() { Value = "GaugeChart", Synonyms = new List<string>() { "GaugeChart" } },
new Choice() { Value = "HorizontalChart", Synonyms = new List<string>() { "HorizontalChart" } },
new Choice() { Value = "HorizontalStacked", Synonyms = new List<string>() { "HorizontalChartStacked" } },
new Choice() { Value = "LineChart", Synonyms = new List<string>() { "LineChart" } },
new Choice() { Value = "PieChart", Synonyms = new List<string>() { "PieChart" } },
new Choice() { Value = "VerticalBarChart", Synonyms = new List<string>() { "VerticalBarChart" } },
new Choice() { Value = "VerticalGroupedChart", Synonyms = new List<string>() { "VerticalBarGroupedChart" } }
};

return returncardOptions;
Expand All @@ -220,4 +274,4 @@ private IList<Choice> loadAllCards()
}
}
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{
"type": "AdaptiveCard",
"version": "1.5",
"layouts": [
{
"type": "Layout.AreaGrid",
"targetWidth": "atLeast:standard",
"columns": [
60
],
"areas": [
{
"name": "imageArea"
},
{
"name": "textArea",
"column": 2
}
]
}
],
"body": [
{
"type": "Image",
"url": "https://picsum.photos/200/200?image=110",
"grid.area": "imageArea",
"style": "RoundedCorners",
"targetWidth": "atLeast:narrow"
},
{
"type": "Container",
"grid.area": "textArea",
"items": [
{
"type": "TextBlock",
"text": "Adaptive Cards",
"wrap": true,
"size": "ExtraLarge",
"weight": "Bolder"
},
{
"type": "TextBlock",
"text": "The simple, lightweight card format to power your ideas.",
"wrap": true
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"type": "AdaptiveCard",
"version": "1.5",
"body": [
{
"type": "Chart.Donut",
"data": [
{
"legend": "Pear",
"value": 59
},
{
"legend": "Banana",
"value": 292
},
{
"legend": "Apple",
"value": 143
},
{
"legend": "Peach",
"value": 98
},
{
"legend": "Kiwi",
"value": 179
},
{
"legend": "Grapefruit",
"value": 50
},
{
"legend": "Orange",
"value": 212
},
{
"legend": "Cantaloupe",
"value": 68
}
]
}
]
}
Loading

0 comments on commit 2184b6c

Please sign in to comment.