public override void DrawImage(SKCanvas dc)
        {
            var thisRect = GetMainRect();

            if (NeedsWhiteBorders == true)
            {
                dc.DrawRect(thisRect, _whitePaint);
                dc.DrawRect(thisRect, _thickBorder);
                thisRect = SKRect.Create(thisRect.Location.X + 5, thisRect.Location.Y + 5, thisRect.Width - 10, thisRect.Width - 10);
            }
            else
            {
                thisRect = SKRect.Create(thisRect.Location.X + 2, thisRect.Location.Y + 2, thisRect.Width - 4, thisRect.Height - 4);
            }
            if (thisRect.Width != thisRect.Height)
            {
                throw new BasicBlankException("Rethink because width and height is not the same so its not a true circle.  Values are " + thisRect.Width + ", " + thisRect.Height + ".  Actual Was " + ActualWidth + ", " + ActualHeight + ".  Needs White Borders Is " + NeedsWhiteBorders);
            }
            if (MainColor.Equals(cs.Transparent) == true)
            {
                if (NeedsWhiteBorders == false)
                {
                    throw new Exception("Will cause blank.  If we want that, rethink");
                }
                return;
            }
            dc.DrawOval(thisRect, MainPaint);
            dc.DrawOval(thisRect, _borderPaint);
        }
        public override void DrawImage(SKCanvas dc)
        {
            SKBitmap thisBit;

            if (MainColor.Equals(cs.Blue) == true)
            {
                // blue processes

                switch (WhichPiece)
                {
                case EnumPieceType.BISHOP:
                {
                    thisBit = _blueBishop;
                    break;
                }

                case EnumPieceType.KING:
                {
                    thisBit = _blueKing;
                    break;
                }

                case EnumPieceType.KNIGHT:
                {
                    thisBit = _blueKnight;
                    break;
                }

                case EnumPieceType.PAWN:
                {
                    thisBit = _bluePawn;
                    break;
                }

                case EnumPieceType.QUEEN:
                {
                    thisBit = _blueQueen;
                    break;
                }

                case EnumPieceType.ROOK:
                {
                    thisBit = _blueRook;
                    break;
                }

                default:
                {
                    throw new BasicBlankException("Not supported");
                }
                }
            }
            else if (MainColor.Equals(cs.Red) == true)
            {
                // red processes
                switch (WhichPiece)
                {
                case EnumPieceType.BISHOP:
                {
                    thisBit = _redBishop;
                    break;
                }

                case EnumPieceType.KING:
                {
                    thisBit = _redKing;
                    break;
                }

                case EnumPieceType.KNIGHT:
                {
                    thisBit = _redKnight;
                    break;
                }

                case EnumPieceType.PAWN:
                {
                    thisBit = _redPawn;
                    break;
                }

                case EnumPieceType.QUEEN:
                {
                    thisBit = _redQueen;
                    break;
                }

                case EnumPieceType.ROOK:
                {
                    thisBit = _redRook;
                    break;
                }

                default:
                {
                    throw new BasicBlankException("Not supported");
                }
                }
            }
            else
            {
                throw new BasicBlankException("Only blue and red are supported for chess pieces");
            }
            if (thisBit == null == true)
            {
                throw new BasicBlankException("There is no bitmap to even draw");
            }
            var thisRect = GetMainRect();

            dc.DrawBitmap(thisBit, thisRect, _bitPaint);
        }
