コード例 #1
0
        public string Execute([NotNull] string databaseName, [NotNull] string itemId)
        {
            Assert.ArgumentNotNull(databaseName, nameof(databaseName));
            Assert.ArgumentNotNull(itemId, nameof(itemId));

            var url = itemId;

            var database = Factory.GetDatabase(databaseName);

            Assert.IsNotNull(database, typeof(Database));

            Item item;

            try
            {
                item = database.GetItem(itemId);
            }
            catch
            {
                item = null;
            }

            if (item != null)
            {
                url = GetItemUrl(databaseName, itemId);
                if (string.IsNullOrEmpty(url))
                {
                    return(string.Empty);
                }
            }

            var filename = TempFolder.GetFilename("thumbnail.png");

            var htmlCapture = new HtmlCapture
            {
                Url      = url,
                FileName = filename
            };

            if (htmlCapture.Capture())
            {
                return(filename);
            }

            return(string.Empty);
        }
コード例 #2
0
 private void btnScreenshot_Click(object sender, RoutedEventArgs e)
 {
     if (!string.IsNullOrWhiteSpace(txtUrl.Text))
     {
         if (!string.IsNullOrWhiteSpace(txtSaveLocation.Text))
         {
             HtmlCapture capture = new HtmlCapture(txtSaveLocation.Text);
             capture.HtmlImageCapture += new HtmlCapture.HtmlCaptureEvent(capture_HtmlImageCapture);
             capture.Create(txtUrl.Text);
         }
         else
         {
             MessageBox.Show("Please enter Save Location with image name");
         }
     }
     else
     {
         MessageBox.Show("Please enter URL");
     }
 }