How to make a Print Screen on Microsoft Source using WPF
After we took a look inside of Microsoft Surface, let’s see how to take a later look on the surface, by creating printscreens of the application.
In some WPF applications you’ll need to take a quick screenshot of the user’s screen, allowing him (or them, in case of Multi User Surface) for later reviewing. Now, on Surface there can be only one full screen and active application. So it use the entire screen of the device.
Here are the steps in order to accomplish that:
First, we need to add to Visual Studio project the references to the libraries that we’ll use:
using System.Drawing; using System.Drawing.Imaging; using System.Windows.Forms;
Then, we will add create the method that will do the actual saving to a specific file, with the format PNG:
public void MakeScreenshot(String fileName)
{
Bitmap bmpScreenshot;
Graphics gfxScreenshot;
//first, we create&set a bitmap object to the size of the screen
bmpScreenshot = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height, PixelFormat.Format32bppArgb);
//Using the bitmap, we create a graphics object
gfxScreenshot = Graphics.FromImage(bmpScreenshot);
//Copy the rectangle (the screen in our case) - from the upper left corner to the right bottom corner
gfxScreenshot.CopyFromScreen(Screen.PrimaryScreen.Bounds.X, Screen.PrimaryScreen.Bounds.Y, 0, 0, Screen.PrimaryScreen.Bounds.Size, CopyPixelOperation.SourceCopy);
// Do the saving, outputing a file by supplying the name and format it as PNG
bmpScreenshot.Save(fileName, ImageFormat.Png);
}
That’s all, folks – Use and enjoy!
Related posts:
- Change screen orientation of a Microsoft Surface application In order to understand the need of changing the screen...
- Microsoft Surface – What’s inside After starting the task, I started to be very...
- Microsoft Surface – new task and new challenges New day, new task, new challenges – Today I started...
- C# .Net using Post with HTTPWebRequest Just a reminder for posterity : posting with .Net its...
- How to generate image_src for Facebook links in Wordpress theme In this article I present a script that sets the...
Euro
Lira sterlina
Dolar SUA
Francul elvetian
Gramul de aur



