예제 #1
0
        private void DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            WebBrowser browser = sender as WebBrowser;

            if (browser == null)
            {
                return;
            }

            if (browser.Document == null || browser.Document.Body == null)
            {
                return;
            }

            if (string.IsNullOrWhiteSpace(browser.Tag.ToString()))
            {
                return;
            }

            File.Delete(browser.Tag.ToString());

            browser.Document.Body.Style = "zoom:100%;";

            var element = browser.Document.GetElementById("ReportParameterPanel");

            if (element != null)
            {
                element.OuterHtml = "";
                element.InnerHtml = "";
            }

            if (browser.Document.Body != null)
            {
                const int margin    = 100;
                var       height    = browser.Document.Body.ScrollRectangle.Height + margin;
                var       width     = browser.Width;
                var       imagePath = browser.Tag.ToString().Replace(".html", ".png");

                using (Bitmap bitmap = new Bitmap(width + 2 * margin, height))
                {
                    using (Graphics g = Graphics.FromImage(bitmap))
                    {
                        g.Clear(Color.White);
                        g.DrawImage(bitmap, 0, 0, width + 2 * margin, height);
                    }

                    browser.DrawToBitmap(bitmap, new Rectangle(margin, 0, width, height));
                    bitmap.SetResolution(3200, 3200);
                    bitmap.Save(imagePath, GetEncoder(ImageFormat.Png), null);

                    EmailProcessor processor = new EmailProcessor();
                    processor.Send(this.Recipient, this.Subject, this.EmailBody, EmailAttachment.GetAttachments(imagePath));
                }
            }
        }
예제 #2
0
        private void Serializer_ImageSaved(object sender, ImageSavedEventArgs e)
        {
            EmailProcessor processor = new EmailProcessor();

            processor.Send(this.Recipient, this.Subject, this.EmailBody, EmailAttachment.GetAttachments(e.ImagePath));
        }