Bloom.Shell.Shell_Load C# (CSharp) Method

Shell_Load() private method

private Shell_Load ( object sender, EventArgs e ) : void
sender object
e EventArgs
return void
        private void Shell_Load(object sender, EventArgs e)
        {
            //Handle window sizing/location. Normally, we just Maximize the window.
            //The exceptions to this are if we are in a DEBUG build or the settings have a MaximizeWindow=='False", which at this time
            //must be done by hand (no user UI is provided).
            try
            {
                SuspendLayout();

                if(Settings.Default.WindowSizeAndLocation == null)
                {
                    StartPosition = FormStartPosition.WindowsDefaultLocation;
                    WindowState = FormWindowState.Maximized;
                    Settings.Default.WindowSizeAndLocation = FormSettings.Create(this);
                    Settings.Default.Save();
                }

                // This feature is not yet a normal part of Bloom, since we think just maximizing is more rice-farmer-friendly.
                // However, we added the ability to remember this stuff at the request of the person making videos, who needs
                // Bloom to open in the same place / size each time.
                if (Settings.Default.MaximizeWindow == false)
                {
                    Settings.Default.WindowSizeAndLocation.InitializeForm(this);
                }
                else
                {
                    // BL-1036: save and restore un-maximized settings
                    var savedBounds = Settings.Default.RestoreBounds;
                    if ((savedBounds.Width > 200) && (savedBounds.Height > 200) && (IsOnScreen(savedBounds)))
                    {
                        StartPosition = FormStartPosition.Manual;
                        WindowState = FormWindowState.Normal;
                        Bounds = savedBounds;
                    }
                    else
                    {
                        StartPosition = FormStartPosition.CenterScreen;
                    }

                    WindowState = FormWindowState.Maximized;
                }
            }
            catch (Exception error)
            {
                Debug.Fail(error.Message);

            // ReSharper disable HeuristicUnreachableCode
                //Not worth bothering the user. Just reset the values to something reasonable.
                StartPosition = FormStartPosition.WindowsDefaultLocation;
                WindowState = FormWindowState.Maximized;
            // ReSharper restore HeuristicUnreachableCode
            }
            finally
            {
                ResumeLayout();
            }
        }