public void SetScaleTranslateWorksCorrectly()
        {
            var tempMatrix = SKMatrix.MakeIdentity();

            tempMatrix.Values = new float[] { 1, 0, 0, 0, 1, 0, 0, 0, 1 };

            SKMatrix.RotateDegrees(ref tempMatrix, 0);

            tempMatrix.SetScaleTranslate(1.2f, 1.0f, 0, 0);

            Assert.Equal(1.2f, tempMatrix.Values[0]);
        }
Exemple #2
0
        public override void DrawImage(SKCanvas dc)
        {
            var     rect_Car  = GetMainRect();
            SKPoint pt_Center = new SKPoint(rect_Car.Left + (rect_Car.Width / 2), rect_Car.Top + (rect_Car.Height / 2));
            SKRect  rect_Body;
            SKPath  gp_Body;
            SKRect  rect_Tire;
            float   int_TireHeight;

            SKPoint[] pts_Body;
            SKRect    rect_Hole;
            int       int_Row;
            int       int_Col;
            float     int_HoleWidth;
            int       int_Count;
            CustomBasicList <SKRect> arr_Holes;
            SKColor  clr_Peg;
            SKMatrix tmp_Matrix = new SKMatrix();

            if (CarType == EnumTypesOfCars.Minivan)
            {
                // *** Draw tires
                int_TireHeight = (rect_Car.Height / 5);
                rect_Tire      = SKRect.Create(rect_Car.Left, rect_Car.Top + (rect_Car.Height / 10), rect_Car.Width, int_TireHeight);
                dc.DrawRect(rect_Tire, _blackPaint);
                rect_Tire = SKRect.Create(rect_Car.Left, (rect_Car.Top + rect_Car.Height) - (rect_Car.Height / 10) - int_TireHeight, rect_Car.Width, int_TireHeight);
                dc.DrawRect(rect_Tire, _blackPaint);
                // *** Draw the body outline
                gp_Body     = new SKPath();
                rect_Body   = SKRect.Create(rect_Car.Left + (rect_Car.Width / 12), rect_Car.Top, rect_Car.Width - (rect_Car.Width / 6), rect_Car.Height);
                pts_Body    = new SKPoint[4];
                pts_Body[0] = new SKPoint(System.Convert.ToInt32(rect_Body.Left), rect_Body.Top + (rect_Body.Height / 30));
                pts_Body[1] = new SKPoint(System.Convert.ToInt32((rect_Body.Left + rect_Body.Width)), rect_Body.Top + (rect_Body.Height / 30));
                pts_Body[2] = new SKPoint(System.Convert.ToInt32(((rect_Body.Left + rect_Body.Width) - (rect_Car.Width / 15))), (rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 30));
                pts_Body[3] = new SKPoint(System.Convert.ToInt32((rect_Body.Left + (rect_Car.Width / 15))), (rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 30));
                gp_Body.AddPoly(pts_Body);
                SKMatrix.RotateDegrees(ref tmp_Matrix, 180, pt_Center.X, pt_Center.Y);
                gp_Body.Transform(tmp_Matrix);
                dc.DrawPath(gp_Body, MainPaint);
                dc.DrawPath(gp_Body, _borderPaint);
                gp_Body     = new SKPath();
                pts_Body    = new SKPoint[3];
                pts_Body[0] = new SKPoint(rect_Body.Left + (rect_Body.Width / 15), rect_Body.Top + (rect_Body.Height / 15));
                pts_Body[1] = new SKPoint(rect_Body.Left + (rect_Body.Width / 2), rect_Body.Top + (rect_Body.Height / 100));
                pts_Body[2] = new SKPoint((rect_Body.Left + rect_Body.Width) - (rect_Body.Width / 15), rect_Body.Top + (rect_Body.Height / 15));
                gp_Body.AddPoly(pts_Body);
                SKMatrix.RotateDegrees(ref tmp_Matrix, 180, pt_Center.X, pt_Center.Y);
                gp_Body.Transform(tmp_Matrix);
                dc.DrawPath(gp_Body, _blackPaint);
                // *** Draw the front window
                gp_Body     = new SKPath();
                pts_Body    = new SKPoint[8];
                pts_Body[0] = new SKPoint(rect_Body.Left + (rect_Body.Width / 12), (rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 3));
                pts_Body[1] = new SKPoint(rect_Body.Left + (rect_Body.Width / 2), ((rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 3)) + (rect_Body.Height / 30));
                pts_Body[2] = new SKPoint((rect_Body.Left + rect_Body.Width) - (rect_Body.Width / 12), (rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 3));
                pts_Body[3] = new SKPoint((rect_Body.Left + rect_Body.Width) - (rect_Body.Width / 12), (rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 3));
                pts_Body[4] = new SKPoint((rect_Body.Left + rect_Body.Width) - (rect_Body.Width / 6), (rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 4));
                pts_Body[5] = new SKPoint(rect_Body.Left + (rect_Body.Width / 2), ((rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 4)) + (rect_Body.Height / 30));
                pts_Body[6] = new SKPoint(rect_Body.Left + (rect_Body.Width / 6), (rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 4));
                pts_Body[7] = new SKPoint(rect_Body.Left + (rect_Body.Width / 12), (rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 3));
                gp_Body.AddPoly(pts_Body);
                SKMatrix.RotateDegrees(ref tmp_Matrix, 180, pt_Center.X, pt_Center.Y);
                gp_Body.Transform(tmp_Matrix);
                dc.DrawPath(gp_Body, _blackPaint);
                // *** Draw the hood
                gp_Body     = new SKPath();
                pts_Body    = new SKPoint[8];
                pts_Body[0] = new SKPoint(rect_Body.Left + (rect_Body.Width / 8), ((rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 3)) + (rect_Body.Height / 10));
                pts_Body[1] = new SKPoint(rect_Body.Left + (rect_Body.Width / 2), ((rect_Body.Top + rect_Body.Height) - ((rect_Body.Height * 2) / 6)) + (rect_Body.Height / 30) + (rect_Body.Height / 10));
                pts_Body[2] = new SKPoint((rect_Body.Left + rect_Body.Width) - (rect_Body.Width / 8), ((rect_Body.Top + rect_Body.Height) - ((rect_Body.Height * 2) / 6)) + (rect_Body.Height / 10));
                pts_Body[3] = new SKPoint((rect_Body.Left + rect_Body.Width) - (rect_Body.Width / 8), ((rect_Body.Top + rect_Body.Height) - ((rect_Body.Height * 2) / 6)) + (rect_Body.Height / 10));
                pts_Body[4] = new SKPoint((rect_Body.Left + rect_Body.Width) - (rect_Body.Width / 5), (rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 30));
                pts_Body[5] = new SKPoint(rect_Body.Left + (rect_Body.Width / 2), rect_Body.Top + rect_Body.Height);
                pts_Body[6] = new SKPoint(rect_Body.Left + (rect_Body.Width / 5), (rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 30));
                pts_Body[7] = new SKPoint(rect_Body.Left + (rect_Body.Width / 8), ((rect_Body.Top + rect_Body.Height) - (rect_Body.Height / 3)) + (rect_Body.Height / 10));
                gp_Body.AddPoly(pts_Body);
                SKMatrix.RotateDegrees(ref tmp_Matrix, 180, pt_Center.X, pt_Center.Y);
                gp_Body.Transform(tmp_Matrix);
                dc.DrawPath(gp_Body, MainPaint);
            }
            else if (CarType == EnumTypesOfCars.Car)
            {
            }
            // *** Draw the holes
            arr_Holes     = new CustomBasicList <SKRect>();
            int_HoleWidth = rect_Car.Width * 2 / 9;
            for (int_Row = 0; int_Row <= 2; int_Row++)
            {
                for (int_Col = 0; int_Col <= 1; int_Col++)
                {
                    if (int_Col == 0)
                    {
                        rect_Hole = SKRect.Create(rect_Car.Left + (rect_Car.Width / 5), rect_Car.Top + (rect_Car.Height * 2 / 5) + (int_Row * (int_HoleWidth + (int_HoleWidth / 4))), int_HoleWidth, int_HoleWidth);
                    }
                    else
                    {
                        rect_Hole = SKRect.Create(rect_Car.Left + rect_Car.Width - (rect_Car.Width / 5) - int_HoleWidth, rect_Car.Top + (rect_Car.Height * 2 / 5) + (int_Row * (int_HoleWidth + (int_HoleWidth / 4))), int_HoleWidth, int_HoleWidth);
                    }

                    arr_Holes.Add(rect_Hole);
                }
            }
            var loopTo = arr_Holes.Count;

            for (int_Count = 1; int_Count <= loopTo; int_Count++)
            {
                rect_Hole = arr_Holes[int_Count - 1];
                dc.DrawOval(rect_Hole, _blackPaint);

                if (_arr_Pegs.Count >= int_Count)
                {
                    clr_Peg = _arr_Pegs[int_Count - 1].ToSKColor();
                    DrawPeg(dc, rect_Hole, clr_Peg);
                }
            }
        }
