public static FrameworkElement Render(AdaptiveImageSet imageSet, AdaptiveRenderContext context)
        {
            var uiImageSet = new ListBox();

            uiImageSet.BorderThickness = new Thickness(0);
            uiImageSet.Background      = new SolidColorBrush(Colors.Transparent);
            ScrollViewer.SetHorizontalScrollBarVisibility(uiImageSet, ScrollBarVisibility.Disabled);
            var itemsPanelTemplate = new ItemsPanelTemplate();
            var factory            = new FrameworkElementFactory(typeof(WrapPanel));

            // factory.SetValue(StackPanel.OrientationProperty, Orientation.Horizontal);
            itemsPanelTemplate.VisualTree = factory;
            uiImageSet.ItemsPanel         = itemsPanelTemplate;

            uiImageSet.Style = context.GetStyle("Adaptive.ImageSet");
            foreach (var image in imageSet.Images)
            {
                if (image.Size == AdaptiveImageSize.Auto)
                {
                    if (imageSet.ImageSize != AdaptiveImageSize.Auto)
                    {
                        image.Size = imageSet.ImageSize;
                    }
                    else
                    {
                        image.Size = context.Config.ImageSet.ImageSize;
                    }
                }

                var uiImage = context.Render(image);
                uiImageSet.Add(uiImage);
            }
            return(uiImageSet);
        }
Example #2
0
 public virtual void Visit(AdaptiveImageSet imageSet)
 {
     foreach (var image in imageSet.Images)
     {
         Visit(image);
     }
 }
Example #3
0
 private void SetValue(AdaptiveImageSet imageSet, object value)
 {
     if (value is List <AdaptiveImage> )
     {
         imageSet.Images = value as List <AdaptiveImage>;
     }
     else if (value is List <CardImage> )
     {
         imageSet = AdaptiveElementBuilder.CreateImageSet(value as List <CardImage>) as AdaptiveImageSet;
     }
     else if (value is List <MediaUrl> )
     {
         imageSet = AdaptiveElementBuilder.CreateImageSet(value as List <MediaUrl>) as AdaptiveImageSet;
     }
 }
Example #4
0
        protected static HtmlTag ImageSetRender(AdaptiveImageSet imageSet, AdaptiveRendererContext context)
        {
            var uiImageSet = new DivTag()
                             .AddClass(imageSet.Type.ToLower());

            foreach (var image in imageSet.Images)
            {
                if (imageSet.ImageSize != AdaptiveImageSize.Auto)
                {
                    image.Size = imageSet.ImageSize;
                }

                var uiImage = context.Render(image);
                uiImage = uiImage.Style("display", "inline-block");
                uiImageSet.Children.Add(uiImage);
            }
            return(uiImageSet);
        }
        protected static Element ImageSetRender(AdaptiveImageSet imageSet, ElementAdaptiveRenderContext context)
        {
            var uiImageSet = new List()
                             .AddClass(imageSet.Type.ToLower());

            foreach (var image in imageSet.Images)
            {
                if (imageSet.ImageSize != AdaptiveImageSize.Auto)
                {
                    image.Size = imageSet.ImageSize;
                }

                var uiImage = context.Render(image)
                              .Style("display", "inline-block")
                              .Style("margin-right", "10px");

                uiImageSet.AppendChild(uiImage);
            }
            return(uiImageSet);
        }
Example #6
0
        // Create ImageSet
        public static AdaptiveElement CreateImageSet(IList <CardImage> cardImages, AdaptiveImageSize size = AdaptiveImageSize.Medium)
        {
            var imageSet = new AdaptiveImageSet()
            {
                Id     = "ImageSet",
                Images = new List <AdaptiveImage>()
            };

            if (cardImages == null || cardImages.Count == 0)
            {
                return(null);
            }

            for (var i = 0; i < cardImages.Count; i++)
            {
                var cardImage = cardImages[i];
                imageSet.Images.Add(CreateImage(cardImage, size, $"Image-{i + 1}"));
            }

            return(imageSet);
        }
