private void FormContainer_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                SaveSettings();

                formMain.Shutdown();
                formMain.Close();
                formWaterfall.Shutdown();
                formWaterfall.Close();
                formROI.Close();
                formMap.Close();
                formLog.Close();
            }
            catch (Exception ex)
            {
                log.Error(ex.Message, ex);
            }
        }
        private void FormContainer_Load(object sender, EventArgs e)
        {
            try
            {
                formLog      = new FormLog(this);
                formLog.Left = -1000;
                IntPtr iptr = formLog.Handle; // Force window handle creation
                log = GetLog(formLog.GetTextBox());

                // Create directories and files
                if (!Directory.Exists(GAEnvironment.SettingsPath))
                {
                    Directory.CreateDirectory(GAEnvironment.SettingsPath);
                }

                installDir = Path.GetDirectoryName(Environment.GetCommandLineArgs()[0]) + Path.DirectorySeparatorChar;

                if (!File.Exists(GAEnvironment.NuclideLibraryFile))
                {
                    File.Copy(installDir + "template_nuclides.lib", GAEnvironment.NuclideLibraryFile);
                }

                LoadSettings();

                formWaterfall      = new FormWaterfall(this, settings, log);
                formWaterfall.Left = -1000;
                formROI            = new FormROI(this, settings, log);
                formROI.Left       = -1000;
                formMap            = new FormMap(this, settings, log);
                formMap.Left       = -1000;
                formMain           = new FormMain(this, settings, log);
                formMain.Left      = -1000;

                menuItemLayoutSession_Click(sender, e);

                statusLabel.Text = "";
            }
            catch (Exception ex)
            {
                log.Fatal(ex.Message, ex);
                MessageBox.Show("Unable to load application. See log for details", "Error");

                if (formMain != null)
                {
                    formMain.Shutdown();
                    formMain.Close();
                }

                if (formMap != null)
                {
                    formMap.Close();
                }

                if (formROI != null)
                {
                    formROI.Close();
                }

                if (formWaterfall != null)
                {
                    formWaterfall.Shutdown();
                    formWaterfall.Close();
                }

                if (formLog != null)
                {
                    formLog.Close();
                }

                Environment.Exit(1);
            }
        }