예제 #1
0
        // Create AdaptiveCard from ThumbnailCard
        public static AdaptiveCard CreateThumbnailCard(ThumbnailCard card, string version = "1.0")
        {
            var adaptiveCard = new AdaptiveCard();
            var body         = new AdaptiveContainer()
            {
                Items = new List <AdaptiveElement>()
            };

            // Add Image
            var image = AdaptiveElementBuilder.CreateImage(card.Images, AdaptiveImageSize.Medium);

            if (image != null)
            {
                body.Items.Add(image);
            }

            // Add Title, SubTitle and Text
            body.Items.AddRange(AdaptiveElementBuilder.CreateTitle(card.Title, card.Subtitle, card.Text));

            // Set Tap Action
            if (card.Tap != null)
            {
                body.SelectAction = AdaptiveElementBuilder.CreateAction(card.Tap);
            }

            // Set Body and Actions
            adaptiveCard.Body = new List <AdaptiveElement>()
            {
                body
            };
            adaptiveCard.Actions = AdaptiveElementBuilder.CreateActions(card.Buttons);
            adaptiveCard.Version = version;
            return(adaptiveCard);
        }
예제 #2
0
        // Create List Card
        public static AdaptiveCard CreateListCard(IList <AdaptiveListCardItem> listItem, string title = null, IList <CardAction> buttons = null, AdaptiveListCardImageLayout imageLayout = AdaptiveListCardImageLayout.Right, AdaptiveImageSize imageSize = AdaptiveImageSize.Small, string version = "1.0")
        {
            var adaptiveCard = new AdaptiveCard();
            var body         = new AdaptiveContainer()
            {
                Items = new List <AdaptiveElement>()
            };

            // Add Title
            if (!string.IsNullOrEmpty(title))
            {
                body.Items.AddRange(AdaptiveElementBuilder.CreateTitle(title, AdaptiveTextSize.Large));
            }

            // Add List Item
            body.Items.AddRange(CreateListItems(listItem, imageLayout, imageSize));

            // Set Body and Actions
            adaptiveCard.Body = new List <AdaptiveElement>()
            {
                body
            };
            adaptiveCard.Actions = AdaptiveElementBuilder.CreateActions(buttons);
            adaptiveCard.Version = version;
            return(adaptiveCard);
        }
예제 #3
0
        // Create Fact Card
        public static AdaptiveCard CreateFactListCard(string title, IList <Fact> facts, IList <CardAction> buttons = null, CardImage image = null, string version = "1.0")
        {
            var adaptiveCard = new AdaptiveCard();
            var body         = new AdaptiveContainer()
            {
                Items = new List <AdaptiveElement>()
            };

            // Add Image
            if (image != null)
            {
                // Add Image
                body.Items.Add(AdaptiveElementBuilder.CreateImage(image, AdaptiveImageSize.Medium));
            }

            // Add Title
            body.Items.AddRange(AdaptiveElementBuilder.CreateTitle(title));

            // Add FaceSet
            body.Items.Add(AdaptiveElementBuilder.CreateFactSet(facts));

            // Set Body and Actions
            adaptiveCard.Body = new List <AdaptiveElement>()
            {
                body
            };
            adaptiveCard.Actions = AdaptiveElementBuilder.CreateActions(buttons);
            adaptiveCard.Version = version;
            return(adaptiveCard);
        }
예제 #4
0
        // Create Confirm Card
        public static AdaptiveCard CreateConfirmCard(string title, CardAction yesAction = null, CardAction noAction = null, CardImage image = null, string version = "1.0")
        {
            var adaptiveCard = new AdaptiveCard();
            var body         = new AdaptiveContainer()
            {
                Items = new List <AdaptiveElement>()
            };

            // Add Image
            if (image != null)
            {
                // Add Image
                body.Items.Add(AdaptiveElementBuilder.CreateImage(image, AdaptiveImageSize.Medium));
            }

            // Add Title
            body.Items.AddRange(AdaptiveElementBuilder.CreateTitle(title));

            // Add Action
            var actions = AdaptiveElementBuilder.CreateActions(new List <CardAction>()
            {
                yesAction ?? GetYesAction(),
                noAction ?? GetNoAction(),
            });

            // Set Body and Actions
            adaptiveCard.Body = new List <AdaptiveElement>()
            {
                body
            };
            adaptiveCard.Actions = actions;
            adaptiveCard.Version = version;
            return(adaptiveCard);
        }
예제 #5
0
        // Create AdaptiveCard from SigninCard
        public static AdaptiveCard CreateSigninCard(SigninCard card, string version = "1.0")
        {
            var adaptiveCard = new AdaptiveCard();

            var body = new AdaptiveContainer()
            {
                Items = new List <AdaptiveElement>()
            };

            // Add Title
            body.Items.AddRange(AdaptiveElementBuilder.CreateTitle(card.Text));

            // Set Body and Actions
            adaptiveCard.Body = new List <AdaptiveElement>()
            {
                body
            };
            adaptiveCard.Actions = AdaptiveElementBuilder.CreateActions(card.Buttons);
            adaptiveCard.Version = version;
            return(adaptiveCard);
        }
예제 #6
0
        // Create AdaptiveCard from ReceiptCard
        public static AdaptiveCard CreateReceiptCard(ReceiptCard card, string totalTitle = "Total", string vatTitle = "VAT", string taxTitle = "Tax", string version = "1.0")
        {
            var adaptiveCard = new AdaptiveCard();
            var body         = new AdaptiveContainer()
            {
                Items = new List <AdaptiveElement>()
            };

            // Add Title
            body.Items.AddRange(AdaptiveElementBuilder.CreateTitle(card.Title));

            // Add Receipt Fact
            if (card.Facts != null && card.Facts.Count != 0)
            {
                body.Items.AddRange(CreateReceiptFactSet(card.Facts));
            }

            // Add Separator
            body.Items.Add(CreateReceiptSeparator());

            // Add Receipt Item
            if (card.Items != null && card.Items.Count != 0)
            {
                body.Items.AddRange(CreateReceiptItems(card.Items.ToList()));
            }

            // Add Separator
            body.Items.Add(CreateReceiptSeparator());

            // Add VAT
            if (!string.IsNullOrEmpty(card.Vat))
            {
                body.Items.Add(CreateReceiptOtherInfo(vatTitle, card.Vat, "Vat"));
            }

            // Add Tax
            if (!string.IsNullOrEmpty(card.Tax))
            {
                body.Items.Add(CreateReceiptOtherInfo(taxTitle, card.Tax, "Tax"));
            }

            // Add Total
            if (!string.IsNullOrEmpty(card.Total))
            {
                body.Items.Add(CreateReceiptTotalInfo(totalTitle, card.Total));
            }

            // Set Tap Action
            if (card.Tap != null)
            {
                body.SelectAction = AdaptiveElementBuilder.CreateAction(card.Tap);
            }

            // Set Body and Actions
            adaptiveCard.Body = new List <AdaptiveElement>()
            {
                body
            };
            adaptiveCard.Actions = AdaptiveElementBuilder.CreateActions(card.Buttons);
            adaptiveCard.Version = version;

            return(adaptiveCard);
        }