Пример #1
0
 private void Configure()
 {
     _joinType = LineJoinType.Round;
     _startCap = LineCap.Round;
     _endCap = LineCap.Round;
     _decorations = new CopyList<ILineDecoration>();
 }
Пример #2
0
 private void Configure()
 {
     _joinType    = LineJoinType.Round;
     _startCap    = LineCap.Round;
     _endCap      = LineCap.Round;
     _decorations = new CopyList <ILineDecoration>();
 }
Пример #3
0
 private void RadBevelCheckedChanged(object sender, EventArgs e)
 {
     if (radBevel.Checked && _joinType != LineJoinType.Bevel)
     {
         _joinType = LineJoinType.Bevel;
         OnValueChanged();
     }
 }
Пример #4
0
 /// <summary>
 /// Sets the type of line joints
 /// </summary>
 /// <param name="join">Type of the joint</param>
 public void SetJoinType(LineJoinType join)
 {
     if ((int)JoinType != (int)join)
     {
         JoinType   = (JoinType)join;
         HasChanged = true;
     }
 }
Пример #5
0
 private void RadMiterCheckedChanged(object sender, EventArgs e)
 {
     if (radMiter.Checked && _joinType != LineJoinType.Mitre)
     {
         _joinType = LineJoinType.Mitre;
         OnValueChanged();
     }
 }
Пример #6
0
 private void RadRoundCheckedChanged(object sender, EventArgs e)
 {
     if (radRound.Checked && _joinType != LineJoinType.Round)
     {
         _joinType = LineJoinType.Round;
         OnValueChanged();
     }
 }
Пример #7
0
 private ShapeStroke(string name, AnimatableFloatValue offset, IList <AnimatableFloatValue> lineDashPattern, AnimatableColorValue color, AnimatableIntegerValue opacity, AnimatableFloatValue width, LineCapType capType, LineJoinType joinType)
 {
     Name            = name;
     DashOffset      = offset;
     LineDashPattern = lineDashPattern;
     Color           = color;
     Opacity         = opacity;
     Width           = width;
     CapType         = capType;
     JoinType        = joinType;
 }
Пример #8
0
 public ShapeStroke(string name, AnimatableFloatValue offset, List <AnimatableFloatValue> lineDashPattern, AnimatableColorValue color, AnimatableIntegerValue opacity, AnimatableFloatValue width, LineCapType capType, LineJoinType joinType, float miterLimit, bool hidden)
 {
     Name            = name;
     DashOffset      = offset;
     LineDashPattern = lineDashPattern;
     Color           = color;
     Opacity         = opacity;
     Width           = width;
     CapType         = capType;
     JoinType        = joinType;
     MiterLimit      = miterLimit;
     IsHidden        = hidden;
 }
Пример #9
0
        internal static PenLineJoin LineJoinTypeToPaintLineJoin(LineJoinType lineJoinType)
        {
            switch (lineJoinType)
            {
            case LineJoinType.Bevel:
                return(PenLineJoin.Bevel);

            case LineJoinType.Miter:
                return(PenLineJoin.Miter);

            case LineJoinType.Round:
            default:
                return(PenLineJoin.Round);
            }
        }
Пример #10
0
 public LinearGradientStroke(
     string name,
     string matchName,
     Animatable <double> opacityPercent,
     Animatable <double> strokeWidth,
     LineCapType capType,
     LineJoinType joinType,
     double miterLimit)
     : base(name, matchName)
 {
     OpacityPercent = opacityPercent;
     StrokeWidth    = strokeWidth;
     CapType        = capType;
     JoinType       = joinType;
     MiterLimit     = miterLimit;
 }
Пример #11
0
        /// <summary>
        /// Handles the randomization of the cartographic properties of this stroke.
        /// </summary>
        /// <param name="generator">The random class that generates the random numbers.</param>
        protected override void OnRandomize(Random generator)
        {
            base.OnRandomize(generator);
            DashStyle        = DashStyle.Custom;
            _dashCap         = generator.NextEnum <DashCap>();
            _startCap        = generator.NextEnum <LineCap>();
            _endCap          = generator.NextEnum <LineCap>();
            _dashButtons     = generator.NextBoolArray(1, 20);
            _compoundButtons = generator.NextBoolArray(1, 5);
            _offset          = generator.NextFloat(10);
            _joinType        = generator.NextEnum <LineJoinType>();
            int len = generator.Next(0, 1);

            if (len > 0)
            {
                _decorations.Clear();
                LineDecoration ld = new();
                ld.Randomize(generator);
                _decorations.Add(ld);
            }
        }
