Ejemplo n.º 1
0
        /// <summary>
        /// Sets the physical size onto which to draw the value display.
        /// </summary>
        /// <param name="width">Width in pixels.</param>
        /// <param name="height">Height in pixels.</param>
        public void SetSize(int width, int height)
        {
            this.width  = width;
            this.height = height;

            canvas.SetWidth(width);
            canvas.SetHeight(height);

            tickHandler.SetRange(rangeStart, rangeEnd, height);
        }
        /// <inheritdoc/>
        public override void Rebuild()
        {
            canvas.Clear();
            tickHandler.SetRange(rangeOffset, rangeOffset + GetRange(true), drawableWidth + PADDING);

            float range = GetRange();

            int numTickLevels = tickHandler.NumLevels;

            for (int i = numTickLevels - 1; i >= 0; i--)
            {
                bool drawText = i == 0;

                float[] ticks    = tickHandler.GetTicks(i);
                float   strength = tickHandler.GetLevelStrength(i);

                if (ticks.Length > 0)
                {
                    float valuePerTick     = range / ticks.Length;
                    bool  displayAsMinutes = TimeSpan.FromSeconds(valuePerTick).Minutes > 0;
                    for (int j = 0; j < ticks.Length; j++)
                    {
                        DrawTick(ticks[j], strength, drawText, displayAsMinutes);
                    }
                }
            }

            DrawFrameMarker();
        }