/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); //spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, camera.GetTransformMatrix()); gameWorld.Draw(spriteBatch, camera); //spriteBatch.End(); spriteBatch.Begin(); uiRoot.Draw(spriteBatch); spriteBatch.End(); //spriteBatch.Begin(); //spriteBatch.DrawString(font, $"FPS: {frameCounter.GetFps()}", Vector2.Zero, Color.White); //spriteBatch.End(); frameCounter.Reset(); base.Draw(gameTime); }
private async Task CheckAutoDisable() { // Don't do anything if auto-disable isn't enabled if (!_enableAutoDisable) { if (!_autoDisabled) { return; } _autoDisabled = false; DataUtil.SetItem("AutoDisabled", _autoDisabled); return; } var sourceActive = _stream?.SourceActive ?? false; if (sourceActive) { // If our source is active and we're auto-disabled, turn it off. if (_autoDisabled) { Log.Information("Auto-enabling stream."); _autoDisabled = false; DataUtil.SetItem("AutoDisabled", _autoDisabled); ControlService.SetModeEvent -= Mode; _deviceMode = _systemData.PreviousMode; await ControlService.SetMode(_deviceMode); await StartStream(); ControlService.SetModeEvent += Mode; } _watch.Reset(); } else { if (_autoDisabled) { return; } if (!_watch.IsRunning) { _watch.Restart(); } if (_watch.ElapsedMilliseconds >= _autoDisableDelay * 1000f) { _autoDisabled = true; Counter.Reset(); DataUtil.SetItem("AutoDisabled", _autoDisabled); ControlService.SetModeEvent -= Mode; await ControlService.SetMode(DeviceMode.Off, true); ControlService.SetModeEvent += Mode; await SendColors(ColorUtil.EmptyColors(_systemData.LedCount), ColorUtil.EmptyColors(_systemData.SectorCount), 0, true); Log.Information( $"Auto-disabling stream {_watch.ElapsedMilliseconds} vs {_autoDisableDelay * 1000}."); _watch.Reset(); await StopStream(); } } }