private static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(Program.CurrentDomain_UnhandledException);

               //ExceptionTracker.TestStackTrace(0, 10);
               // var ex = new NullReferenceException("Message");
               //throw ex;

            if (!Program.CatchStuff)
            {
                using (Game1 game = new Game1())
                {
                    game.Run();
                }
            }
            else
            {
                try
                {
                    using (SingleGlobalInstance singleGlobalInstance = new SingleGlobalInstance(1000))
                    {
                        using (Game1 game = new Game1())
                        {
                            game.Run();
                        }
                    }
                }
                catch (Exception exception)
                {
                    Exception e = exception;
                    MessageBox.Show(string.Concat("Whoops! Please post a screenshot of this to the StarDrive forums (", MainMenuScreen.Version, "):\n\n", e.ToString()));
                }
            }
        }
		public void SetWindowMode(Game1.WindowMode mode, int width, int height)
		{
            if (width <= 0 || height <= 0)
            {
                width = 800;
                height = 600;
            }
			Form form = (Form)Control.FromHandle(base.Window.Handle);
#if DEBUG
            if (mode == WindowMode.Fullscreen)
                mode = WindowMode.Borderless; 
#endif
            switch (mode)
			{
				case Game1.WindowMode.Fullscreen:
				{
					if (!this.graphics.IsFullScreen)
					{
						this.graphics.ToggleFullScreen();
					}
                    
					this.graphics.PreferredBackBufferWidth = width;
					this.graphics.PreferredBackBufferHeight = height;
					this.graphics.ApplyChanges();
					this.CurrentMode = Game1.WindowMode.Fullscreen;
					GlobalStats.Config.WindowMode = 0;
					return;
				}
				case Game1.WindowMode.Windowed:
				{
					if (this.graphics.IsFullScreen)
					{
						this.graphics.ToggleFullScreen();
					}
					this.graphics.PreferredBackBufferWidth = width;
					this.graphics.PreferredBackBufferHeight = height;
					this.graphics.ApplyChanges();
					form.WindowState = FormWindowState.Normal;
					form.FormBorderStyle = FormBorderStyle.Fixed3D;
					form.ClientSize = new Size(width, height);
					Size size = Screen.PrimaryScreen.WorkingArea.Size;
					int num = size.Width / 2 - width / 2;
					Size size1 = Screen.PrimaryScreen.WorkingArea.Size;
					form.Location = new System.Drawing.Point(num, size1.Height / 2 - height / 2);
					this.CurrentMode = Game1.WindowMode.Windowed;
					GlobalStats.Config.WindowMode = 1;
					return;
				}
				case Game1.WindowMode.Borderless:
				{
					if (this.graphics.IsFullScreen)
					{
						this.graphics.ToggleFullScreen();
					}
					this.graphics.PreferredBackBufferWidth = width;
					this.graphics.PreferredBackBufferHeight = height;
					this.graphics.ApplyChanges();
					form.FormBorderStyle = FormBorderStyle.None;
					form.WindowState = FormWindowState.Normal;
					form.ClientSize = new Size(width, height);
					Size size2 = Screen.PrimaryScreen.WorkingArea.Size;
					int num1 = size2.Width / 2 - width / 2;
					Size size3 = Screen.PrimaryScreen.WorkingArea.Size;
					form.Location = new System.Drawing.Point(num1, size3.Height / 2 - height / 2);
					this.CurrentMode = Game1.WindowMode.Borderless;
					GlobalStats.Config.WindowMode = 2;
					return;
				}
				default:
				{
					return;
				}
			}
		}
		protected override void Initialize()
		{
			base.Window.Title = "StarDrive";
			base.Content.RootDirectory = "Content";
			this.screenManager = new ScreenManager(this, this.graphics)
			{
				splashScreenGameComponent = new SplashScreenGameComponent(this, this.graphics)
			};
			base.Components.Add(this.screenManager.splashScreenGameComponent);
			AudioManager.Initialize(this, "Content/Audio/ShipGameProject.xgs", "Content/Audio/Wave Bank.xwb", "Content/Audio/Sound Bank.xsb");
            
			Game1.Instance = this;
			base.Initialize();
		}