Exemplo n.º 1
0
        public void PolylinePoint_create(float x, float y)
        {
            var point = PolylinePoint.Create(x, y);

            Assert.AreEqual(x, point.X);
            Assert.AreEqual(y, point.Y);
        }
Exemplo n.º 2
0
        public void Polyline(string behaviorName, LineCapType lineCap, LineJoinType lineJoin)
        {
            var random = new Random();

            _mockBehaviorResolver
            .Setup(resolver => resolver.GetBehaviorHandler(behaviorName))
            .Returns(() =>
            {
                return(new DrawContentBehavior(_sciterWindow, (element, prms) =>
                {
                    if (prms.DrawEvent != DrawEvent.Content)
                    {
                        return false;
                    }

                    using (var graphics = SciterGraphics.Create(prms.Handle))
                    {
                        for (var i = 0; i < byte.MaxValue; i++)
                        {
                            graphics.SaveState()
                            .Translate(prms.Area.Left, prms.Area.Top)
                            .SetLineColor(
                                (byte)random.Next(byte.MinValue, byte.MaxValue),
                                (byte)random.Next(byte.MinValue, byte.MaxValue),
                                (byte)random.Next(byte.MinValue, byte.MaxValue),
                                (byte)random.Next(byte.MinValue, byte.MaxValue))
                            .SetLineCap(lineCap)
                            .SetLineJoin(lineJoin)
                            .SetLineWidth(random.Next(2, 10))
                            .DrawPolyline(() =>
                            {
                                var result = new List <PolylinePoint>();
                                for (var j = 0; j < random.Next(3, 12); j++)
                                {
                                    result.Add(PolylinePoint.Create(
                                                   random.Next(byte.MinValue, prms.Area.Width),
                                                   random.Next(byte.MinValue, prms.Area.Height)));
                                }
                                return result;
                            })
                            .RestoreState();
                        }
                    }

                    element?.Window?.Close();

                    return true;
                }));
            });

            _ = new TestableSciterHost(_sciterWindow)
                .SetBehaviorResolver(_mockBehaviorResolver.Object);

            _sciterWindow.Show();

            var backgroundColor = random.Next(byte.MinValue, 80);

            _sciterWindow.RootElement.AppendElement("body", elm => elm)
            .SetStyleValue("background", $"rgb({backgroundColor}, {backgroundColor}, {backgroundColor})")
            .SetStyleValue("behavior", behaviorName);

            SciterPlatform.RunMessageLoop();

            //Assert.NotNull(_sciterGraphics);
        }