Exemplo n.º 1
0
        private void Render()
        {
            if (ImageGenerationHandler != null && Config.ImageGemerationConfiguration.EnableExternalImageGenerator)
            {
                // Use external Generator
                if (string.IsNullOrEmpty(Id))
                {
                    Id = Guid.NewGuid().ToString("D");
                }
                ExpectedSerial++;

                // Dispatch Generation Image
                ImageGenerationHandler.DispatchGeneration(Id, ExpectedSerial, this);

                // Register Callback for image return
                ImageGenerationHandler.RegisterImageCallback(Id, ExpectedSerial, this);
            }
            else
            {
                Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Render,
                                                           (SendOrPostCallback) delegate
                {
                    PublicImageUrl = null;
                    PreviewImage   =
                        HTMLRenderer.Base64ToImage(RenderImageWithTemplateContext(generationProperties: null));
                    _rendering         = false;
                    LastGenerationTime = DateTime.Now;
                }, null);
            }
        }
Exemplo n.º 2
0
 public void DispatchedExternalPreviewUpdate(long newSerial, string newImageBase64)
 {
     // Update in Dispatcher
     Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Render,
                                                (SendOrPostCallback) delegate
     {
         PreviewImage = HTMLRenderer.Base64ToImage(newImageBase64);
     }, null);
 }
Exemplo n.º 3
0
        public string RenderAndReturnBase64(string generationProperties = null)
        {
            _rendering = true;
            var image = RenderImageWithTemplateContext(generationProperties);

            Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Render,
                                                       (SendOrPostCallback) delegate
            {
                PublicImageUrl     = null;
                PreviewImage       = HTMLRenderer.Base64ToImage(image);
                _rendering         = false;
                LastGenerationTime = DateTime.Now;
            }, null);

            return(image);
        }