Making Form Screenshots In .NET

Have you ever need to take a screenshot of your .NET form from code within the form?  Some sort of print screen method?  Don’t touch that PrtSc button just yet, there is another way.

No, I’m not talking about using the gdi32.dll or the Visual Basic Power Pack.  The .NET graphics object has it’s own built in screenshot-taking ability, and ImageSource is here to help show you how to use it.

Getting a screenshot of your form is as easy as instantiating a Bitmap object (sized to your form’s width and height), creating a graphics object from that bitmap and finally calling Graphics object’s CopyFromScreen method.  The code below demonstrates how to do this:

private Bitmap GetFormScreenshot(Form frmRef)
{
   //Setup the bitmap and graphics objects
   Bitmap bmp = new Bitmap(frmRef.Width, frmRef.Height,
      PixelFormat.Format32bppArgb);
   Graphics gfx = Graphics.FromImage(bmp);

   //Take the screenshot
   gfx.CopyFromScreen(frmRef.Bounds.X, frmRef.Bounds.Y, 0, 0,
       frmRef.Bounds.Size, CopyPixelOperation.SourceCopy);   return bmp;
}

Wow, it’s just that simple.  Enjoy the rest of your day knowing that you’ll be screenshotting your troubles away.

Installing Silverlight 4 Beta

clip_image001

If you are getting an install error while trying to install Silverlight 4 Beta on an existing machine with Silverlight 3 SDK installed, please verify that your Silverlight 3 SDK version is 3.0.40818.0.

If you have an older version installed, you can uninstall it and reinstall a newer version here.

Hope this helps.

Phong Hoang
ImageSource, Inc.

ECM Best Practices: Training

One of the most useful but less known trick in a fully managed Oracle UCM production site, for example ImageSource, Inc.,  is to prevent content editing on a web site.  By default, a managed or dynamic site allows the content owners to enter the contributor mode by navigating to web pages and hit a standard hot key Ctrl + Shift + F5.  This mode is all fine and useful in development and contribution servers, but it is a no no in a production environment.

Continue reading

The DataContractSerializer – XML Files Made Easy

With the release of .NET 3.5, Microsoft has included a fun new tool for data serializing.  The DataContractSerializer was introduced as a replacement for the current XmlSerializer class, and is the preferred XML data serializer of developers at ImageSource.

The DataContractSerializer class uses opt-in properties for it’s serialization rather than the XmlSerializer class’s opt-out methodology.  This means that the programmer must specify what class properties are to included in serialization.  It’s also up to the programmer to serialize fields, properties and non-public data.

Continue reading