Example #7
0
        public void ImageSet()
        {
            AdaptiveImage image1 = new AdaptiveImage
            {
                Id  = "Image1Id",
                Url = "https://www.stuff.com/picture.jpg"
            };

            AdaptiveImage image2 = new AdaptiveImage
            {
                Id  = "Image2Id",
                Url = "https://www.stuff.com/picture2.jpg"
            };

            AdaptiveImageSet imageSet = new AdaptiveImageSet
            {
                ImageSize = ImageSize.Small,
                Height    = HeightType.Stretch,
                Id        = "ImageSetId",
                IsVisible = false,
                Separator = true,
                Spacing   = Spacing.Medium,
            };

            ValidateBaseElementProperties(imageSet, "ImageSetId", false, true, Spacing.Medium, HeightType.Stretch);
            Assert.AreEqual(ImageSize.Small, imageSet.ImageSize);

            imageSet.Images.Add(image1);
            imageSet.Images.Add(image2);

            Assert.AreEqual("Image1Id", imageSet.Images[0].Id);
            Assert.AreEqual("Image2Id", imageSet.Images[1].Id);

            var jsonString = imageSet.ToJson().ToString();

            Assert.AreEqual("{\"height\":\"Stretch\",\"id\":\"ImageSetId\",\"imageSize\":\"Small\",\"images\":[{\"id\":\"Image1Id\",\"type\":\"Image\",\"url\":\"https://www.stuff.com/picture.jpg\"},{\"id\":\"Image2Id\",\"type\":\"Image\",\"url\":\"https://www.stuff.com/picture2.jpg\"}],\"isVisible\":false,\"separator\":true,\"spacing\":\"medium\",\"type\":\"ImageSet\"}", jsonString);
        }
    public static AdaptiveCard CreateFullCardForCandidate(Candidate c)
    {
        AdaptiveCard card = new AdaptiveCard();

        card.Body = new List <AdaptiveElement>();
        AdaptiveContainer header = new AdaptiveContainer();

        card.Body.Add(header);

        header.Items = new List <AdaptiveElement>();
        header.Items.Add(new AdaptiveTextBlock()
        {
            Text   = c.Name,
            Weight = AdaptiveTextWeight.Bolder,
            Size   = AdaptiveTextSize.Large
        });

        AdaptiveColumnSet headerDetails = new AdaptiveColumnSet();

        header.Items.Add(headerDetails);

        AdaptiveColumn col1 = new AdaptiveColumn();

        col1.Width = AdaptiveColumnWidth.Auto;
        col1.Items = new List <AdaptiveElement>
        {
            new AdaptiveImage()
            {
                Url   = new Uri(c.ProfilePicture),
                Size  = AdaptiveImageSize.Small,
                Style = AdaptiveImageStyle.Person
            }
        };

        AdaptiveColumn col2 = new AdaptiveColumn();

        col2.Width = AdaptiveColumnWidth.Stretch;
        col2.Items = new List <AdaptiveElement>
        {
            new AdaptiveTextBlock()
            {
                Text = $"Applied {DateTime.Today.ToString("MM/dd/yyyy")}",
                Wrap = true
            },
            new AdaptiveTextBlock()
            {
                Text     = $"Current role {c.CurrentRole}",
                Spacing  = AdaptiveSpacing.None,
                Wrap     = true,
                IsSubtle = true
            }
        };

        headerDetails.Columns = new List <AdaptiveColumn>
        {
            col1,
            col2
        };

        AdaptiveContainer details = new AdaptiveContainer();

        AdaptiveTextBlock candidateSummary = new AdaptiveTextBlock()
        {
            Text = new CandidatesDataController().GetCandidateBio(c),
            Wrap = true
        };

        AdaptiveFactSet factsCol1 = new AdaptiveFactSet();

        factsCol1.Facts = new List <AdaptiveFact>
        {
            new AdaptiveFact("Applied to position", c.ReqId),
            new AdaptiveFact("Interview date", "Not set")
        };

        AdaptiveFactSet factsCol2 = new AdaptiveFactSet();

        factsCol2.Facts = new List <AdaptiveFact>
        {
            new AdaptiveFact("Hires", c.Hires.ToString()),
            new AdaptiveFact("No hires", c.NoHires.ToString())
        };

        AdaptiveColumnSet factColumns = new AdaptiveColumnSet()
        {
            Columns = new List <AdaptiveColumn>
            {
                new AdaptiveColumn()
                {
                    Items = new List <AdaptiveElement>
                    {
                        factsCol1
                    },
                    Width = AdaptiveColumnWidth.Stretch
                },

                new AdaptiveColumn()
                {
                    Items = new List <AdaptiveElement>
                    {
                        factsCol2
                    },
                    Width = AdaptiveColumnWidth.Stretch
                }
            }
        };

        details.Items = new List <AdaptiveElement>
        {
            candidateSummary,
            factColumns
        };

        card.Body.Add(details);

        AdaptiveImageSet referrals = new AdaptiveImageSet();

        referrals.ImageSize = AdaptiveImageSize.Small;
        referrals.Images    = new List <AdaptiveImage>();

        foreach (Candidate referral in new CandidatesDataController().GetReferrals(c))
        {
            referrals.Images.Add(new AdaptiveImage()
            {
                Url   = new Uri(referral.ProfilePicture),
                Style = AdaptiveImageStyle.Person
            });
        }

        card.Body.Add(new AdaptiveTextBlock()
        {
            Text = "Referrals",
            Size = AdaptiveTextSize.Large
        });
        card.Body.Add(referrals);

        AdaptiveAction setInterview = new AdaptiveShowCardAction()
        {
            Title = "Set interview date",
            Card  = new AdaptiveCard()
            {
                Body = new List <AdaptiveElement>
                {
                    new AdaptiveDateInput()
                    {
                        Id          = "InterviewDate",
                        Placeholder = "Enter in a date for the interview"
                    }
                },
                Actions = new List <AdaptiveAction>
                {
                    new AdaptiveSubmitAction()
                    {
                        Title = "OK"
                    }
                }
            }
        };

        AdaptiveAction setComment = new AdaptiveShowCardAction()
        {
            Title = "Add comment",
            Card  = new AdaptiveCard()
            {
                Body = new List <AdaptiveElement>
                {
                    new AdaptiveTextInput()
                    {
                        Id          = "Comment",
                        Placeholder = "Add a comment for this candidate",
                        IsMultiline = true
                    }
                },
                Actions = new List <AdaptiveAction>
                {
                    new AdaptiveSubmitAction()
                    {
                        Title = "OK"
                    }
                }
            }
        };

        card.Actions = new List <AdaptiveAction>
        {
            setInterview,
            setComment
        };

        return(card);
    }
