Exemplo n.º 1
0
    void PrintCode(Alt.Sketch.Graphics graphics, string code, ref double yOffset)
    {
        GraphicsState state = graphics.Save();

        yOffset += 20;
        graphics.TranslateTransform(50f, yOffset);

        codeText.Print(code, ClientWidth - 50, QFontAlignment.Left);

        yOffset += codeText.Measure(code, ClientWidth - 50, QFontAlignment.Left).Height;

        graphics.Restore(state);
    }
Exemplo n.º 2
0
    void PrintComment(Alt.Sketch.Graphics graphics, QFont font, string comment, QFontAlignment alignment, ref double yOffset)
    {
        GraphicsState state = graphics.Save();

        yOffset += 20;
        graphics.TranslateTransform(30, yOffset);

        font.Print(comment, ClientWidth - 60, alignment);

        yOffset += font.Measure(comment, ClientWidth - 60, alignment).Height;

        graphics.Restore(state);
    }
Exemplo n.º 3
0
    void PrintCommentWithLine(Alt.Sketch.Graphics graphics, QFont font, string comment, QFontAlignment alignment, double xOffset, ref double yOffset)
    {
        GraphicsState state = graphics.Save();

        yOffset += 20;
        graphics.TranslateTransform((int)xOffset, yOffset);

        font.Print(comment, alignment);

        Size bounds = font.Measure(comment, ClientWidth - 60, alignment);

        graphics.DrawLine(m_LinesPen, 0, 0, 0, bounds.Height + 20);

        yOffset += bounds.Height;

        graphics.Restore(state);
    }