Пример #12
0
 public SolidColorStroke(
     string name,
     string matchName,
     Animatable <double> dashOffset,
     IEnumerable <double> dashPattern,
     Animatable <Color> color,
     Animatable <double> opacityPercent,
     Animatable <double> thickness,
     LineCapType capType,
     LineJoinType joinType,
     double miterLimit)
     : base(name, matchName)
 {
     DashOffset     = dashOffset;
     _dashPattern   = dashPattern.ToArray();
     Color          = color;
     OpacityPercent = opacityPercent;
     Thickness      = thickness;
     CapType        = capType;
     JoinType       = joinType;
     MiterLimit     = miterLimit;
 }
Пример #13
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);
        }
Пример #14
0
 private void radMiter_CheckedChanged(object sender, EventArgs e)
 {
     if (radMiter.Checked && _joinType != LineJoinType.Mitre)
     {
         _joinType = LineJoinType.Mitre;
         OnValueChanged();
     }
 }
Пример #15
0
 private void radRound_CheckedChanged(object sender, EventArgs e)
 {
     if (radRound.Checked && _joinType != LineJoinType.Round)
     {
         _joinType = LineJoinType.Round;
         OnValueChanged();
     }
 }
Пример #16
0
 private void radBevel_CheckedChanged(object sender, EventArgs e)
 {
     if (radBevel.Checked && _joinType != LineJoinType.Bevel)
     {
         _joinType = LineJoinType.Bevel;
         OnValueChanged();
     }
 }
Пример #17
0
 /// <summary>
 /// Handles the randomization of the cartographic properties of this stroke.
 /// </summary>
 /// <param name="generator">The random class that generates the random numbers</param>
 protected override void OnRandomize(Random generator)
 {
     base.OnRandomize(generator);
     DashStyle = DashStyle.Custom;
     _dashCap = generator.NextEnum<DashCap>();
     _startCap = generator.NextEnum<LineCap>();
     _endCap = generator.NextEnum<LineCap>();
     _dashButtons = generator.NextBoolArray(1, 20);
     _compoundButtons = generator.NextBoolArray(1, 5);
     _offset = generator.NextFloat(10);
     _joinType = generator.NextEnum<LineJoinType>();
     int len = generator.Next(0, 1);
     if (len > 0)
     {
         _decorations.Clear();
         LineDecoration ld = new LineDecoration();
         ld.Randomize(generator);
         _decorations.Add(ld);
     }
 }
 public static bool TrySetLineJoin(this SciterGraphics graphics, LineJoinType joinType)
 {
     return(graphics?.TrySetLineJoinInternal(joinType: joinType) == true);
 }
Пример #19
0
        public void DrawLine_with_lineCap_and_lineJoin(string behaviorName, LineCapType lineCap, LineJoinType lineJoin)
        {
            var random = new Random();

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

                    using (var graphics = SciterGraphics.Create(args.Handle))
                    {
                        for (var i = 0; i < byte.MaxValue; i++)
                        {
                            graphics.SaveState()
                            .Translate(args.Area.Left, args.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))
                            .SetFillColor(
                                (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))
                            .SetLineWidth(random.Next(2, 10))
                            .SetLineCap(lineCap)
                            .SetLineJoin(lineJoin)
                            .DrawLine(random.Next(byte.MinValue, args.Area.Width),
                                      random.Next(byte.MinValue, args.Area.Height),
                                      random.Next(byte.MinValue, args.Area.Width),
                                      random.Next(byte.MinValue, args.Area.Height))
                            .SetLineGradientLinear(
                                0f,
                                0f,
                                args.Area.Width / 2f,
                                args.Area.Height,
                                SciterColorStop.Create(0f,
                                                       (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)),
                                SciterColorStop.Create(.5f,
                                                       (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)),
                                SciterColorStop.Create(1f,
                                                       (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)))
                            .DrawLine(random.Next(byte.MinValue, args.Area.Width),
                                      random.Next(byte.MinValue, args.Area.Height),
                                      random.Next(byte.MinValue, args.Area.Width),
                                      random.Next(byte.MinValue, args.Area.Height))
                            .RestoreState();
                        }
                    }

                    element?.Window?.Close();

                    return true;
                }));
            });

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

            _sciterWindow.Show();

            _sciterWindow.RootElement.AppendElement("body", elm => elm)
            .SetStyleValue("background", $"rgb({random.Next(byte.MinValue, byte.MaxValue)}, {random.Next(byte.MinValue, byte.MaxValue)}, {random.Next(byte.MinValue, byte.MaxValue)})")
            .SetStyleValue("behavior", behaviorName);

            SciterPlatform.RunMessageLoop();

            //Assert.NotNull(_sciterGraphics);
        }
 public static SciterGraphics SetLineJoin(this SciterGraphics graphics, LineJoinType joinType)
 {
     graphics?.SetLineJoinInternal(joinType: joinType);
     return(graphics);
 }