Exemple #3
0
        public override void DrawImage(SKCanvas dc)
        {
            if (ActualHeight == 1)
            {
                return;
            }
            // anything that needs to be drawn for each space will be here.  if nothing is done, then will do nothing.
            if (Number == 0)
            {
                return;// because no number associated with it.  must have a number
            }
            if (Number == 10 || Number == 11)
            {
                throw new BasicBlankException("Can't have 10 or 11 for number");
            }
            if (Number < 1 || Number > 12)
            {
                throw new BasicBlankException("Number has to be between 2 and 12 but no 10 or 11");
            }
            // can be transparent and previous one (if removing space)
            if (ActualHeight != ActualWidth)
            {
                throw new BasicBlankException("Must be perfect squares for this game");
            }
            if (ActualWidth == 0 || ActualHeight == 0)
            {
                throw new BasicBlankException("Can't be 0 for the actual width or height");
            }
            var thisRect = GetMainRect();
            var newRect  = SKRect.Create(3, 3, thisRect.Width - 6, thisRect.Height - 6);

            if (Number != 2 && Number != 12)
            {
                if (WasPrevious == true)
                {
                    dc.DrawRect(thisRect, _yellowPaint);
                }
                else
                {
                    dc.DrawRect(thisRect, _whitePaint);
                }
                SKPaint otherTextPaint;
                if (MainColor.Equals(cs.Transparent) == false)
                {
                    // this means do a circle
                    dc.DrawOval(newRect, _borderPaint);
                    dc.DrawOval(newRect, MainPaint); // i think
                    otherTextPaint = MiscHelpers.GetTextPaint(SKColors.Aqua, newRect.Height * 1.2f);
                }
                else
                {
                    otherTextPaint = MiscHelpers.GetTextPaint(SKColors.Red, newRect.Height * 1.2f);
                }
                dc.DrawBorderText(Number.ToString(), TextExtensions.EnumLayoutOptions.Center, TextExtensions.EnumLayoutOptions.Center, otherTextPaint, _text1Paint, newRect);
                dc.DrawRect(thisRect, _borderPaint);
                return;
            }
            dc.DrawRect(thisRect, _grayPaint);
            StandardDiceGraphicsCP firstDice = new StandardDiceGraphicsCP();
            {
                var withBlock = firstDice;
                withBlock.Location          = new SKPoint(newRect.Location.X, newRect.Location.Y);
                withBlock.NeedsToClear      = false;
                withBlock.ActualWidthHeight = newRect.Height / 2.1f;
                withBlock.Value             = Number / 2;
                withBlock.UseSmallerBorders();
                if (WasPrevious == true)
                {
                    withBlock.FillColor = cs.Yellow;
                }
            }

            StandardDiceGraphicsCP secondDice = new StandardDiceGraphicsCP();

            {
                var withBlock1 = secondDice;
                withBlock1.Location          = new SKPoint(firstDice.Location.X + 3 + firstDice.ActualWidthHeight, firstDice.Location.Y + 3 + firstDice.ActualWidthHeight);
                withBlock1.NeedsToClear      = false;
                withBlock1.ActualWidthHeight = newRect.Height / 2.1f;
                withBlock1.Value             = Number / 2;
                withBlock1.UseSmallerBorders();
                if (WasPrevious == true)
                {
                    withBlock1.FillColor = cs.Yellow;
                }
            }
            firstDice.DrawDice(dc);
            secondDice.DrawDice(dc);
            if (MainColor.Equals(cs.Transparent) == false)
            {
                // this means do a circle
                dc.DrawOval(newRect, _borderPaint);
                dc.DrawOval(newRect, MainPaint); // i think
                SKPaint otherTextPaint;
                if (Number == 2)
                {
                    otherTextPaint = MiscHelpers.GetTextPaint(SKColors.Aqua, newRect.Height * 1.2f);
                }
                else
                {
                    otherTextPaint = MiscHelpers.GetTextPaint(SKColors.Aqua, newRect.Height * 0.7f);
                }
                dc.DrawBorderText(Number.ToString(), TextExtensions.EnumLayoutOptions.Center, TextExtensions.EnumLayoutOptions.Center, otherTextPaint, _text1Paint, newRect);
                dc.DrawRect(thisRect, _borderPaint);
                return;
            }
            dc.DrawRect(thisRect, _borderPaint);
        }
        public void DrawWeapon(SKCanvas dc, SKRect rect_Piece)
        {
            if (Weapon == EnumWeaponList.None)
            {
                throw new BasicBlankException("You must specify a weapon to draw");
            }
#pragma warning disable IDE0068 // Use recommended dispose pattern
            SKPath gp_Piece = new SKPath();
#pragma warning restore IDE0068 // Use recommended dispose pattern  cannot do recommended because it creates some other objects.
            SKPoint[] pts_Curve;
            int[]     int_Offset;
            SKMatrix  tmp_Matrix;
            tmp_Matrix        = SKMatrix.MakeScale(rect_Piece.Width / 100, rect_Piece.Height / 100);
            tmp_Matrix.TransX = rect_Piece.Left;
            tmp_Matrix.TransY = rect_Piece.Top;
            switch (Weapon)
            {
            case EnumWeaponList.Candlestick:
            {
                int_Offset    = new int[5];
                int_Offset[0] = 35;
                int_Offset[1] = 30;
                int_Offset[2] = 40;
                int_Offset[3] = 30;
                int_Offset[4] = 50;
                pts_Curve     = new SKPoint[10];     // was 4.  has to do poly since curves don't work
                pts_Curve[0]  = new SKPoint((float)50 + int_Offset[0], 0);
                pts_Curve[1]  = new SKPoint((float)50 + int_Offset[1], 20);
                pts_Curve[2]  = new SKPoint((float)50 + int_Offset[2], 50);
                pts_Curve[3]  = new SKPoint((float)50 + int_Offset[3], 80);
                pts_Curve[4]  = new SKPoint((float)50 + int_Offset[4], 90);
                pts_Curve[9]  = new SKPoint((float)50 - int_Offset[0], 0);
                pts_Curve[8]  = new SKPoint((float)50 - int_Offset[1], 20);
                pts_Curve[7]  = new SKPoint((float)50 - int_Offset[2], 50);
                pts_Curve[6]  = new SKPoint((float)50 - int_Offset[3], 80);
                pts_Curve[5]  = new SKPoint((float)50 - int_Offset[4], 90);
                gp_Piece.AddPoly(pts_Curve);
                gp_Piece.AddRect(SKRect.Create(0, 90, 100, 10));
                gp_Piece.Transform(tmp_Matrix);
                dc.DrawPath(gp_Piece, MainPaint);
                dc.DrawPath(gp_Piece, _borderPaint);
                break;
            }

            case EnumWeaponList.Knife:
            {
                int_Offset    = new int[5];
                int_Offset[0] = 0;
                int_Offset[1] = 15;
                int_Offset[2] = 20;
                int_Offset[3] = 18;
                int_Offset[4] = 15;
                pts_Curve     = new SKPoint[12];
                pts_Curve[0]  = new SKPoint((float)50 + int_Offset[0], 0);
                pts_Curve[1]  = new SKPoint((float)50 + int_Offset[1], 5);
                pts_Curve[2]  = new SKPoint((float)50 + int_Offset[2], 15);
                pts_Curve[3]  = new SKPoint((float)50 + int_Offset[3], 25);
                pts_Curve[4]  = new SKPoint((float)50 + int_Offset[4], 50);
                pts_Curve[5]  = new SKPoint(50, 100);
                pts_Curve[11] = new SKPoint((float)50 - int_Offset[0], 0);
                pts_Curve[10] = new SKPoint((float)50 - int_Offset[1], 5);
                pts_Curve[9]  = new SKPoint((float)50 - int_Offset[2], 15);
                pts_Curve[8]  = new SKPoint((float)50 - int_Offset[3], 25);
                pts_Curve[7]  = new SKPoint((float)50 - int_Offset[4], 50);
                pts_Curve[6]  = new SKPoint(50, 100);
                gp_Piece.AddPoly(pts_Curve);
                gp_Piece.Transform(tmp_Matrix);
                dc.DrawPath(gp_Piece, MainPaint);
                dc.DrawPath(gp_Piece, _borderPaint);
                gp_Piece = new SKPath();
                gp_Piece.AddRect(SKRect.Create(0, 25, 100, 10));
                gp_Piece.Transform(tmp_Matrix);
                dc.DrawPath(gp_Piece, MainPaint);
                dc.DrawPath(gp_Piece, _borderPaint);
                break;
            }

            case EnumWeaponList.LeadPipe:
            {
                gp_Piece = new SKPath();
                gp_Piece.AddRect(SKRect.Create(0, 0, 100, 100));
                gp_Piece.Transform(tmp_Matrix);
                if (MainColor.Equals(cs.Aqua) == true)
                {
                    dc.DrawPath(gp_Piece, _mainHatchPaint);
                }
                else
                {
                    dc.DrawPath(gp_Piece, _cardHatchPaint);
                }
                dc.DrawPath(gp_Piece, _borderPaint);
                gp_Piece = new SKPath();
                gp_Piece.AddRect(SKRect.Create(0, 20, 100, 60));
                gp_Piece.Transform(tmp_Matrix);
                dc.DrawPath(gp_Piece, MainPaint);
                dc.DrawPath(gp_Piece, _borderPaint);
                break;
            }

            case EnumWeaponList.Revolver:
            {
                pts_Curve    = new SKPoint[3];
                pts_Curve[0] = new SKPoint(20, 65);
                pts_Curve[1] = new SKPoint(55, 60);
                pts_Curve[2] = new SKPoint(55, 30);
                gp_Piece.AddPoly(pts_Curve);         // try this way
                gp_Piece.Transform(tmp_Matrix);
                dc.DrawPath(gp_Piece, MainPaint);
                dc.DrawPath(gp_Piece, _borderPaint);
                gp_Piece     = new SKPath();
                pts_Curve    = new SKPoint[8];
                pts_Curve[0] = new SKPoint(100, 5);
                pts_Curve[1] = new SKPoint(30, 5);
                pts_Curve[2] = new SKPoint(20, 20);
                pts_Curve[3] = new SKPoint(0, 100);
                pts_Curve[4] = new SKPoint(30, 100);
                pts_Curve[5] = new SKPoint(35, 80);
                pts_Curve[6] = new SKPoint(45, 45);
                pts_Curve[7] = new SKPoint(100, 40);
                gp_Piece.AddPoly(pts_Curve);
                gp_Piece.Transform(tmp_Matrix);
                dc.DrawPath(gp_Piece, MainPaint);
                dc.DrawPath(gp_Piece, _borderPaint);
                break;
            }

            case EnumWeaponList.Rope:
            {
                int int_Angle = 0;
                int int_Count;
                var rect_Rope = SKRect.Create(45, 45, 10, 10);
                for (int_Count = 1; int_Count <= 8; int_Count++)
                {
                    gp_Piece.AddArc(rect_Rope, int_Angle, 180);
                    if (int_Angle == 0)
                    {
                        rect_Rope = SKRect.Create(rect_Rope.Left, rect_Rope.Top - 5, rect_Rope.Width + 10, rect_Rope.Height + 10);
                        int_Angle = 180;
                    }
                    else
                    {
                        rect_Rope = SKRect.Create(rect_Rope.Left - 10, rect_Rope.Top - 5, rect_Rope.Width + 10, rect_Rope.Height + 10);
                        int_Angle = 0;
                    }
                }
                gp_Piece.AddLine(100, 65, 95, 70);
                gp_Piece.Transform(tmp_Matrix);
                dc.DrawPath(gp_Piece, MainPaint);
                dc.DrawPath(gp_Piece, _borderPaint);
                break;
            }

            case EnumWeaponList.Wrench:
            {
                gp_Piece.AddLine(0, 10, 10, 0, true);
                gp_Piece.AddLine(90, 0, 100, 10);
                gp_Piece.AddLine(100, 100, 60, 100);
                gp_Piece.AddLine(60, 40, 10, 40);
                gp_Piece.AddLine(0, 30, 40, 30);
                gp_Piece.AddLine(40, 10, 0, 10);
                gp_Piece.Close();
                gp_Piece.Transform(tmp_Matrix);
                dc.DrawPath(gp_Piece, MainPaint);
                dc.DrawPath(gp_Piece, _borderPaint);
                break;
            }
            }
        }