public Icon(IEmission emission, SKPoint cakeCenter, float radius, float offset, SKPoint center)
 {
     Radius     = radius;
     Offset     = offset;
     Center     = center;
     SVG        = CakeUtil.GetSVGPath(emission);
     Color      = CakeUtil.GetColor(emission);
     DropShadow = SKImageFilter.CreateDropShadow(-(Center.X - cakeCenter.X) / 12, -(Center.Y - cakeCenter.Y) / 12, 9, 9, SKColors.Black.WithAlpha(50), SKDropShadowImageFilterShadowMode.DrawShadowAndForeground);
     ScaleSVGPath();
     CenterSVGPath();
 }
Exemple #2
0
        public PieceOfCake(IEmission emission, SKPoint cakeCenter, float startAngle, float sweepAngle, float cakeRadius, float iconSpacing, float iconRadius)
        {
            Emission   = emission;
            StartAngle = startAngle;
            EndAngle   = startAngle + sweepAngle;
            ArcAngle   = EndAngle - StartAngle;
            Color      = CakeUtil.GetColor(emission);
            CakeCenter = cakeCenter;
            // Calculate coordinates for icons
            float   offsetAngle = StartAngle + (sweepAngle / 2);
            float   offsetX     = (cakeRadius + iconSpacing) * (float)Math.Cos(offsetAngle * Math.PI * 2 / 360);
            float   offsetY     = (cakeRadius + iconSpacing) * (float)Math.Sin(offsetAngle * Math.PI * 2 / 360);
            SKPoint IconCenter  = new SKPoint(cakeCenter.X + offsetX, cakeCenter.Y + offsetY);

            Icon = new Icon(emission, cakeCenter, iconRadius, iconSpacing, IconCenter);
        }
Exemple #3
0
        public void DrawPopover()
        {
            // Define paint

            if (CakeOrientation.CurrentlySelected != null)
            {
                SKPaint fillPaint = new SKPaint
                {
                    Color       = SKColors.Transparent,
                    IsAntialias = true
                };


                PopOver     popOver      = CakeOrientation.PopOver;
                PieceOfCake Slice        = CakeOrientation.CurrentlySelected;
                SKPath      centerCircle = new SKPath();

                fillPaint.Color       = CakeOrientation.CurrentlySelected.Color;
                fillPaint.ImageFilter = SKImageFilter.CreateDropShadow(1, 1, 20 * popOver.Factor, 20 * popOver.Factor, SKColors.Black.WithAlpha(80), SKDropShadowImageFilterShadowMode.DrawShadowAndForeground);

                float   radius          = popOver.Radius * popOver.Factor;
                float   amountFontSize  = popOver.AmountFontSize * popOver.Factor;
                float   unitFontSize    = popOver.UnitFontSize * popOver.Factor;
                float   titleFontSize   = popOver.TitleFontSize * popOver.Factor;
                SKColor testColor       = SKColors.White;
                SKColor titleFontColor  = testColor;
                SKColor amountFontColor = testColor;
                SKColor unitFontColor   = testColor;

                //connectRect.AddRect(rect);
                centerCircle.AddCircle(CakeOrientation.Center.X, CakeOrientation.Center.Y, radius);

                // Draw path
                canvas.DrawPath(centerCircle, fillPaint);

                // Define paint

                SKPaint titlePaint = CakeOrientation.NormalFont;
                titlePaint.Color    = titleFontColor;
                titlePaint.TextSize = titleFontSize;

                SKPaint amountPaint = CakeOrientation.BoldFont;
                amountPaint.Color    = amountFontColor;
                amountPaint.TextSize = amountFontSize;

                SKPaint unitPaint = titlePaint;


                SKPoint amountTextCenter = CakeOrientation.Center;
                SKPoint titleTextCenter  = CakeOrientation.Center;
                SKPoint unitTextCenter   = CakeOrientation.Center;
                float   amountTextHeight = amountFontSize / 0.75f;
                float   titleTextHeight  = titleFontSize / 0.75f;
                amountTextCenter.Y += amountFontSize / 2 * 0.75f;
                titleTextCenter.Y  -= (amountTextHeight / 2 - titleTextHeight / 2 + 5);
                unitTextCenter.Y   += (amountTextHeight / 2 + 5);


                // Draw Text

                canvas.DrawText(((int)Slice.Emission.KgCO2).ToString(), amountTextCenter, amountPaint);
                canvas.DrawText(CakeUtil.GetTitle(Slice.Emission), titleTextCenter, titlePaint);
                canvas.DrawText("kg CO2", unitTextCenter, unitPaint);
            }
        }