internal CommandConsole(LuaEnvironment lua, DrawingSizeF screenSize, GameApplication.OutputStreams streams, int maxLines = 500)
 {
     Debug.Assert(lua != null, "Lua environment can not be null");
     Debug.Assert(streams != null, "Streams can not be null");
     _streams = streams;
     _lua = lua;
     _outputView = ToDispose<OutputView>(new OutputView(screenSize));
     _inputView = ToDispose<InputView>(new InputView(_outputView));
 }
        public GameApplication(string configPath = "config/config.cfg", string formTitle = "Default Form Title")
            : base()
        {
            if(_singleton != null)
                _singleton.Exit();
            _singleton = this;
            _mainThreadId = Thread.CurrentThread.ManagedThreadId;

            _streams = ToDispose<OutputStreams>(new OutputStreams());

            _formTitle = formTitle;
            _appConfiguration = configPath == null ? new ApplicationConfig() : new ApplicationConfig(configPath);
            _initializeForm();
            _initializeGraphics();
            Lua = new LuaEnvironment();
            _commandConsole = ToDispose<CommandConsole>(new CommandConsole(Lua, new DrawingSizeF(Viewport.Width, Viewport.Height), _streams));
            RegisterEngineComponent(_commandConsole);
            _controlManager = ToDispose<ControlManager>(new ControlManager());
            RegisterEngineComponent(_controlManager);
            OnUpdate += Update;
            OnRender += Render;
            OnLoadContent += LoadContent;
            OnUnloadContent += UnloadContent;
        }
 private void _endRun()
 {
     EndRun();
     _dMouse.Unacquire();
     _dKeyboard.Unacquire();
     _singleton = null;
 }