예제 #1
0
        /// <summary>
        /// Creates a thumbnail of the specified window.
        /// </summary>
        /// <param name="window">The window.</param>
        /// <param name="width">The width of the thumbnail.</param>
        /// <param name="path">The output path.</param>
        private static void CreateThumbnail(Window window, int width, string path)
        {
            var bitmap = ScreenCapture.Capture(
                (int)window.Left,
                (int)window.Top,
                (int)window.ActualWidth,
                (int)window.ActualHeight);
            var newHeight     = width * bitmap.Height / bitmap.Width;
            var resizedBitmap = BitmapTools.Resize(bitmap, width, newHeight);

            resizedBitmap.Save(path);
        }
예제 #2
0
        /// <summary>
        /// Creates a thumbnail of the specified window.
        /// </summary>
        /// <param name="window">The window.</param>
        /// <param name="width">The width of the thumbnail.</param>
        /// <param name="path">The output path.</param>
        /// <param name="delay">The delay before capturing the window (in milliseconds).</param>
        private static void CreateThumbnail(Window window, int width, string path, double delay)
        {
            var timer = new DispatcherTimer {
                Interval = TimeSpan.FromMilliseconds(delay)
            };

            timer.Tick += (s, a) =>
            {
                var bitmap = ScreenCapture.Capture(
                    (int)window.Left,
                    (int)window.Top,
                    (int)window.ActualWidth,
                    (int)window.ActualHeight);
                var newHeight     = width * bitmap.Height / bitmap.Width;
                var resizedBitmap = BitmapTools.Resize(bitmap, width, newHeight);
                resizedBitmap.Save(path);
                timer.Stop();
            };
            timer.Start();
        }