示例#1
0
        public DebuggingPage()
        {
            this.InitializeComponent();

            _dispatcher = CoreApplication.GetCurrentView().Dispatcher;
            Current     = this;
        }
 private void _renderer_OnCardChanges(object sender, string changes)
 {
     DebuggingPage.RunInWindowThread((page) =>
     {
         page.LatestChange = changes;
     });
 }
 private void _renderer_OnTransformedTemplateChanged(object sender, string transformedTemplate)
 {
     DebuggingPage.RunInWindowThread((page) =>
     {
         page.TransformedTemplate = transformedTemplate;
     });
 }
 private void _renderer_OnDataChanged(object sender, string data)
 {
     DebuggingPage.RunInWindowThread((page) =>
     {
         page.Data = data;
     });
 }
 private void _renderer_OnVirtualCardChanged(object sender, string newVirtualCard)
 {
     DebuggingPage.RunInWindowThread((page) =>
     {
         page.VirtualCardChanged(newVirtualCard);
     });
 }
        private void Render()
        {
            try
            {
                var cardPayload = TextBoxCardPayload.Text;

                DebuggingPage.RunInWindowThread((page) =>
                {
                    page.ResetForNewTemplate(cardPayload);
                });

                if (_renderer == null || _shouldResetData)
                {
                    _renderer = new AdaptiveCardRenderer();
                    _renderer.OnCardChanges += _renderer_OnCardChanges;
                    _renderer.OnTransformedTemplateChanged += _renderer_OnTransformedTemplateChanged;
                    _renderer.OnDataChanged        += _renderer_OnDataChanged;
                    _renderer.OnVirtualCardChanged += _renderer_OnVirtualCardChanged;
                    CardContainer.Child             = _renderer.Render(cardPayload, TextBoxDataPayload.Text, CardScript.Text);
                }
                else
                {
                    _renderer.UpdateTemplate(cardPayload);
                }

                _shouldResetData = false;
            }
            catch (Exception ex)
            {
                CardContainer.Child = new TextBlock()
                {
                    Text         = ex.ToString(),
                    TextWrapping = TextWrapping.Wrap
                };
            }
        }