Exemple #1
0
        public void TestUploadAndGetResource()
        {
            //should allow sending custom coordinates

            var coordinates = new Core.Rectangle(121, 31, 110, 151);

            var upResult = m_cloudinary.Upload(new ImageUploadParams()
            {
                File = new FileDescription(m_testImagePath),
                CustomCoordinates = coordinates,
                Tags = m_apiTag
            });

            var result = m_cloudinary.GetResource(new GetResourceParams(upResult.PublicId)
            {
                Prefix     = m_test_prefix,
                NextCursor = "test",
                StartAt    = "start",
                Direction  = "-1",
                Tags       = true,
                Context    = true,
                Moderation = true
            });

            Assert.NotNull(result.NextCursor);
            Assert.NotZero(result.Tags.Length);
        }
        public void TestUpdateCustomCoordinatesAsync()
        {
            //should update custom coordinates
            var coordinates = new Core.Rectangle(121, 31, 110, 151);
            var upResult    = m_cloudinary.UploadAsync(new ImageUploadParams()
            {
                File = new FileDescription(m_testImagePath),
                Tags = m_apiTag
            }).Result;

            var updResult = m_cloudinary.UpdateResourceAsync(new UpdateParams(upResult.PublicId)
            {
                CustomCoordinates = coordinates
            }).Result;

            var result = m_cloudinary.GetResourceAsync(new GetResourceParams(upResult.PublicId)
            {
                Coordinates = true
            }).Result;

            Assert.NotNull(result.Coordinates);
            Assert.NotNull(result.Coordinates.Custom);
            Assert.AreEqual(1, result.Coordinates.Custom.Length);
            Assert.AreEqual(4, result.Coordinates.Custom[0].Length);
            Assert.AreEqual(coordinates.X, result.Coordinates.Custom[0][0]);
            Assert.AreEqual(coordinates.Y, result.Coordinates.Custom[0][1]);
            Assert.AreEqual(coordinates.Width, result.Coordinates.Custom[0][2]);
            Assert.AreEqual(coordinates.Height, result.Coordinates.Custom[0][3]);
        }
 private void AssertUpdatedCustomCoordinates(GetResourceResult result, Core.Rectangle coordinates)
 {
     Assert.NotNull(result.Coordinates);
     Assert.NotNull(result.Coordinates.Custom);
     Assert.AreEqual(1, result.Coordinates.Custom.Length);
     Assert.AreEqual(4, result.Coordinates.Custom[0].Length);
     Assert.AreEqual(coordinates.X, result.Coordinates.Custom[0][0]);
     Assert.AreEqual(coordinates.Y, result.Coordinates.Custom[0][1]);
     Assert.AreEqual(coordinates.Width, result.Coordinates.Custom[0][2]);
     Assert.AreEqual(coordinates.Height, result.Coordinates.Custom[0][3]);
 }