Exemplo n.º 4
0
    protected void QuickFont_onPaint(Alt.GUI.PaintEventArgs e)
    {
        Alt.Sketch.Graphics graphics = e.Graphics;
        GraphicsState       state;

        switch (currentDemoPage)
        {
        case 1:
        {
            double yOffset = 0;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(ClientWidth * 0.5f, yOffset + 10);
            heading1.Print("AltGUI QuickFont", QFontAlignment.Centre);
            yOffset += heading1.Measure("QuickFont").Height;
            graphics.Restore(state);


            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Introduction", QFontAlignment.Left);
            yOffset += heading2.Measure("Introduction").Height;
            graphics.Restore(state);


            state = graphics.Save();
            graphics.TranslateTransform(30f, yOffset + 20);
            mainText.Print(introduction, ClientWidth - 60, QFontAlignment.Justify);
            graphics.Restore(state);

            QFont.End();
        }
        break;

        case 2:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Easy as ABC!", QFontAlignment.Left);
            yOffset += heading2.Measure("Easy as ABC!").Height;
            graphics.Restore(state);


            PrintComment(graphics, usingQuickFontIsSuperEasy, ref yOffset);
            PrintCode(graphics, loadingAFont1, ref yOffset);

            PrintComment(graphics, andPrintWithIt, ref yOffset);
            PrintCode(graphics, printWithFont1, ref yOffset);

            PrintComment(graphics, itIsAlsoEasyToMeasure, ref yOffset);
            PrintCode(graphics, measureText1, ref yOffset);

            PrintComment(graphics, oneOfTheFirstGotchas, ref yOffset);
            PrintCode(graphics, loadingAFont2, ref yOffset);

            QFont.End();
        }
        break;

        case 3:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Alignment", QFontAlignment.Left);
            yOffset += heading2.Measure("Easy as ABC!").Height;
            graphics.Restore(state);

            PrintCommentWithLine(graphics, whenPrintingText, QFontAlignment.Left, ClientWidth * 0.5f, ref yOffset);
            PrintCode(graphics, printWithFont2, ref yOffset);


            PrintCommentWithLine(graphics, righAlignedText, QFontAlignment.Right, ClientWidth * 0.5f, ref yOffset);
            yOffset += 10f;

            PrintCommentWithLine(graphics, centredTextAsYou, QFontAlignment.Centre, ClientWidth * 0.5f, ref yOffset);

            QFont.End();
        }
        break;

        case 4:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Bounds and Justify", QFontAlignment.Left);
            yOffset += heading2.Measure("Easy as ABC!").Height;
            graphics.Restore(state);

            state    = graphics.Save();
            yOffset += 20;
            graphics.TranslateTransform((int)(ClientWidth * 0.5), yOffset);
            controlsText.Options.Colour = Alt.Sketch.Color.Yellow;
            controlsText.Print("Press [Up], [Down] or [Enter]!", QFontAlignment.Centre);
            yOffset += controlsText.Measure("[]").Height;
            graphics.Restore(state);

            double boundShrink = (int)(350 * (1 - Math.Cos(boundsAnimationCnt * Math.PI * 2)));

            yOffset += 15;
            PrintWithBounds(graphics, mainText, ofCourseItsNot, new Alt.Sketch.Rect(30f + boundShrink * 0.5f, yOffset, ClientWidth - 60 - boundShrink, 350f), cycleAlignment, ref yOffset);

            string printWithBounds = "myFont.Print(text, 400f, QFontAlignment." + cycleAlignment + ");";
            yOffset += 15f;
            PrintCode(graphics, printWithBounds, ref yOffset);

            QFont.End();
        }
        break;

        case 5:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Your own Texture Fonts", QFontAlignment.Left);
            yOffset += heading2.Measure("T").Height;
            graphics.Restore(state);

            PrintComment(graphics, anotherCoolFeature, ref yOffset);
            PrintCode(graphics, textureFontCode1, ref yOffset);
            PrintComment(graphics, thisWillHaveCreated, ref yOffset);

            QFont.End();
        }
        break;

        case 6:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Your own Texture Fonts", QFontAlignment.Left);
            yOffset += heading2.Measure("T").Height;
            graphics.Restore(state);

            PrintComment(graphics, ifYouDoIntend, ref yOffset);
            PrintCode(graphics, textureFontCode2, ref yOffset);
            PrintComment(graphics, actuallyTexturing, ref yOffset);
            PrintCode(graphics, textureFontCode3, ref yOffset);

            QFont.End();
        }
        break;

        case 7:
        {
            double yOffset = 20;

            QFont.Begin();

            heading2.Options.DropShadowOffset = new Alt.Sketch.Vector2(0.1f + 0.2f * (float)Math.Sin(cnt), 0.1f + 0.2f * (float)Math.Cos(cnt));

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Drop Shadows", QFontAlignment.Left);
            yOffset += heading2.Measure("T").Height;
            graphics.Restore(state);

            heading2.Options.DropShadowOffset = new Alt.Sketch.Vector2(0.16f, 0.16f);             //back to default

            mainText.Options.DropShadowActive  = true;
            mainText.Options.DropShadowOpacity = 0.7f;
            mainText.Options.DropShadowOffset  = new Alt.Sketch.Vector2(0.1f + 0.2f * (float)Math.Sin(cnt), 0.1f + 0.2f * (float)Math.Cos(cnt));

            PrintComment(graphics, asIhaveleant, ref yOffset);
            PrintCode(graphics, dropShadowCode1, ref yOffset);
            PrintComment(graphics, thisWorksFine, ref yOffset);
            PrintCode(graphics, dropShadowCode2, ref yOffset);
            PrintComment(graphics, onceAFont, ref yOffset);

            mainText.Options.DropShadowActive = false;

            QFont.End();
        }
        break;

        case 8:
        {
            double yOffset = 20;

            QFont.Begin();

            monoSpaced.Options.CharacterSpacing = 0.05f;

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("Monospaced Fonts", QFontAlignment.Left);
            yOffset += heading2.Measure("T").Height;
            graphics.Restore(state);


            PrintComment(graphics, monoSpaced, hereIsSomeMono, QFontAlignment.Left, ref yOffset);
            PrintCode(graphics, monoCode1, ref yOffset);
            PrintComment(graphics, monoSpaced, theDefaultMono, QFontAlignment.Left, ref yOffset);

            PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Left, ClientWidth * 0.5f, ref yOffset);
            yOffset += 2f;
            PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Right, ClientWidth * 0.5f, ref yOffset);
            yOffset += 2f;
            PrintCommentWithLine(graphics, monoSpaced, mono, QFontAlignment.Centre, ClientWidth * 0.5f, ref yOffset);
            yOffset += 2f;

            monoSpaced.Options.CharacterSpacing = 0.5f;
            PrintComment(graphics, monoSpaced, "As usual, you can adjust character spacing with myFont.Options.CharacterSpacing.", QFontAlignment.Left, ref yOffset);

            QFont.End();
        }
        break;

        case 9:
        {
            double yOffset = 20;

            QFont.Begin();

            state = graphics.Save();
            graphics.TranslateTransform(20f, yOffset);
            heading2.Print("In Conclusion", QFontAlignment.Left);
            yOffset += heading2.Measure("T").Height;
            graphics.Restore(state);

            PrintComment(graphics, thereAreActually, ref yOffset);

            QFont.End();
        }
        break;
        }


        QFont.Begin();

        Alt.Sketch.Color pressColor = new ColorR(0.8, 0.2, 0.2);        // new ColorR(0.8, 0.1, 0.1);

        if (currentDemoPage != lastPage)
        {
            state = graphics.Save();
            graphics.TranslateTransform(ClientWidth - 15 - 16 * (float)(1 + Math.Sin(cnt * 4)), ClientHeight - controlsText.Measure("P").Height - 17);
            controlsText.Options.Colour = pressColor;
            controlsText.Print("Press [Right] ->", QFontAlignment.Right);
            graphics.Restore(state);
        }

        if (currentDemoPage != 1)
        {
            state = graphics.Save();
            graphics.TranslateTransform(15 + 16 * (float)(1 + Math.Sin(cnt * 4)), ClientHeight - controlsText.Measure("P").Height - 17);
            controlsText.Options.Colour = pressColor;
            controlsText.Print("<- Press [Left]", QFontAlignment.Left);
            graphics.Restore(state);
        }

        QFont.End();
    }