Ejemplo n.º 1
0
        public override void SetUp()
        {
            base.SetUp();
            _step = GetService <OffsetImage>();

            // Create a sample image, filling a region so we can verify offset
            _image = new Image <Rgba32>(100, 100);
            _image.Mutate(c => c.Fill(Color.Red, new Rectangle(0, 0, 50, 50)));
        }
Ejemplo n.º 2
0
        public void OffsetPatternToScript_ShouldReturnRightString()
        {
            var pathToTestPic = Path.GetFullPath(@"..\..\..\Utils\vs.png");
            var pattern       = new FileImage(pathToTestPic, 0.3);
            var point         = new Point(5, 5);
            var offsetPattern = new OffsetImage(pattern, point);

            var actualResult = offsetPattern.ToSikuliScript("click", 0);

            actualResult.Should()
            .Be(
                $@"print ""SIKULI#: YES"" if click(Pattern({"\"" + pathToTestPic + "\""}).similar(0.3).targetOffset(5, 5)) else ""SIKULI#: NO""");
        }
Ejemplo n.º 3
0
        public void DoubleClickWithOffset_InvokePattern_WithRightCommand()
        {
            var offset        = new Point(5, 5);
            var offsetImage   = new OffsetImage(_image, offset);
            var sikuliCommand = offsetImage.ToSikuliScript("doubleClick", 0);

            _mockRuntime.Setup(r => r.Run(sikuliCommand, 0)).Callback(() => _invokeCount++);

            IScreen screen = new Screen(_mockRuntime.Object);

            screen.DoubleClick(_image, offset);

            _invokeCount.Should().Be(1);
        }
Ejemplo n.º 4
0
        private BitmapSource Crop(BitmapSource image, AowImage imageData)
        {
            OffsetImage offsetData = imageData as OffsetImage;

            if (offsetData != null)
            {
                Int32Rect rect = new Int32Rect(offsetData.DataOffsetX, offsetData.DataOffsetY, offsetData.DataWidth, offsetData.DataHeight);
                image = new CroppedBitmap(image, rect);
            }

            if (image.Format == PixelFormats.Bgr565 || image.Format == PixelFormats.Bgr555)
            {
                image = ConvertToAlpha(image, imageData);
            }

            return(image);
        }
Ejemplo n.º 5
0
        public static Bitmap GetStringBitmap(string content, Font font, Color color, Size size)
        {
            int      x = 0, y = 0;
            Graphics gmp = Graphics.FromImage(new Bitmap(1, 1));

            if (size == Size.Empty)
            {
                size = gmp.MeasureString(content, font).ToSize();
            }
            Bitmap pic = new Bitmap(size.Width, size.Height);
            //OffsetImage oi = OffsetImage.New(pic);

            Graphics     g = Graphics.FromImage(pic);
            Random       r = new Random();
            RotateMatrix rm;
            Brush        fill;

            //g.FillRectangle(Brushes.Wheat, 0, 0, pic.Width, pic.Height);
            foreach (char c in content)
            {
                string ch     = new string(c, 1);
                int    width  = (int)gmp.MeasureString(ch, font).Width;
                int    height = (int)gmp.MeasureString(ch, font).Height;

                float angle = r.Next(-35, 35);
                fill = new LinearGradientBrush(new Point(x, y), new Point(pic.Width / 2, pic.Height / 2), color, Color.Wheat);
                rm   = RenderHelper.Rotate(angle, width / 2, height / 2, x, y);

                x += width / 5 * 3;
                y  = r.Next(-pic.Height / 7, pic.Height / 7);

                OffsetImage oi = OffsetImage.New(new Bitmap(size.Width, size.Height));
                RenderHelper.DrawString(ref oi, ch, font, fill, rm);
                RenderHelper.DrawImage(g, oi);
                oi.Dispose();
                //g.Transform = rm.Matrix;
                //g.DrawString(new string(c, 1), font, fill, new PointF(x, y));
                fill.Dispose();
            }
            gmp.Dispose();
            g.Dispose();
            return(pic);
        }