Ejemplo n.º 1
0
        private static void Update()
        {
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Escape && ke.Down))
            {
                window.Close();
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Up && ke.Down))
            {
                fontSize += 0.5f;
                UpdateFont();
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Down && ke.Down))
            {
                fontSize -= 0.5f;
                UpdateFont();
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Left && ke.Down))
            {
                letterSpacing -= 0.01f;
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Right && ke.Down))
            {
                letterSpacing += 0.01f;
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Enter && ke.Down))
            {
                currentFontIndex = (currentFontIndex + 1) % fonts.Length;
                UpdateFont();
            }
            if (inputSnapshot.KeyEvents.Any(ke => ke.Key == Key.Space && ke.Down))
            {
                currentColorIndex = (currentColorIndex + 1) % colors.Length;
            }

            infoTextRenderer.Update();
            demoTextRenderer.Update();

            var         xAccumulated = 0f;
            const float xInset       = 10;
            const float lineSpacing  = 5;

            infoTextRenderer.DrawText("Debug Controls:", new Vector2(xInset, xAccumulated += xInset), colors[0]);
            infoTextRenderer.DrawText("Up/Down = Increase/Decrease Font Size", new Vector2(xInset, xAccumulated         += lineSpacing + infoFont.FontSizeInPixels), colors[0]);
            infoTextRenderer.DrawText("Right/Left = Increase/Decrease Letter Spacing", new Vector2(xInset, xAccumulated += lineSpacing + infoFont.FontSizeInPixels), colors[0]);
            infoTextRenderer.DrawText("Enter = Change Font", new Vector2(xInset, xAccumulated            += lineSpacing + infoFont.FontSizeInPixels), colors[0]);
            infoTextRenderer.DrawText("Space = Change Colorm", new Vector2(xInset, xAccumulated          += lineSpacing + infoFont.FontSizeInPixels), colors[0]);
            infoTextRenderer.DrawText($"Current Font: {demoFont.Name}", new Vector2(xInset, xAccumulated += lineSpacing + infoFont.FontSizeInPixels), colors[0]);

            demoTextRenderer.DrawText("Sixty zippers were quickly picked from the woven jute bag.", new Vector2(xInset, xAccumulated += (lineSpacing * 5) + infoFont.FontSizeInPixels), colors[currentColorIndex], letterSpacing);
            demoTextRenderer.DrawText("The quick brown fox jumps over the lazy dog", new Vector2(xInset, xAccumulated += lineSpacing + demoFont.FontSizeInPixels), colors[(currentColorIndex + 1) % colors.Length], letterSpacing);
            demoTextRenderer.DrawText("How vexingly quick daft zebras jump!", new Vector2(xInset, xAccumulated        += lineSpacing + demoFont.FontSizeInPixels), colors[(currentColorIndex + 2) % colors.Length], letterSpacing);
        }