/// <summary> /// Runs the demo. /// </summary> public void Run(DemoConfiguration demoConfiguration) { _demoConfiguration = demoConfiguration ?? new DemoConfiguration(); _form = CreateForm(_demoConfiguration); Initialize(_demoConfiguration); bool isFormClosed = false; bool formIsResizing = false; _form.MouseClick += HandleMouseClick; _form.KeyDown += HandleKeyDown; _form.KeyUp += HandleKeyUp; _form.Resize += (o, args) => { if (_form.WindowState != _currentFormWindowState) { HandleResize(o, args); } _currentFormWindowState = _form.WindowState; }; _form.ResizeBegin += (o, args) => { formIsResizing = true; }; _form.ResizeEnd += (o, args) => { formIsResizing = false; HandleResize(o, args); }; _form.Closed += (o, args) => { isFormClosed = true; }; LoadContent(); clock.Start(); BeginRun(); RenderLoop.Run(_form, () => { if (isFormClosed) { return; } OnUpdate(); if (!formIsResizing) { Render(); } }); UnloadContent(); EndRun(); // Dispose explicity Dispose(); }
/// <summary> /// Runs the demo. /// </summary> public void Run(DemoConfiguration demoConfiguration) { Config = demoConfiguration ?? new DemoConfiguration(); _form = CreateForm(Config); // disable resizing and center on screen _form.FormBorderStyle = FormBorderStyle.FixedSingle; _form.MaximizeBox = false; _form.StartPosition = FormStartPosition.CenterScreen; Initialize(Config); var isFormClosed = false; _form.MouseClick += HandleMouseClick; _form.KeyDown += HandleKeyDown; _form.KeyUp += HandleKeyUp; _form.Resize += (o, args) => { _currentFormWindowState = _form.WindowState; }; // ReSharper disable once ImplicitlyCapturedClosure _form.Closed += (o, args) => isFormClosed = true; LoadContent(); _clock.Start(); BeginRun(); RenderLoop.Run(_form, () => { if (isFormClosed) { return; } OnUpdate(); Render(); }); UnloadContent(); EndRun(); // Dispose explicity Dispose(); }