async Task UpdateTogglePosition(bool animated = true)
        {
            _isToggling = true;

            uint duration = 100;
            var  easing   = IsToggled ? Easing.CubicIn : Easing.CubicOut;

            if (animated == false)
            {
                duration = 0;
            }


            var xPosition      = IsToggled ? (RoundedRectangle.WidthRequest - 2 - 2 - CircleDot.Width) : 0;
            var animationTasks = new List <Task>();

            animationTasks.Add(CircleDot.TranslateTo(xPosition, 0, duration, easing));

            var fromColor = RoundedRectangle.BackgroundColor;
            var toColor   = IsToggled ? OnColor : OffColor;

            animationTasks.Add(RoundedRectangle.ColorTo(fromColor, toColor, (color) =>
            {
                RoundedRectangle.BackgroundColor = color;
            }, duration, easing));

            await Task.WhenAll(animationTasks);

            CurrentColor = toColor;

            _isToggling = false;
        }
 public Bitmap GetShapeBitmap()
 {
     if (shapePoints != null && shapePoints.Length != 0)
     {
         if (movePlusVisable)
         {
             Color[] plusColors;
             movePlusVisable = false;
             if (movePlus == null)
             {
                 movePlus = new CircleDotLine(DefaultColor.DefaultColorEx.DefaultMovePlusColor, plusShapeSize);
             }
             else
             {
                 drawShapeDC.EraseLocatShape(movePlus.GetLocatShapePoints(), movePlus.GetPointColors());
             }
             Nullable <Point> point1 = null;
             Nullable <Point> point2 = null;
             if (shapePoints.Length > 1)
             {
                 if (selectPointIndex == 0)
                 {
                     point1 = null;
                     point2 = shapePoints[selectPointIndex + 1];
                 }
                 else if (selectPointIndex == shapePoints.Length - 1)
                 {
                     point1 = shapePoints[selectPointIndex - 1];
                     point2 = null;
                 }
                 else
                 {
                     point1 = shapePoints[selectPointIndex - 1];
                     point2 = shapePoints[selectPointIndex + 1];
                 }
             }
             movePlus.SetPointIn(plusPoint, point1, point2);
             plusColors = drawShapeDC.DrawLocatShape(movePlus.GetLocatShapePoints(), movePlus.ShapeColor);
             movePlus.SetPointColor(plusColors);
             ShowPointInfo();
         }
         if (locatPlusVisable)
         {
             if (locatPlus != null)
             {
                 drawShapeDC.EraseLocatShape(locatPlus.GetLocatShapePoints(), locatPlus.GetPointColors());
             }
             else
             {
                 locatPlus = new CircleDot(DefaultColor.DefaultColorEx.DefaultPlueColor, plusShapeSize);
             }
             locatPlus.SetPointIn(shapePoints[selectPointIndex]);
             Color[] plusColors = drawShapeDC.DrawLocatShape(locatPlus.GetLocatShapePoints(), locatPlus.ShapeColor);
             locatPlus.SetPointColor(plusColors);
             ShowPointInfo();
         }
         if (moveType == MoveType.MoveShape)
         {
             if (plusPoint != Point.Empty)
             {
                 for (int i = 0; i < shapePoints.Length; i++)
                 {
                     shapePoints[i].X += plusPoint.X;
                     shapePoints[i].Y += plusPoint.Y;
                 }
                 plusPoint = Point.Empty;
                 SetShapePoints(shapePoints, DefaultColor.DefaultColorEx.DefaultPlueColor);
                 LoadPointValueRange();
             }
         }
     }
     return(drawShapeDC.ShapeBitmap);
 }