Esempio n. 1
0
        /// <summary>
        /// Creates a thumbnail for the given website by invoking a dialog,
        /// loads the url, captures the surface, closes the dialog.
        /// </summary>
        /// <param name="url">URL of browser location</param>
        /// <param name="presentationSize">The <see cref="Size"/> for the thumb.</param>
        /// <returns>An <see cref="Image"/> with the thumbnail image.</returns>
        private static Image CreateBrowserThumb(string url, Size presentationSize)
        {
            Bitmap bmp = WebsiteThumbnailGenerator.GetWebSiteThumbnail(
                url,
                presentationSize.Width,
                presentationSize.Height,
                presentationSize);

            return(bmp);
        }
Esempio n. 2
0
        /// <summary>
        /// Creates a new <see cref="Slide"/> with the
        /// properties defined on this dialog and creates a thumb for it.
        /// </summary>
        /// <returns>The new <see cref="Slide"/> to be added to the slideshow.</returns>
        private BrowserTreeNode GetBrowserSlide()
        {
            if (this.browserTreeNode == null)
            {
                this.browserTreeNode = new BrowserTreeNode();
            }

            // Store category and name.
            this.browserTreeNode.Category    = this.cbbCategory.Text;
            this.browserTreeNode.Text        = this.txbName.Text;
            this.browserTreeNode.OriginURL   = this.txbURL.Text;
            this.browserTreeNode.BrowseDepth = (int)this.nudBrowseDepth.Value;

            // Add standard stop condition if none is specified.
            if (this.lsbStopConditions.Items.Count == 0)
            {
                this.lsbStopConditions.Items.Add(new TimeStopCondition(SlideDesignModule.SLIDEDURATIONINS * 1000));
            }

            Slide baseURLSlide = new Slide();

            baseURLSlide.Category           = this.cbbCategory.Text;
            baseURLSlide.Modified           = true;
            baseURLSlide.Name               = this.txbName.Text;
            baseURLSlide.PresentationSize   = Document.ActiveDocument.PresentationSize;
            baseURLSlide.MouseCursorVisible = true;

            // Store Stop conditions
            foreach (StopCondition cond in this.lsbStopConditions.Items)
            {
                baseURLSlide.StopConditions.Add(cond);
            }

            Bitmap screenshot = WebsiteThumbnailGenerator.GetWebSiteScreenshot(
                this.txbURL.Text,
                Document.ActiveDocument.PresentationSize);
            string screenshotFilename = GetFilenameFromUrl(new Uri(this.txbURL.Text));
            var    filename           = Path.Combine(Document.ActiveDocument.ExperimentSettings.SlideResourcesPath, screenshotFilename);

            screenshot.Save(filename, System.Drawing.Imaging.ImageFormat.Png);

            VGScrollImage baseURLScreenshot = new VGScrollImage(
                ShapeDrawAction.None,
                Pens.Transparent,
                Brushes.Black,
                SystemFonts.DefaultFont,
                Color.Black,
                Path.GetFileName(screenshotFilename),
                Document.ActiveDocument.ExperimentSettings.SlideResourcesPath,
                ImageLayout.None,
                1f,
                Document.ActiveDocument.PresentationSize,
                VGStyleGroup.None,
                baseURLSlide.Name,
                string.Empty);

            baseURLSlide.VGStimuli.Add(baseURLScreenshot);
            this.browserTreeNode.Slide = baseURLSlide;

            // HtmlElementCollection es = webBrowser1.Document.GetElementsByTagName("a");
            // if (es != null && es.Count != 0)
            // {
            //  HtmlElement ele = es[0];
            //  //This line is optional, it only visually scolls the first link element into view
            //  ele.ScrollIntoView(true);
            //  ele.Focus();
            // SendKeys.Send("{ENTER}");
            // }
            return(this.browserTreeNode);
        }