Exemple #4
0
        public static void AddWallsToBoard(ref bool[,] isWall, Core.Rectangle walls)
        {
            IEnumerable <Core.Point> wallCells = walls.GetPoints();

            foreach (Core.Point wallCell in wallCells)
            {
                if (wallCell.X >= 0 && wallCell.X < isWall.GetLength(0) && wallCell.Y >= 0 && wallCell.Y < isWall.GetLength(1))
                {
                    isWall[wallCell.X, wallCell.Y] = true;
                }
            }
        }
        public void TestCustomCoordinates()
        {
            //should allow sending custom coordinates

            var coordinates = new Core.Rectangle(121, 31, 110, 151);

            var upResult = m_cloudinary.Upload(new ImageUploadParams()
            {
                File = new FileDescription(m_testImagePath),
                CustomCoordinates = coordinates,
                Tags = m_apiTag
            });

            var result = m_cloudinary.GetResource(new GetResourceParams(upResult.PublicId)
            {
                Coordinates = true
            });

            Assert.NotNull(result.Coordinates);
            Assert.NotNull(result.Coordinates.Custom);
            Assert.AreEqual(1, result.Coordinates.Custom.Length);
            Assert.AreEqual(4, result.Coordinates.Custom[0].Length);
            Assert.AreEqual(coordinates.X, result.Coordinates.Custom[0][0]);
            Assert.AreEqual(coordinates.Y, result.Coordinates.Custom[0][1]);
            Assert.AreEqual(coordinates.Width, result.Coordinates.Custom[0][2]);
            Assert.AreEqual(coordinates.Height, result.Coordinates.Custom[0][3]);

            coordinates = new CloudinaryDotNet.Core.Rectangle(122, 32, 110, 152);

            m_cloudinary.Explicit(new ExplicitParams(upResult.PublicId)
            {
                CustomCoordinates = coordinates,
                Type = STORAGE_TYPE_UPLOAD,
                Tags = m_apiTag
            });

            result = m_cloudinary.GetResource(new GetResourceParams(upResult.PublicId)
            {
                Coordinates = true
            });

            Assert.NotNull(result.Coordinates);
            Assert.NotNull(result.Coordinates.Custom);
            Assert.AreEqual(1, result.Coordinates.Custom.Length);
            Assert.AreEqual(4, result.Coordinates.Custom[0].Length);
            Assert.AreEqual(coordinates.X, result.Coordinates.Custom[0][0]);
            Assert.AreEqual(coordinates.Y, result.Coordinates.Custom[0][1]);
            Assert.AreEqual(coordinates.Width, result.Coordinates.Custom[0][2]);
            Assert.AreEqual(coordinates.Height, result.Coordinates.Custom[0][3]);
        }
        public async Task TestUpdateCustomCoordinatesAsync()
        {
            //should update custom coordinates
            var upResult = await UploadTestImageResourceAsync();

            var coordinates = new Core.Rectangle(121, 31, 110, 151);

            await m_cloudinary.UpdateResourceAsync(
                new UpdateParams(upResult.PublicId)
            {
                CustomCoordinates = coordinates
            });

            var result = await m_cloudinary.GetResourceAsync(
                new GetResourceParams(upResult.PublicId)
            {
                Coordinates = true
            });

            AssertUpdatedCustomCoordinates(result, coordinates);
        }
 /// <summary>
 /// Draws texture within specified drawing boundings
 /// </summary>
 /// <param name="texture">Texture to draw</param>
 /// <param name="drawingBoundings">Drawing boundings, including position</param>
 /// <param name="interpolationMode">Overriden texture interpolation mode</param>
 public void DrawTexture(Texture texture, Core.Rectangle drawingBoundings, Core.InterpolationMode interpolationMode)
 {
     DrawTexture(texture, drawingBoundings, 1f, interpolationMode);
 }
 /// <summary>
 /// Draws texture within specified drawing boundings
 /// </summary>
 /// <param name="texture">Texture to draw</param>
 /// <param name="drawingBoundings">Drawing boundings, including position</param>
 public void DrawTexture(Texture texture, Core.Rectangle drawingBoundings)
 {
     DrawTexture(texture, drawingBoundings, 1f);
 }
 /// <summary>
 /// Draws texture within specified drawing boundings
 /// </summary>
 /// <param name="texture">Texture to draw</param>
 /// <param name="drawingBoundings">Drawing boundings, including position</param>
 /// <param name="opacity">Opacity of texture</param>
 public void DrawTexture(Texture texture, Core.Rectangle drawingBoundings, float opacity)
 {
     DrawTexture(texture, drawingBoundings, opacity, Game.Renderer.InterpolationMode);
 }
 /// <summary>
 /// Draws texture within specified drawing boundings
 /// </summary>
 /// <param name="texture">Texture to draw</param>
 /// <param name="drawingBoundings">Drawing boundings, including position</param>
 /// <param name="opacity">Opacity of texture</param>
 /// <param name="interpolationMode">Overriden texture interpolation mode</param>
 public void DrawTexture(Texture texture, Core.Rectangle drawingBoundings, float opacity, Core.InterpolationMode interpolationMode)
 {
     RenderTarget.DrawBitmap(texture.Bitmap, drawingBoundings.RawRectangle, opacity, (BitmapInterpolationMode)interpolationMode);
 }