Exemple #3
0
        protected override void CreateSpaces()
        {
            var      bounds = GetBounds();
            int      int_Count;
            SKRect   rect;
            SKPoint  pt_Center  = new SKPoint(bounds.Left + (bounds.Width / 2), bounds.Top + (bounds.Height / 2));
            SKMatrix tmp_Matrix = new SKMatrix();
            SKPath   gp;
            SKRect   obj_Space;

            _homeSpaces   = new Dictionary <int, SKRect>();
            _rect_Deck    = SKRect.Create(pt_Center.X - this.CardSize().Width - (this.CardSize().Width / 10), pt_Center.Y - (this.CardSize().Height / 2), this.CardSize().Width, this.CardSize().Height);
            _rect_Discard = SKRect.Create(pt_Center.X + (this.CardSize().Width / 10), pt_Center.Y - (this.CardSize().Height / 2), this.CardSize().Width, this.CardSize().Height);
            SKMatrix.RotateDegrees(ref tmp_Matrix, 90, pt_Center.X, pt_Center.Y);
            int spaceNumber;

            // *** Draw starts
            // *** Draw circles
            gp = new SKPath();
            var thisRect = SKRect.Create(bounds.Left + ((bounds.Width * 41) / 64), bounds.Top + ((bounds.Height * 95) / 200) + ((bounds.Height * 5) / 16), (bounds.Width * 5) / 32, (bounds.Height * 5) / 32);

            gp.AddRect(thisRect);
            obj_Space   = SKRect.Create(thisRect.Left, thisRect.Top, thisRect.Width / 2, thisRect.Height / 2);
            spaceNumber = 1;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left + (gp.Bounds.Width / 2), gp.Bounds.Top, gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 2;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left, gp.Bounds.Top + (gp.Bounds.Height / 2), gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 3;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left + (gp.Bounds.Width / 2), gp.Bounds.Top + (gp.Bounds.Height / 2), gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 4;
            _spaceList.Add(spaceNumber, obj_Space);
            gp.Transform(tmp_Matrix);
            obj_Space   = SKRect.Create(gp.Bounds.Left, gp.Bounds.Top, gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 5;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left + (gp.Bounds.Width / 2), gp.Bounds.Top, gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 6;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left, gp.Bounds.Top + (gp.Bounds.Height / 2), gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 7;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left + (gp.Bounds.Width / 2), gp.Bounds.Top + (gp.Bounds.Height / 2), gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 8;
            _spaceList.Add(spaceNumber, obj_Space);
            gp.Transform(tmp_Matrix);
            obj_Space   = SKRect.Create(gp.Bounds.Left, gp.Bounds.Top, gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 9;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left + (gp.Bounds.Width / 2), gp.Bounds.Top, gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 10;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left, gp.Bounds.Top + (gp.Bounds.Height / 2), gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 11;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left + (gp.Bounds.Width / 2), gp.Bounds.Top + (gp.Bounds.Height / 2), gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 12;
            _spaceList.Add(spaceNumber, obj_Space);
            gp.Transform(tmp_Matrix);
            obj_Space   = SKRect.Create(gp.Bounds.Left, gp.Bounds.Top, gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 13;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left + (gp.Bounds.Width / 2), gp.Bounds.Top, gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 14;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left, gp.Bounds.Top + (gp.Bounds.Height / 2), gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 15;
            _spaceList.Add(spaceNumber, obj_Space);
            obj_Space   = SKRect.Create(gp.Bounds.Left + (gp.Bounds.Width / 2), gp.Bounds.Top + (gp.Bounds.Height / 2), gp.Bounds.Width / 2, gp.Bounds.Height / 2);
            spaceNumber = 16;
            _spaceList.Add(spaceNumber, obj_Space);
            gp.Dispose();
            // *********************************************
            // *** Draw Homes
            // *** Draw circles
            gp = new SKPath();
            gp.AddRect(SKRect.Create(bounds.Left + ((bounds.Width * 49) / 64), bounds.Top + ((bounds.Height * 95) / 200), (bounds.Width * 5) / 32, (bounds.Height * 5) / 32));
            obj_Space   = SKRect.Create(gp.Bounds.Left, gp.Bounds.Top, gp.Bounds.Width, gp.Bounds.Height);
            spaceNumber = 1;
            _homeSpaces.Add(spaceNumber, obj_Space);
            gp.Transform(tmp_Matrix);
            obj_Space   = SKRect.Create(gp.Bounds.Left, gp.Bounds.Top, gp.Bounds.Width, gp.Bounds.Height);
            spaceNumber = 2;
            _homeSpaces.Add(spaceNumber, obj_Space);
            gp.Transform(tmp_Matrix);
            obj_Space   = SKRect.Create(gp.Bounds.Left, gp.Bounds.Top, gp.Bounds.Width, gp.Bounds.Height);
            spaceNumber = 3;
            _homeSpaces.Add(spaceNumber, obj_Space);
            gp.Transform(tmp_Matrix);
            obj_Space   = SKRect.Create(gp.Bounds.Left, gp.Bounds.Top, gp.Bounds.Width, gp.Bounds.Height);
            spaceNumber = 4;
            _homeSpaces.Add(spaceNumber, obj_Space);
            for (int_Count = 10; int_Count <= 14; int_Count++)
            {
                // *** Blue
                rect        = SKRect.Create(bounds.Left + ((bounds.Width * 13) / 16), bounds.Top + ((bounds.Height * int_Count) / 16), bounds.Width / 16, ((((bounds.Height * (int_Count + 1)) / 16)) - (((bounds.Height * int_Count) / 16))) + 1);
                obj_Space   = rect;
                spaceNumber = (77 + 14) - int_Count;
                _spaceList.Add(spaceNumber, obj_Space);
                // *** yellow
                rect        = SKRect.Create(bounds.Left + ((bounds.Width * (int_Count - 9)) / 16), bounds.Top + ((bounds.Height * 13) / 16), ((((bounds.Width * (int_Count + 1)) / 16)) - (((bounds.Width * int_Count) / 16))) + 1, bounds.Height / 16);
                obj_Space   = rect;
                spaceNumber = 72 + int_Count;
                _spaceList.Add(spaceNumber, obj_Space);
                // *** green
                rect        = SKRect.Create(bounds.Left + ((bounds.Width * 2) / 16), bounds.Top + ((bounds.Height * (int_Count - 9)) / 16), bounds.Width / 16, ((((bounds.Height * (int_Count + 1)) / 16)) - (((bounds.Height * int_Count) / 16))) + 1);
                obj_Space   = rect;
                spaceNumber = 77 + int_Count;
                _spaceList.Add(spaceNumber, obj_Space);
                // *** red
                rect        = SKRect.Create(bounds.Left + ((bounds.Width * int_Count) / 16), bounds.Top + ((bounds.Height * 2) / 16), ((((bounds.Width * (int_Count + 1)) / 16)) - (((bounds.Width * int_Count) / 16))) + 1, bounds.Height / 16);
                obj_Space   = rect;
                spaceNumber = (92 + 14) - int_Count;
                _spaceList.Add(spaceNumber, obj_Space);
            }
            for (int_Count = 0; int_Count <= 15; int_Count++)
            {
                if ((int_Count > 0) & (int_Count < 15))
                {
                    // *** Top
                    rect        = SKRect.Create(bounds.Left + ((bounds.Width * int_Count) / 16), bounds.Top, ((((bounds.Width * (int_Count + 1)) / 16)) - (((bounds.Width * int_Count) / 16))) + 1, bounds.Height / 16);
                    obj_Space   = rect;
                    spaceNumber = 43 + int_Count;
                    _spaceList.Add(spaceNumber, obj_Space);
                    // *** Bottom
                    rect      = SKRect.Create(bounds.Left + ((bounds.Width * int_Count) / 16), bounds.Top + ((bounds.Height * 15) / 16), ((((bounds.Width * (int_Count + 1)) / 16)) - (((bounds.Width * int_Count) / 16))) + 1, bounds.Height / 16);
                    obj_Space = rect;
                    if ((28 - int_Count) < 17)
                    {
                        spaceNumber = 88 - int_Count;
                    }
                    else
                    {
                        spaceNumber = 28 - int_Count;
                    }
                    _spaceList.Add(spaceNumber, obj_Space);
                    // *** Left
                    rect        = SKRect.Create(bounds.Left, bounds.Top + ((bounds.Height * int_Count) / 16), bounds.Width / 16, ((((bounds.Height * (int_Count + 1)) / 16)) - (((bounds.Height * int_Count) / 16))) + 1);
                    obj_Space   = rect;
                    spaceNumber = 43 - int_Count;
                    _spaceList.Add(spaceNumber, obj_Space);
                    // *** Right
                    rect        = SKRect.Create(bounds.Left + ((bounds.Width * 15) / 16), bounds.Top + ((bounds.Height * int_Count) / 16), bounds.Width / 16, ((((bounds.Height * (int_Count + 1)) / 16)) - (((bounds.Height * int_Count) / 16))) + 1);
                    obj_Space   = rect;
                    spaceNumber = 58 + int_Count;
                    _spaceList.Add(spaceNumber, obj_Space);
                }
                else
                {
                    // *** Top
                    rect        = SKRect.Create(bounds.Left + ((bounds.Width * int_Count) / 16), bounds.Top, (((bounds.Width * (int_Count + 1)) / 16)) - (((bounds.Width * int_Count) / 16)), bounds.Height / 16);
                    obj_Space   = rect;
                    spaceNumber = 43 + int_Count;
                    _spaceList.Add(spaceNumber, obj_Space);
                    // *** Bottom
                    rect      = SKRect.Create(bounds.Left + ((bounds.Width * int_Count) / 16), bounds.Top + ((bounds.Height * 15) / 16), (((bounds.Width * (int_Count + 1)) / 16)) - (((bounds.Width * int_Count) / 16)), bounds.Height / 16);
                    obj_Space = rect;
                    if ((28 - int_Count) < 17)
                    {
                        spaceNumber = 88 - int_Count;
                    }
                    else
                    {
                        spaceNumber = 28 - int_Count;
                    }
                    _spaceList.Add(spaceNumber, obj_Space);
                }
            }
            if (_spaceList.Count == 0)
            {
                throw new BasicBlankException("No spaces was created");
            }
            if (_homeSpaces.Count != 4)
            {
                throw new BasicBlankException("Should be 4 home spaces, not " + _homeSpaces.Count.ToString());
            }
            PieceHeight = bounds.Height / 17f;
            PieceWidth  = bounds.Width / 17f;
            gp.Dispose();
        }