예제 #1
0
        public IPathGeometry CreatePathGeometry(ITransform?transformInterface, IEnumerable <IPathFigure> figures, FillRule fillRule)
        {
            var pathGeometry = new PathGeometry()
            {
                FillRule = fillRule
            };

            if (transformInterface != null)
            {
                if (!(transformInterface is Transform transform))
                {
                    throw new InvalidOperationException($"Transforms should all be of type {nameof(Transform)}");
                }

                pathGeometry.Transform = transform;
            }

            GraphicsObjectCollection <PathFigure> destinationFigures = pathGeometry.Figures;

            foreach (IPathFigure pathFigureInterface in figures)
            {
                if (!(pathFigureInterface is PathFigure pathFigure))
                {
                    throw new InvalidOperationException($"{nameof(CreatePathGeometry)} figures should all be of type {nameof(PathFigure)}");
                }

                destinationFigures.Add(pathFigure);
            }

            return(pathGeometry);
        }
예제 #2
0
        public XCanvas()
        {
            designMode        = DesignerProperties.GetIsInDesignMode(this);
            Children          = new GraphicsObjectCollection <GraphicsElement>();
            Children.Changed += OnSubobjectChanged;

            // If anything in the hierarchy changes, invalidate to trigger a redraw
            Changed += Invalidate;
        }
예제 #3
0
        public IPathFigure CreatePathFigure(IEnumerable <IPathSegment> segments, Point startPoint, bool isClosed, bool isFilled)
        {
            var pathFigure = new PathFigure()
            {
                StartPoint = new Wrapper.Point(startPoint),
                IsClosed   = isClosed,
                IsFilled   = isFilled
            };

            GraphicsObjectCollection <PathSegment> destinationSegments = pathFigure.Segments;

            foreach (IPathSegment pathSegmentInterface in segments)
            {
                if (!(pathSegmentInterface is PathSegment pathSegment))
                {
                    throw new InvalidOperationException($"{nameof(CreatePathFigure)} segments should all be of type {nameof(PathSegment)}");
                }

                destinationSegments.Add(pathSegment);
            }

            return(pathFigure);
        }
예제 #4
0
 public PathFigure()
 {
     Segments          = new GraphicsObjectCollection <PathSegment>();
     Segments.Changed += OnSubobjectChanged;
 }
예제 #5
0
 public PathGeometry()
 {
     Figures          = new GraphicsObjectCollection <PathFigure>();
     Figures.Changed += OnSubobjectChanged;
 }
예제 #6
0
 public GradientBrush()
 {
     GradientStops          = new GraphicsObjectCollection <GradientStop>();
     GradientStops.Changed += OnSubobjectChanged;
 }
예제 #7
0
 public Canvas()
 {
     Children          = new GraphicsObjectCollection <GraphicsElement>();
     Children.Changed += OnSubobjectChanged;
 }
예제 #8
0
 public TransformGroup()
 {
     Children          = new GraphicsObjectCollection <Transform>();
     Children.Changed += OnSubobjectChanged;
 }