protected override void DoWork()
        {
            Trace.WriteLine("UpdateSemanticHtmlPreviewAsyncOperation started for blog(" + BlogId + ")");

            Size newSize = new Size(1500, 1000);

            _screenCapture     = new HtmlScreenCaptureCore(_html, newSize.Width);
            _screenCapture.Ids = _elementIds;
            _screenCapture.HtmlScreenCaptureAvailable += new HtmlScreenCaptureAvailableHandlerCore(screenCapture_HtmlScreenCaptureAvailable);
            _screenCapture.MaximumHeight = newSize.Height;
            _screenCapture.CaptureHtml(45000);
        }
Пример #2
0
        public override bool ValidateSelection()
        {
            if (_video == null)
            {
                string input = videoCode.Text.Trim();
                try
                {
                    _video = VideoProviderManager.FindVideo(input);
                }
                catch (VideoUrlConvertException)
                {
                    DisplayHtml(Res.Get(StringId.VideoUrlConvertError), CreateErrorHtml);
                    return(false);
                }

                if (_video == null)
                {
                    DisplayHtml(Res.Get(StringId.Plugin_Video_Cannot_Parse_Url_Message), CreateErrorHtml);
                    return(false);
                }
            }

            IViewObject element = GetIViewObjectElement(previewBox.Document.Body);

            // The object doesnt cant have a snapshot taken of it, but we should still allow it to
            // be inserted, though on some providers this means it might be stripped.
            // NOTE: We skip this behavior on IE9+ because of WinLive 589461.
            if (element == null || ApplicationEnvironment.BrowserVersion.Major >= 9)
            {
                _video.Snapshot = null;
                return(true);
            }

            try
            {
                _video.Snapshot = HtmlScreenCaptureCore.TakeSnapshot(element, _video.Width, _video.Height);
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Failed to take video snapshot: " + ex);
                _video.Snapshot = null;
            }

            return(true);
        }
Пример #3
0
        private string GetSnapshotPathIfNeeded(HtmlType htmlType, VideoContext context)
        {
            // NOTE: We skip this behavior on IE9+ because of WinLive 589461.
            if (htmlType == HtmlType.ObjectHtml || ApplicationEnvironment.BrowserVersion.Major >= 9)
            {
                return(null);
            }

            try
            {
                IHTMLElement element = context.GetElement(((IInternalContent)_content).Id);

                if (element != null)
                {
                    element = ((IHTMLDOMNode)element).firstChild as IHTMLElement;
                }

                if (element != null && (element is IViewObject))
                {
                    Bitmap snapshot = HtmlScreenCaptureCore.TakeSnapshot((IViewObject)element, element.offsetWidth, element.offsetHeight);
                    UpdateVideoSnapshot(snapshot);
                }

                Uri uri = _content.Files.GetUri(_content.Properties.GetString(VIDEO_PUBLISH_IMAGE, String.Empty));

                if (uri != null)
                {
                    return(uri.ToString());
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine("Failed to take video snapshot: " + ex);
            }

            return(null);
        }
Пример #4
0
 /// <summary>
 /// Initialize a screen capture for a snippet of HTML content.
 /// </summary>
 /// <param name="htmlContent">HTML snippet to capture.</param>
 /// <param name="contentWidth">Width of content.</param>
 public HtmlScreenCapture(string htmlContent, int contentWidth)
 {
     _htmlScreenCapture = new HtmlScreenCaptureCore(htmlContent, contentWidth);
     SubscribeToEvents();
 }
Пример #5
0
 /// <summary>
 /// Initialize a screen capture for an HTML page located at a URL.
 /// </summary>
 /// <param name="url">Url of HTML page to capture.</param>
 /// <param name="contentWidth">Width of content.</param>
 public HtmlScreenCapture(Uri url, int contentWidth)
 {
     _htmlScreenCapture = new HtmlScreenCaptureCore(url, contentWidth);
     SubscribeToEvents();
 }