Path geometry.
상속: ObservableObject
예제 #1
0
        public void ToString_Should_Return_Path_Markup_Empty_Nonzero()
        {
            var target = new XPathGeometry();

            var actual = target.ToString();

            Assert.Equal("F1", actual);
        }
예제 #2
0
        public void ToString_Should_Return_Path_Markup_Empty_EvenOdd()
        {
            var target = new XPathGeometry() { FillRule = XFillRule.EvenOdd };

            var actual = target.ToString();

            Assert.Equal("", actual);
        }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XPathGeometryContext"/> class.
        /// </summary>
        public XPathGeometryContext(XPathGeometry geometry)
        {
            if (geometry == null)
            {
                throw new ArgumentNullException(nameof(geometry));
            }

            _geometry = geometry;
        }
예제 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="XPathGeometryContext"/> class.
        /// </summary>
        public XPathGeometryContext(XPathGeometry geometry)
        {
            if (geometry == null)
            {
                throw new ArgumentNullException(nameof(geometry));
            }

            _geometry = geometry;
        }
예제 #5
0
        public void ToString_Should_Return_Empty()
        {
            var geometry = new XPathGeometry();

            var target = ImmutableArray.Create<XPathFigure>();
            var actual = geometry.ToString(target);

            Assert.Equal(string.Empty, actual);
        }
예제 #6
0
        public void BeginFigure_Adds_New_Figure()
        {
            var geometry = new XPathGeometry();
            var target = new XPathGeometryContext(geometry);
            Assert.Equal(0, geometry.Figures.Length);

            target.BeginFigure(new XPoint());
            Assert.Equal(1, geometry.Figures.Length);
            Assert.True(geometry.Figures[0].IsFilled);
            Assert.True(geometry.Figures[0].IsClosed);

            target.SetClosedState(false);
            Assert.False(geometry.Figures[0].IsClosed);
        }
예제 #7
0
        public void CubicBezierTo_Adds_New_XCubicBezierSegment()
        {
            var geometry = new XPathGeometry();
            var target = new XPathGeometryContext(geometry);
            target.BeginFigure(new XPoint());
            Assert.Equal(0, geometry.Figures[0].Segments.Length);

            target.CubicBezierTo(new XPoint(), new XPoint(), new XPoint());
            Assert.Equal(1, geometry.Figures[0].Segments.Length);

            var segment = geometry.Figures[0].Segments[0];
            Assert.IsType<XCubicBezierSegment>(segment);
            Assert.True(segment.IsStroked);
            Assert.True(segment.IsSmoothJoin);
        }
예제 #8
0
        private void Remove(XPathGeometry geometry)
        {
            if (geometry == null)
                return;

            geometry.PropertyChanged -= ObserveShape;

            if (geometry.Figures != null)
            {
                Remove(geometry.Figures);
            }
        }
예제 #9
0
        private void Add(XPathGeometry geometry)
        {
            if (geometry == null)
                return;

            geometry.PropertyChanged += ObserveShape;

            if (geometry.Figures != null)
            {
                Add(geometry.Figures);
            }
        }
예제 #10
0
        public void PolyQuadraticBezierTo_Adds_New_XPolyQuadraticBezierSegment()
        {
            var geometry = new XPathGeometry();
            var target = new XPathGeometryContext(geometry);
            target.BeginFigure(new XPoint());
            Assert.Equal(0, geometry.Figures[0].Segments.Length);

            target.PolyQuadraticBezierTo(ImmutableArray.Create<XPoint>(new XPoint(), new XPoint(), new XPoint()));
            Assert.Equal(1, geometry.Figures[0].Segments.Length);

            var segment = geometry.Figures[0].Segments[0];
            Assert.IsType<XPolyQuadraticBezierSegment>(segment);
            Assert.True(segment.IsStroked);
            Assert.True(segment.IsSmoothJoin);
        }
예제 #11
0
 public void FillRule_Set_To_Nonzero_By_Default()
 {
     var target = new XPathGeometry();
     Assert.Equal(XFillRule.Nonzero, target.FillRule);
 }
예제 #12
0
 public void Figures_Not_Null()
 {
     var target = new XPathGeometry();
     Assert.NotNull(target.Figures);
 }
예제 #13
0
파일: XPath.cs 프로젝트: Core2D/Core2D
 /// <summary>
 /// Creates a new <see cref="XPath"/> instance.
 /// </summary>
 /// <param name="name">The shape name.</param>
 /// <param name="style">The shape style.</param>
 /// <param name="geometry">The path geometry.</param>
 /// <param name="isStroked">The flag indicating whether shape is stroked.</param>
 /// <param name="isFilled">The flag indicating whether shape is filled.</param>
 /// <returns>The new instance of the <see cref="XPath"/> class.</returns>
 public static XPath Create(string name, ShapeStyle style, XPathGeometry geometry, bool isStroked = true, bool isFilled = true)
 {
     return new XPath()
     {
         Name = name,
         Style = style,
         IsStroked = isStroked,
         IsFilled = isFilled,
         Geometry = geometry
     };
 }
예제 #14
0
 /// <inheritdoc/>
 XPath IShapeFactory.Path(XPathGeometry geometry, bool isStroked, bool isFilled)
 {
     var style = _editor.Project.CurrentStyleLibrary.Selected;
     var path = XPath.Create(
         "",
         _editor.Project.Options.CloneStyle ? style.Clone() : style,
         geometry,
         isStroked,
         isFilled);
     _editor.Project.AddShape(_editor.Project.CurrentContainer.CurrentLayer, path);
     return path;
 }