ComponentFactory.Krypton.Toolkit.RenderStandard.DrawTrackTicksGlyph C# (CSharp) Method

DrawTrackTicksGlyph() public method

Draw the track bar ticks glyph.
public DrawTrackTicksGlyph ( RenderContext context, PaletteState state, IPaletteElementColor elementPalette, Rectangle drawRect, Orientation orientation, bool topRight, Size positionSize, int minimum, int maximum, int frequency ) : void
context RenderContext Render context.
state PaletteState Element state.
elementPalette IPaletteElementColor Source of palette colors.
drawRect System.Drawing.Rectangle Drawing rectangle that should contain ticks.
orientation Orientation Orientation of the drawing area.
topRight bool Drawing on the topRight or the bottomLeft.
positionSize System.Drawing.Size Size of the position indicator.
minimum int First value.
maximum int Last value.
frequency int How often ticks are drawn.
return void
        public override void DrawTrackTicksGlyph(RenderContext context,
                                                 PaletteState state,
                                                 IPaletteElementColor elementPalette,
                                                 Rectangle drawRect,
                                                 Orientation orientation,
                                                 bool topRight,
                                                 Size positionSize,
                                                 int minimum,
                                                 int maximum,
                                                 int frequency)
        {
            // Never want a frequency less than 1
            if (frequency <= 0)
                frequency = 1;

            float range = maximum - minimum;
            using (Pen tickPen = new Pen(elementPalette.GetElementColor1(state)))
            {
                if (orientation == Orientation.Horizontal)
                {
                    // Reduce area by half the position indicator on each side
                    int halfPosition = positionSize.Width / 2;
                    drawRect.X += halfPosition;
                    drawRect.Width -= positionSize.Width;

                    // Draw a marker for each value between min and max
                    float factor = (range == 0) ? float.MinValue : (float)drawRect.Width / range;
                    float top = drawRect.Y + 1;
                    float bottom = drawRect.Bottom - 2;
                    for (int i = minimum, y = 0; i <= maximum; i += frequency, y += frequency)
                    {
                        float offset = drawRect.X + (factor * y);
                        if (!topRight)
                        {
                            top = drawRect.Y + 2;
                            bottom = drawRect.Bottom - 2;
                            if ((i == minimum) || (i == maximum))
                                top -= 1;
                        }
                        else
                        {
                            top = drawRect.Y + 1;
                            bottom = drawRect.Bottom - 3;
                            if ((i == minimum) || (i == maximum))
                                bottom += 1;
                        }

                        context.Graphics.DrawLine(tickPen, offset, top, offset, bottom);
                    }
                }
                else
                {
                    // Reduce area by half the position indicator on each side
                    int halfPosition = positionSize.Height / 2;
                    drawRect.Y += halfPosition;
                    drawRect.Height -= positionSize.Height;

                    // Draw a marker for each value between min and max
                    float factor = (range == 0) ? float.MinValue : (float)drawRect.Height / range;
                    float left = drawRect.X + 1;
                    float right = drawRect.Right - 2;
                    for (int i = minimum, y = 0; i <= maximum; i += frequency, y += frequency)
                    {
                        float offset = drawRect.Y + (factor * y);
                        if (topRight)
                        {
                            left = drawRect.X + 2;
                            right = drawRect.Right - 2;
                            if ((i == minimum) || (i == maximum))
                                left -= 1;
                        }
                        else
                        {
                            left = drawRect.X + 1;
                            right = drawRect.Right - 3;
                            if ((i == minimum) || (i == maximum))
                                right += 1;
                        }

                        context.Graphics.DrawLine(tickPen, left, offset, right, offset);
                    }
                }
            }
        }
RenderStandard