Beispiel #1
0
        /// <summary>
        /// Renders the caret.
        /// </summary>
        protected virtual void RenderCaret()
        {
            if (drawCaret && textFont != null)
            {
                UI2DRenderer.DrawLine(paintBounds.X + caretPosition.X, caretPosition.Y + textHeight,
                                      paintBounds.X + caretPosition.X, caretPosition.Y, Color.Black, 1);
            }

            if (caretTimer >= caretBlinkInterval)
            {
                drawCaret  = !drawCaret;
                caretTimer = 0;
            }
        }
Beispiel #2
0
        protected override void PaintComponent()
        {
            base.PaintComponent();

            if (lines == null)
            {
                return;
            }

            Color c = animationBarColor;

            c.A = 255;
            for (int i = 0; i < linesToDraw.Count; i++)
            {
                if (alpha < 255 && linesToDraw.Count > 4)
                {
                    c.A = (byte)((i + 1) / 6.0f * alpha);
                }
                UI2DRenderer.DrawLine(linesToDraw[i].Start, linesToDraw[i].End, c, lineWidth);
            }

            if (textFont != null && label.Length > 0)
            {
                UI2DRenderer.WriteText(textPos, label, textColor, textFont);
            }

            animationCounter++;

            if (animationCounter > updateInterval)
            {
                linesToDraw.RemoveAt(0);
                linesToDraw.Add(lines[curTail]);
                curTail++;
                if (curTail >= lines.Length)
                {
                    curTail = 0;
                }

                animationCounter = 0;
            }
        }
Beispiel #3
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;
                    }
                }
            }
        }