Exemple #1
0
        private void LeftViewLoadButton_Click(object sender, RoutedEventArgs e)
        {
            #region drawing extension functions test

            var img = ImageExtensions.BuildImage(Game.Get.TileManager.Tiles);
            img.DrawLine(new Vector2(10, 10), new Vector2(20, 15), 1, Colors.Blue());

            img.DrawRectangle(new Vector2(18, 18), 5, 7, false, 1, Colors.MediumPurple());
            img.DrawRectangle(new Vector2(14, 13), 2, 4, true, 1, Colors.HotPink());

            img.DrawCircle(new Vector2(25, 25), 5, false, 1, Colors.Black());
            img.DrawCircle(new Vector2(25, 10), 5, true, 1, Colors.White());

            var polygonPoints1 = new List <Vector2>()
            {
                new Vector2(10, 1), new Vector2(10, 30), new Vector2(30, 3)
            };
            var polygonPoints2 = new List <Vector2>()
            {
                new Vector2(4, 4), new Vector2(4, 7), new Vector2(7, 7)
            };
            img.DrawPolygon(polygonPoints1, false, 1, Colors.BrightBlue());
            img.DrawPolygon(polygonPoints2, true, 1, Colors.Green());

            img.DrawText(new Vector2(12, 20), "1", 15, Colors.Red());

            var bitmapImage = ImageExtensions.GetBitmapFromPath("Media/Testing/TestDrawnImage2.png");
            img.DrawImage(new Vector2(3, 20), bitmapImage);

            #endregion

            //img.Save("image.png",ImageFormat.Png);
            //Variable used to load the image in online so it can be copied and checked using https://codebeautify.org/base64-to-image-converter.
            //var strval = Convert.ToBase64String(ImageExtensions.ToByteArray(img));
            //LeftViewContainer.Source = ImageExtensions.BitmapToImageSource(img);
            var controlImage = new CustomImage
            {
                Source = ImageExtensions.BitmapToImageSource(img)
            };
            Main.GetDispatcher.Invoke(PopulateCanvasControlDelegate, LeftViewContainer, new List <CustomImage> {
                controlImage
            }, false);
        }