Ejemplo n.º 1
0
        public void Render(SKCanvas canvas, SKRect layoutSlot)
        {
            var top      = layoutSlot.Top + maxLabelSize.Height / 2;
            var left     = layoutSlot.Left;
            var height   = layoutSlot.Height - maxLabelSize.Height;
            var tickLeft = labelsOffset + left + maxLabelSize.Width;

            using (var paint = new SKPaint())
            {
                paint.IsAntialias  = true;
                paint.IsStroke     = false;
                paint.TextEncoding = SKTextEncoding.Utf32;
                paint.TextSize     = fontSize;
                paint.Color        = ColorExtensions.ToSKColor(this.Owner.AxisColor);

                for (var i = this.Owner.Minimum; i <= this.Owner.Maximum; i += this.Owner.Step)
                {
                    var position = GaugeRenderHelper.GetRelativePosition(i, this.Owner.Minimum, this.Owner.Maximum, top + height, top, true);
                    DrawLabel(i.ToString(), left, position, paint, canvas);

                    var tickTop  = position;
                    var tickRect = new SKRect(tickLeft, tickTop, tickLeft + tickLength, tickTop + tickThickness);
                    DrawRect(tickRect, paint, canvas);
                }

                var axisLeft = tickOffset + tickLeft + tickLength;

                DrawRect(new SKRect(axisLeft, top, axisLeft + axisWidth, top + height), paint, canvas);
            }
        }
Ejemplo n.º 2
0
        public void Render(SKCanvas canvas, SKRect layoutSlot)
        {
            float totalHeight = layoutSlot.Height;

            for (int i = 0; i < this.Owner.Ranges.Length - 1; i++)
            {
                var bottom = GaugeRenderHelper.GetRelativePosition(this.Owner.Ranges[i], this.Owner.Minimum, this.Owner.Maximum, layoutSlot.Bottom, layoutSlot.Top, true);
                var top    = GaugeRenderHelper.GetRelativePosition(this.Owner.Ranges[i + 1], this.Owner.Minimum, this.Owner.Maximum, layoutSlot.Bottom, layoutSlot.Top, true);

                SKRect rect = new SKRect(layoutSlot.Left, top, layoutSlot.Right, bottom);

                Color color = this.Owner.Colors[i];
                DrawRectangle(canvas, rect, color);
            }
        }
        public void Render(SKCanvas canvas, SKRect layoutSlot)
        {
            float position = GaugeRenderHelper.GetRelativePosition(this.Owner.IndicatorValue, this.Owner.Minimum, this.Owner.Maximum, layoutSlot.Bottom, layoutSlot.Top);

            if (position > layoutSlot.Bottom && position > layoutSlot.Top || position < layoutSlot.Bottom && position < layoutSlot.Top)
            {
                return;
            }

            using (var paint = this.CreatePaint())
            {
                using (var path = new SKPath())
                {
                    path.MoveTo(layoutSlot.Left, position);
                    path.LineTo(layoutSlot.Right, position - (layoutSlot.Width / 2));
                    path.LineTo(layoutSlot.Right, position + (layoutSlot.Width / 2));
                    path.Close();

                    canvas.DrawPath(path, paint);
                }
            }
        }