/// <summary>
        /// Saves the contents of the window to a bitmap file stored in the users documents folder.
        /// </summary>
        private void SaveToFile()
        {
            try
            {
                bool bSave = false;
                string sFilePath = string.Empty;
                string sDirectory = ApplicationData.CapturedImagesFolder + Path.DirectorySeparatorChar;
                DirectoryInfo oDirectory = new DirectoryInfo(sDirectory);

                // Create the directory if it doesn't exist.
                if (!oDirectory.Exists)
                    oDirectory.Create();

                // Generate a file path.
                for (int n = 0; n < MAX_FILES; n++)
                {
                    sFilePath = sDirectory + FILE_NAME_PREFIX + n.ToString("x4") + ".bmp";

                    if (!File.Exists(sFilePath))
                    {
                        bSave = true;
                        break;
                    }
                }

                // If the file path generated was successfull, save the image.
                if (bSave)
                {
                    using (Bitmap oBitmap = new Bitmap(this.Width, this.Height))
                    {
                        using (Graphics oGraphics = Graphics.FromImage(oBitmap))
                        {
                            this.Visible = false;
                            oGraphics.CopyFromScreen(this.Location.X, this.Location.Y, 0, 0, this.Size);
                            this.Visible = true;

                            using (ImageSaver oImageSaver = new ImageSaver(oBitmap))
                            {
                                oImageSaver.FilePath = sFilePath;
                                oImageSaver.SaveAsBmp(BitDepth.BPP32);
                            }
                        }
                    }
                }
                else
                {
                    MessageBox.Show("Unable to save the image.\n\nThe maximum file count (" + MAX_FILES + ") has been reached.", "Save Error",
                        MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            catch (ArgumentException e)
            {
                MessageBox.Show("Unable to save image.\n\nReason: " + e.Message, "Save Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (UnauthorizedAccessException e)
            {
                MessageBox.Show("Unable to save image.\n\nReason: " + e.Message, "Save Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (IOException e)
            {
                MessageBox.Show("Unable to save image.\n\nReason: " + e.Message, "Save Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (System.Security.SecurityException e)
            {
                MessageBox.Show("Unable to save image.\n\nReason: " + e.Message, "Save Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
        /// <summary>
        /// iView.NET subroutine. Saves the current image to the specified type and file path.
        /// Displays a dialog box allowing the user to specify the save settings for the specified ImageFileType.
        /// </summary>
        /// <param name="nFileType">Specifies the type of image file to save.</param>
        /// <param name="sFilePath">Specifies the path of the image file.</param>
        private SResult SubSave(ImageFileType nFileType, string sFilePath)
        {
            if (!imgbx_MainImage.IsImageLoaded)
                return SResult.NullDisplayImage;

            try
            {
                using (ImageSaver oImageSaver = new ImageSaver(imgbx_MainImage.ImageBoxImage))
                {
                    oImageSaver.FilePath = sFilePath;

                    switch (nFileType)
                    {
                        case ImageFileType.Bmp:
                            using (BmpSettings oForm = new BmpSettings())
                            {
                                if (oForm.ShowDialog(this) == DialogResult.OK)
                                    oImageSaver.SaveAsBmp(oForm.SelectedBitDepth);
                                else
                                    return SResult.Canceled;
                            }
                            break;
                        case ImageFileType.Gif:
                            oImageSaver.SaveAsGif();
                            break;
                        case ImageFileType.Icon:
                            oImageSaver.SaveAsIcon();
                            break;
                        case ImageFileType.Jpeg:
                            using (JpegSettings oForm = new JpegSettings())
                            {
                                if (oForm.ShowDialog(this) == DialogResult.OK)
                                {
                                    oImageSaver.SaveAsJpeg(oForm.Quality,
                                        oForm.PreserveMetadata ? m_oImageBrowser.PropertyItems : null);
                                }
                                else
                                    return SResult.Canceled;
                            }
                            break;
                        case ImageFileType.Png:
                            oImageSaver.SaveAsPng();
                            break;
                        case ImageFileType.Tiff:
                            using (TiffSettings oForm = new TiffSettings())
                            {
                                if (oForm.ShowDialog(this) == DialogResult.OK)
                                {
                                    oImageSaver.SaveAsTiff(oForm.SelectedBitDepth, oForm.SelectedCompression,
                                        oForm.PreserveMetadata ? m_oImageBrowser.PropertyItems : null);
                                }
                                else
                                    return SResult.Canceled;
                            }
                            break;
                    }
                }

                if ((m_nImageListViewType != ImageListViewType.Details) && (m_nImageListViewType != ImageListViewType.List))
                {
                    int nIndex = m_oImageBrowser.GetIndexFromFilePath(sFilePath);

                    if ((nIndex != -1) && (elvw_Images.LargeImageList.Images.Count > nIndex))
                    {
                        // Update the large image list with the current.
                        elvw_Images.LargeImageList.Images[nIndex] = DrawingTools.CreateThumbnail(
                            imgbx_MainImage.ImageBoxImage,
                            elvw_Images.LargeImageList.ImageSize,
                            IViewSettings.Default.HighQualityThumbnails,
                            IViewSettings.Default.ThumbnailEffect);

                        // Redraw the specified image in the image list.
                        elvw_Images.RedrawItems(nIndex, nIndex, false);
                    }
                }

                // Set the save image edited status to false.
                ImageHasBeenEdited = false;

                return SResult.Completed;
            }
            catch (ArgumentNullException e)
            {
                MessageBox.Show("Unable to save the image.\n\nReason: " + e.Message, "Save Image Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (UnauthorizedAccessException e)
            {
                MessageBox.Show("Unable to save the image.\n\nReason: " + e.Message, "Save Image Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (IOException e)
            {
                MessageBox.Show("Unable to save the image.\n\nReason: " + e.Message, "Save Image Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (System.Security.SecurityException e)
            {
                MessageBox.Show("Unable to save the image.\n\nReason: " + e.Message, "Save Image Error",
                    MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            return SResult.Void;
        }