Пример #1
0
        public PerformanceMeasureDrawingLayer(float verticalPadding, ViewInformation view)
        {
            _view            = view;
            _verticalPadding = verticalPadding;

            _lastTimeSpans = new List <TimeSpan>();
            _lastRender    = DateTime.UtcNow;

            // Define drawing resources
            _textFormatCentered = new TextFormatResource("Arial", 18f);
            _textFormatCentered.TextAlignment    = TextAlignment.Center;
            _textFormatLeftAligned               = new TextFormatResource("Arial", 18f);
            _textFormatLeftAligned.TextAlignment = TextAlignment.Leading;

            _backBrush   = new SolidBrushResource(Color4.LightGray);
            _foreBrush   = new SolidBrushResource(Color4.Black);
            _borderBrush = new SolidBrushResource(Color4.DarkGray);

            _enabled     = true;
            _currentType = PerformanceDrawingLayerType.FramesPerSecond;
            _keysDown    = new List <WinVirtualKey>(12);
        }
Пример #2
0
        /// <inheritdoc />
        protected override void Update(UpdateState updateState)
        {
            base.Update(updateState);

            updateState.HandleKeyboardInput(_view, (keyboardState) =>
            {
                // Remember all keys which are down currently
                _keysDown.Clear();
                foreach (var actKeyDown in keyboardState.KeysDown)
                {
                    _keysDown.Add(actKeyDown);
                }

                // Checks for number key (switches current mode for rendering)
                foreach (var actHitKey in keyboardState.KeysHit)
                {
                    switch (actHitKey)
                    {
                    case WinVirtualKey.D1:
                        _enabled     = true;
                        _currentType = PerformanceDrawingLayerType.FramesPerSecond;
                        break;

                    case WinVirtualKey.D2:
                        _enabled     = true;
                        _currentType = PerformanceDrawingLayerType.PressedKeys;
                        break;

                    case WinVirtualKey.D0:
                        _enabled     = false;
                        _currentType = PerformanceDrawingLayerType.None;
                        break;
                    }
                }
            });
        }