public void Update(AdaptiveBlockContent block, AdaptiveBlock sourceBlock, PreviewBlockHostViewModel args)
        {
            TextBlockTitle.Text    = block.Title;
            TextBlockSubtitle.Text = block.Subtitle;

            StackPanelButtons.Children.Clear();
            StackPanelButtons.Visibility = Visibility.Visible;
            QuickReply.Visibility        = Visibility.Collapsed;
            foreach (var a in block.GetSimplifiedActions())
            {
                if (a.Inputs.Count == 0 || (a.Inputs.Count == 1 && a.Inputs[0] is AdaptiveTextInputBlock))
                {
                    var b = new Button()
                    {
                        Content    = a.Title,
                        Padding    = new Thickness(12),
                        Foreground = new SolidColorBrush(Colors.Red),
                        Style      = (Style)Resources["TextBlockButtonStyle"],
                        FontWeight = FontWeights.SemiBold
                    };
                    StackPanelButtons.Children.Add(b);
                    b.Click += delegate
                    {
                        if (a.Inputs.Count > 0)
                        {
                            StackPanelButtons.Visibility      = Visibility.Collapsed;
                            TextBoxQuickReply.PlaceholderText = a.Title;
                            QuickReply.Visibility             = Visibility.Visible;
                        }
                    };
                }
            }
        }
Пример #2
0
        public void Update(AdaptiveBlockContent block, AdaptiveBlock sourceBlock, PreviewBlockHostViewModel args)
        {
            DataContext = block;

            var icon = block.GetIconImageOrBestFit();

            if (icon?.Url != null)
            {
                IconImageBrush.ImageSource = new BitmapImage(new Uri(icon.Url));
                IconImage.Visibility       = Visibility.Visible;

                IconImage.Margin = new Thickness(icon.Hints.Category.Contains(AdaptiveBlockImageCategoryHints.Icon) ? 8 : 0);

                if (icon.BackgroundColor != null)
                {
                    //IconBackground.Fill = new SolidColorBrush(icon.BackgroundColor);
                }
                else
                {
                    IconBackground.Fill = new SolidColorBrush(Colors.LightGray);
                }
            }
            else
            {
                IconImage.Visibility = Visibility.Collapsed;
            }

            var actions = block.GetSimplifiedActions();

            if (actions.Any())
            {
                Buttons.Visibility = Visibility.Visible;

                FirstButton.Text = actions.First().Title;

                if (actions.Count() > 1)
                {
                    MoreButton.Visibility = Visibility.Visible;
                }
                else
                {
                    MoreButton.Visibility = Visibility.Collapsed;
                }
            }
            else
            {
                Buttons.Visibility = Visibility.Collapsed;
            }
        }
        public void Update(AdaptiveBlockContent block, AdaptiveBlock sourceBlock, PreviewBlockHostViewModel args)
        {
            try
            {
                Pages.Children.Clear();

                foreach (var b in block.GetFinalBlocks())
                {
                    Pages.Children.Add(new PreviewRichWatchBlock()
                    {
                        DataContext = b
                    });
                }

                if (block.Actions.Any())
                {
                    Pages.Children.Add(new PreviewRichWatchActionsPage()
                    {
                        DataContext = block.GetSimplifiedActions()
                    });
                }
            }
            catch { }
        }