Ejemplo n.º 1
0
        //
        public ChartAxis(double MainTicks, double MinorTicks, double pMinimum, double pMaximum)
            : base(new List <Type>() { typeof(ChartPadding), typeof(ChartAxis), typeof(ChartData) })
        {
            MyRange = new CappedRange(pMinimum, pMaximum);

            //This filters when what children are added to this instance of ChartAxis
            RegistrationFilter = (
                (object o) =>
            {
                if (o.GetType() == typeof(ChartData))
                {
                    var d = o as ChartData;
                    var axis_label = (Orientation == AxisOrientation.Horizontal) ? d.HorizontalLabel : d.VerticalLabel;
                    return(Label == axis_label);
                }
                return(false);
            });

            //Setup divisions
            this.MainTicks  = MainTicks;
            this.MinorTicks = MinorTicks;

            MaskPaint       = new SKPaint();
            MaskPaint.Color = Globals.BackgroundColor.ToSKColor();

            //Calculate the width of a space charater
            SpaceWidth = MajorPaint.MeasureText(" ");

            //Must be set last as it depends on above
            AxisLocation      = 0.5;
            CircleRadius      = SpaceWidth * 2;
            MajorTickLineSize = 5;

            //
            AxisDrawEvents = new List <ChartAxisDrawEvent>();
            AxisDataEvents = new List <ChartAxisEvent>();
            AxisDataColors = new List <SKColor>();
            AxisDataRanges = new List <Range>();

            //
            Rerange = true;
        }
Ejemplo n.º 2
0
 public override void ParentSizeAdjusted()
 {
     SpaceWidth   = MajorPaint.MeasureText(" ");
     TotalPadding = 0;
     CalculateScales();
 }
Ejemplo n.º 3
0
        void DrawLabel(ref SKCanvas c, float length)
        {
            var hei = MajorTextSize;

            if (hei > AxisLabelPadding)
            {
                AxisLabelPadding = hei + SpaceWidth;
            }

            var     txt = Convert.ToString(Label);
            var     wid = MajorPaint.MeasureText(txt) + SpaceWidth;
            var     pth = new SKPath();
            SKPoint pt1, pt2;

            float xmakoffset = 0, ymakoffset = 0, xfilloffset = 0, yfilloffset = 0;
            float xfillsoffset = 0, yfillsoffset = 0;
            var   offset = 0;

            length /= 2;
            switch (Orientation)
            {
            case AxisOrientation.Vertical:
            {
                offset = (int)LabelPadding + (int)SpaceWidth;
                var x  = GetAxisLabelPosition() - offset;
                var ys = (float)(AxisStart + 2 * SpaceWidth);
                pt2          = new SKPoint(x, ys);
                pt1          = new SKPoint(x, ys + wid);
                xmakoffset   = (CircleRadius + SpaceWidth * 2.0f);
                xfilloffset  = -hei;
                yfilloffset  = -SpaceWidth;
                xfillsoffset = SpaceWidth;
                yfillsoffset = SpaceWidth;
            }
            break;

            case AxisOrientation.Horizontal:
            {
                offset = (int)TotalPadding - (int)SpaceWidth;
                var xs = (float)AxisEnd - SpaceWidth * 2;
                var y  = GetAxisLabelPosition() + offset;
                pt1          = new SKPoint(xs - wid, y);
                pt2          = new SKPoint(xs, y);
                ymakoffset   = -(CircleRadius + hei + SpaceWidth);
                yfilloffset  = -hei;
                xfilloffset  = SpaceWidth;
                yfillsoffset = SpaceWidth;
                xfillsoffset = -SpaceWidth;
            }
            break;

            default:
                return;
            }

            var pts = new SKPoint[] {
                pt1,
                pt2
            };

            pth.AddPoly(pts, false);
            var rect = new SKRect(
                pt1.X + xfillsoffset,
                pt1.Y + yfillsoffset,
                pt2.X + xfilloffset,
                pt2.Y + yfilloffset);

            c.DrawRoundRect(rect, SpaceWidth, SpaceWidth, MaskPaint);
            c.DrawTextOnPath(txt, pth, 0, 0, MajorPaint);

            //
            pth.Offset(xmakoffset, ymakoffset);
            pts = pth.Points;
        }
Ejemplo n.º 4
0
 public SKSize MeasureText(string Input)
 {
     return(new SKSize(MajorPaint.MeasureText(Input), MajorTextSize));
 }