Beispiel #1
0
        protected override void PaintComponent()
        {
            CheckMouseHeldDown();

            textField.RenderWidget();

            // Render the up and down buttons
            Color c = (!enabled || upPressed) ? disabledColor : buttonColor;

            UI2DRenderer.FillRectangle(upArrowBound, null, c);
            c = (!enabled || downPressed) ? disabledColor : buttonColor;
            UI2DRenderer.FillRectangle(downArrowBound, null, c);

            // Render the border of the up and down button
            UI2DRenderer.DrawRectangle(upArrowBound, borderColor, 1);
            UI2DRenderer.DrawRectangle(downArrowBound, borderColor, 1);

            // Render the up and down arrows
            // First render the up arrow
            if (upArrowPoints.Count > 0)
            {
                UI2DRenderer.FillPolygon(upArrowPoints, arrowColor, Point.Zero, UI2DRenderer.PolygonShape.Convex);
                UI2DRenderer.FillPolygon(downArrowPoints, arrowColor, Point.Zero, UI2DRenderer.PolygonShape.Convex);
            }
        }
Beispiel #2
0
        protected override void PaintComponent()
        {
            // Render the track first since it appears on the background of everything
            if (paintTrack)
            {
                UI2DRenderer.DrawRectangle(trackBound, trackBorderColor, 1);

                UI2DRenderer.FillRectangle(trackBound, null, trackColor);
            }

            // Render the knob
            if (paintTicks)
            { // If ticks are painted, then the lower part of the knob will change to a pointing shape
                UI2DRenderer.FillPolygon(knobPoints, knobColor, knobBound.Location, UI2DRenderer.PolygonShape.Convex);

                Point p1 = new Point();
                Point p2 = new Point();
                for (int i = 0, j = 0; i < knobPoints.Count; i++)
                {
                    if (i == knobPoints.Count - 1)
                    {
                        j = 0;
                    }
                    else
                    {
                        j = i + 1;
                    }

                    p1.X = knobPoints[i].X + knobBound.Location.X;
                    p1.Y = knobPoints[i].Y + knobBound.Location.Y;

                    p2.X = knobPoints[j].X + knobBound.Location.X;
                    p2.Y = knobPoints[j].Y + knobBound.Location.Y;
                    UI2DRenderer.DrawLine(p1, p2, knobBorderColor, 1);
                }
            }
            else
            { // Otherwise, it's a simple rectangle
                Color c = (enabled) ? knobColor : disabledColor;
                // Render inside first
                UI2DRenderer.FillRectangle(knobBound, null, c);

                UI2DRenderer.DrawRectangle(knobBound, knobBorderColor, 1);
            }

            // Render the tickes
            if (paintTicks)
            {
                float nextLoc = 0;
                if (orientation == GoblinEnums.Orientation.Horizontal)
                {
                    nextLoc = tickBound.X + minorTickDelta;
                    // Render the minor ticks if minorTickSpacing is greater than 0
                    for (int i = 0; i < minorTickCount; i++)
                    {
                        UI2DRenderer.DrawLine((int)nextLoc, tickBound.Y, (int)nextLoc, tickBound.Y + 4,
                                              knobBorderColor, 1);
                        nextLoc += minorTickDelta;
                    }

                    nextLoc = tickBound.X;
                    // Render the major ticks if majorTickSpacing is greater than 0
                    for (int i = 0; i <= majorTickCount; i++)
                    {
                        UI2DRenderer.DrawLine((int)nextLoc, tickBound.Y, (int)nextLoc, tickBound.Y + 8,
                                              knobBorderColor, 1);
                        nextLoc += majorTickDelta;
                    }
                }
                else
                {
                    nextLoc = tickBound.Y + minorTickDelta;
                    // Render the minor ticks if minorTickSpacing is greater than 0
                    for (int i = 0; i < minorTickCount; i++)
                    {
                        UI2DRenderer.DrawLine(tickBound.X, (int)nextLoc, tickBound.X + 4, (int)nextLoc,
                                              knobBorderColor, 1);
                        nextLoc += minorTickDelta;
                    }

                    nextLoc = tickBound.Y;
                    // Render the major ticks if majorTickSpacing is greater than 0
                    for (int i = 0; i <= majorTickCount; i++)
                    {
                        UI2DRenderer.DrawLine(tickBound.X, (int)nextLoc, tickBound.X + 8, (int)nextLoc,
                                              knobBorderColor, 1);
                        nextLoc += majorTickDelta;
                    }
                }
            }

            // Render the labels
            if (paintLabels && textFont != null)
            {
                float   nextLoc = 0;
                Vector2 textPos = new Vector2();
                if (orientation == GoblinEnums.Orientation.Horizontal)
                {
                    nextLoc   = tickBound.X;
                    textPos.Y = labelBound.Y + 1;
                    // Render labels below major ticks only
                    for (int i = 0; i < tickLabels.Count; i++)
                    {
                        textPos.X = (int)nextLoc - labelShifts[i];
                        UI2DRenderer.WriteText(textPos, tickLabels[i], knobBorderColor, textFont);
                        nextLoc += majorTickDelta;
                    }
                }
                else
                {
                    nextLoc   = tickBound.Y;
                    textPos.X = labelBound.X + 1;
                    // Render labels next to major ticks only
                    for (int i = 0; i < tickLabels.Count; i++)
                    {
                        textPos.Y = (int)nextLoc - 5;
                        UI2DRenderer.WriteText(textPos, tickLabels[tickLabels.Count - i - 1], knobBorderColor, textFont);
                        nextLoc += majorTickDelta;
                    }
                }
            }
        }