Ejemplo n.º 1
0
        public void DrawText()
        {
            PopOver popOver = CakeOrientation.PopOver;

            float   amountFontSize  = popOver.AmountFontSize;
            float   unitFontSize    = popOver.UnitFontSize;
            float   titleFontSize   = popOver.TitleFontSize;
            SKColor testColor       = SKColors.DimGray;
            SKColor titleFontColor  = testColor;
            SKColor amountFontColor = testColor;
            SKColor unitFontColor   = testColor;


            // Define paint

            SKPaint titlePaint = CakeOrientation.NormalFont;

            titlePaint.Color    = titleFontColor;
            titlePaint.TextSize = titleFontSize;

            SKPaint amountPaint = CakeOrientation.BoldFont;

            amountPaint.Color    = amountFontColor;
            amountPaint.TextSize = amountFontSize;

            SKPaint unitPaint = CakeOrientation.NormalFont;

            unitPaint.Color    = unitFontColor;
            unitPaint.TextSize = unitFontSize;

            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)CakeOrientation.TotalValues).ToString(), amountTextCenter, amountPaint);
            canvas.DrawText("Totalt", titleTextCenter, titlePaint);
            canvas.DrawText("kg CO2", unitTextCenter, unitPaint);
        }
Ejemplo n.º 2
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);
            }
        }