Example #9
0
        private AdaptiveCard SetCard()
        {
            AdaptiveCard _card = new AdaptiveCard("1.0");

            var _container = new AdaptiveContainer();

            var colum = new AdaptiveColumnSet();

            var _columnImage = new AdaptiveColumn()
            {
                Width = AdaptiveColumnWidth.Auto
            };

            _columnImage.Items.Add(new AdaptiveImage()
            {
                Url     = new Uri(this.UrlImage),
                Size    = AdaptiveImageSize.Small,
                Style   = AdaptiveImageStyle.Person,
                AltText = "Bootty"
            });

            var _columnContent = new AdaptiveColumn()
            {
                Width = AdaptiveColumnWidth.Stretch
            };

            _columnContent.Items.Add(new AdaptiveTextBlock()
            {
                Text    = "Booty",
                Size    = AdaptiveTextSize.Medium,
                Weight  = AdaptiveTextWeight.Default,
                Color   = AdaptiveTextColor.Default,
                Wrap    = true,
                Spacing = AdaptiveSpacing.Default
            });

            _columnContent.Items.Add(new AdaptiveTextBlock()
            {
                Text     = DateTime.Now.ToString(),
                Size     = AdaptiveTextSize.Small,
                Color    = AdaptiveTextColor.Default,
                Wrap     = true,
                IsSubtle = true,
                Spacing  = AdaptiveSpacing.None
            });

            var _textMessage = new AdaptiveTextBlock()
            {
                Text     = this.Title,
                Size     = AdaptiveTextSize.Medium,
                Color    = AdaptiveTextColor.Default,
                Weight   = AdaptiveTextWeight.Bolder,
                Wrap     = true,
                IsSubtle = false
            };

            var _textMessage2 = new AdaptiveTextBlock()
            {
                Text     = this.Description,
                Size     = AdaptiveTextSize.Small,
                Color    = AdaptiveTextColor.Default,
                Weight   = AdaptiveTextWeight.Default,
                Wrap     = true,
                IsSubtle = false
            };


            colum.Columns.Add(_columnImage);
            colum.Columns.Add(_columnContent);
            _container.Items.Add(colum);

            _card.Body.Add(_container);
            _card.Body.Add(_textMessage);
            _card.Body.Add(_textMessage2);

            var images = this.Actions.Where(p => p.TypeCard == TypeCards.IMAGE).ToList();;

            if (images.Count > 0)
            {
                var _imageSet = new AdaptiveImageSet();
                _imageSet.ImageSize = AdaptiveImageSize.Large;

                foreach (Action action in images)
                {
                    _imageSet.Images.Add(new AdaptiveImage(action.Result));
                }

                _card.Body.Add(_imageSet);
            }


            _card.Actions.AddRange(this.GetAdaptiveActions());

            return(_card);
        }