/// <summary>
        /// Cleans up all the field members that implement the IDisposable interface.
        /// (This should only be called from the forms dispose method)
        /// </summary>
        /// <param name="bDispose">True to dispose of managed resources.</param>
        /// <returns></returns>
        private void CleanUpResources(bool bDispose)
        {
            if (bDispose)
            {
                // Clean up and release the print document object.
                if (m_oPrintDocument != null)
                {
                    m_oPrintDocument.Dispose();
                    m_oPrintDocument = null;
                }

                // Clean up the ImageEditManagement object.
                if ((m_oUndoRedo != null) && (!m_oUndoRedo.IsDisposed))
                {
                    m_oUndoRedo.Dispose();
                    m_oUndoRedo = null;
                }

                // Clean up the image browser object.
                if ((m_oImageBrowser != null) && (!m_oImageBrowser.IsDisposed))
                {
                    m_oImageBrowser.Dispose();
                    m_oImageBrowser = null;
                }

                // Clean up the explorer docking window object.
                if ((m_oExplorerDockWindow != null) && (!m_oExplorerDockWindow.IsDisposed))
                {
                    m_oExplorerDockWindow.Dispose();
                    m_oExplorerDockWindow = null;
                }

                // Clean up the image list docking window object.
                if ((m_oImageListDockWindow != null) && (!m_oImageListDockWindow.IsDisposed))
                {
                    m_oImageListDockWindow.Dispose();
                    m_oImageListDockWindow = null;
                }

                // Clean up the task docking window object.
                if ((m_oTaskDockWindow != null) && (!m_oTaskDockWindow.IsDisposed))
                {
                    m_oTaskDockWindow.Dispose();
                    m_oTaskDockWindow = null;
                }

                // Clean up the screen shot form.
                if ((m_oScreenShotForm != null) && (!m_oScreenShotForm.IsDisposed))
                {
                    m_oScreenShotForm.Dispose();
                    m_oScreenShotForm = null;
                }

                // Clean up the new window form.
                if ((m_oNewWindowForm != null) && (!m_oNewWindowForm.IsDisposed))
                {
                    m_oNewWindowForm.Dispose();
                    m_oNewWindowForm = null;
                }

                // Clean up the new window list.
                if ((m_oNewWindows != null) && (m_oNewWindows.Count > 0))
                {
                    m_oNewWindows.Clear();
                    m_oNewWindows = null;
                }

                // Clean up the slide show.
                if ((m_oSlideShowForm != null) && (!m_oSlideShowForm.IsDisposed))
                {
                    m_oSlideShowForm.Close();
                    m_oSlideShowForm = null;
                }

                // Clean up the red eye panel.
                if ((m_oRedEyePanel != null) && (!m_oRedEyePanel.IsDisposed))
                {
                    m_oRedEyePanel.Dispose();
                    m_oRedEyePanel = null;
                }

                // Clean up the resize panel.
                if ((m_oResizePanel != null) && (!m_oResizePanel.IsDisposed))
                {
                    m_oResizePanel.Dispose();
                    m_oResizePanel = null;
                }

                // Clean up the properties panel.
                if ((m_oPropertiesPanel != null) && (!m_oPropertiesPanel.IsDisposed))
                {
                    m_oPropertiesPanel.Dispose();
                    m_oPropertiesPanel = null;
                }
            }
        }
        /// <summary>
        /// iView.NET subroutine. Opens a new window loaded with the image currently being viewed in the main window.
        /// </summary>
        /// <returns></returns>
        private SResult SubOpenNewWindow()
        {
            if (!imgbx_MainImage.IsImageLoaded)
                return SResult.NullDisplayImage;

            if (m_oNewWindows.Count >= IViewSettings.Default.MaxWindows)
                return SResult.Void;

            Image oImage = imgbx_MainImage.ImageBoxImage;
            m_oNewWindowForm = new NewWindow(oImage);
            m_oItem = new ToolStripMenuItem();

            // Create a new FormNewWindow object.
            m_oNewWindowForm.Text = Path.GetFileName(m_oImageBrowser.SelectedFile);
            m_oNewWindowForm.Tag = m_oItem;
            m_oNewWindowForm.Icon = DrawingTools.CreateScaledIconFromImage(oImage, 16, 16);
            m_oNewWindowForm.FormClosed += delegate(object oSender, FormClosedEventArgs oEventArgs)
            {
                NewWindow oNewWindow = oSender as NewWindow;

                if (oNewWindow != null)
                {
                    ToolStripMenuItem oItem = (ToolStripMenuItem)oNewWindow.Tag;

                    if ((oItem != null) && (!oItem.IsDisposed))
                        tsmi_view_Windows.DropDown.Items.Remove(oItem);

                    m_oNewWindows.Remove(oNewWindow);
                }
            };
            m_oNewWindowForm.Show();

            // Create a new toolstrip menu item.
            m_oItem.Text = m_oNewWindowForm.Text;
            m_oItem.Tag = m_oNewWindowForm.Handle;
            m_oItem.Image = DrawingTools.CreateThumbnail(oImage, 16, 16, true, ThumbnailEffect.None);
            m_oItem.Click += delegate(object oSender, EventArgs oEventArgs)
            {
                if (oSender != null)
                {
                    IntPtr hWnd = (IntPtr)((ToolStripMenuItem)oSender).Tag;

                    if (hWnd != IntPtr.Zero)
                        Form.FromHandle(hWnd).Focus();
                }
            };

            // Add the new window to the form list.
            m_oNewWindows.Add(m_oNewWindowForm);

            // Add a new item to the windows drop down.
            tsmi_view_Windows.DropDown.Items.Add(m_oItem);

            return SResult.Completed;
        }