Ejemplo n.º 1
0
        private System.Drawing.Bitmap GetScreenshot()
        {
            try
            {
                var rct = WindowSupplement.GetWindowRect(_mainWindow);

                var screenshot = new System.Drawing.Bitmap((int)rct.Width, (int)rct.Height);
                using (var g = System.Drawing.Graphics.FromImage(screenshot))
                {
                    g.CopyFromScreen(new System.Drawing.Point((int)rct.Left, (int)rct.Top), System.Drawing.Point.Empty, screenshot.Size);
                }
                return(screenshot);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Failed to save screenshot. " + ex.Message,
                                ProductInfo.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return(null);
            }
        }