Пример #1
0
 /// <summary>
 /// 使用当前的路径填充指定的路径几何。
 /// </summary>
 /// <param name="sink">要填充的路径几何。</param>
 public override void FillGeometry(GeometrySink sink)
 {
     D2D1.ArcSegment arc = new D2D1.ArcSegment()
     {
         Point          = EndPoint,
         Size           = Size,
         RotationAngle  = RotationAngle,
         SweepDirection = SweepDirection,
         ArcSize        = ArcSize
     };
     sink.AddArc(arc);
 }
Пример #2
0
		/// <summary>
		/// 使用当前的路径填充指定的路径几何。
		/// </summary>
		/// <param name="sink">要填充的路径几何。</param>
		public override void FillGeometry(GeometrySink sink)
		{
			D2D1.ArcSegment arc = new D2D1.ArcSegment()
			{
				Point = EndPoint,
				Size = Size,
				RotationAngle = RotationAngle,
				SweepDirection = SweepDirection,
				ArcSize = ArcSize
			};
			sink.AddArc(arc);
		}
            //---------------------------------------------------------------------------------------------------------
            /// <summary>
            /// Обновление данных арки
            /// </summary>
            //---------------------------------------------------------------------------------------------------------
            public override void Update()
            {
                XDisposer.SafeDispose(ref mD2DGeometry);
                mD2DGeometry     = new Direct2D.PathGeometry(XDirect2DManager.D2DFactory);
                mD2DGeometrySink = mD2DGeometry.Open();

                mD2DGeometrySink.BeginFigure(mStartPoint.ToRawVector2(), mIsFilled ? Direct2D.FigureBegin.Filled : Direct2D.FigureBegin.Hollow);

                Direct2D.ArcSegment arc_segment = new Direct2D.ArcSegment();
                arc_segment.ArcSize        = mIsLargeArc ? Direct2D.ArcSize.Large : Direct2D.ArcSize.Small;
                arc_segment.Point          = mEndPoint.ToRawVector2();
                arc_segment.RotationAngle  = mRotationAngle;
                arc_segment.Size           = new SharpDX.Size2F(mRadiusX, mRadiusY);
                arc_segment.SweepDirection = mIsClockwiseDirection ? Direct2D.SweepDirection.Clockwise : Direct2D.SweepDirection.CounterClockwise;

                mD2DGeometrySink.AddArc(arc_segment);

                mD2DGeometrySink.EndFigure(mIsClosed ? Direct2D.FigureEnd.Closed : Direct2D.FigureEnd.Open);
                mD2DGeometrySink.Close();

                XDisposer.SafeDispose(ref mD2DGeometrySink);
                mBoundsRect = mD2DGeometry.GetWidenedBounds(2).ToRect();
            }
Пример #4
0
            //---------------------------------------------------------------------------------------------------------
            /// <summary>
            /// Обновление данных геометрии
            /// </summary>
            //---------------------------------------------------------------------------------------------------------
            public override void Update()
            {
                XDisposer.SafeDispose(ref mD2DGeometry);
                mD2DGeometry     = new Direct2D.PathGeometry(XDirect2DManager.D2DFactory);
                mD2DGeometrySink = mD2DGeometry.Open();

                CCadSegment current_figure = mSegments[0];

                mD2DGeometrySink.BeginFigure(current_figure.BasePoint.ToRawVector2(), current_figure.IsFilled ? Direct2D.FigureBegin.Filled :
                                             Direct2D.FigureBegin.Hollow);

                Int32 current_new_figure = 0;

                for (Int32 i = 0; i < mSegments.Count; i++)
                {
                    CCadSegment current_segment = mSegments[i];

                    // Если новая фигура
                    if (current_segment.IsNewFigure && current_new_figure != i)
                    {
                        // Закрывает текущую фигуру
                        mD2DGeometrySink.EndFigure(current_figure.IsClosed ? Direct2D.FigureEnd.Closed : Direct2D.FigureEnd.Open);

                        // Открываем новую фигуру
                        mD2DGeometrySink.BeginFigure(current_segment.BasePoint.ToRawVector2(),
                                                     current_segment.IsFilled ? Direct2D.FigureBegin.Filled : Direct2D.FigureBegin.Hollow);

                        current_figure     = current_segment;
                        current_new_figure = i;
                    }

                    switch (current_segment.SegmentType)
                    {
                    case TCadSegmentType.Points:
                    {
                        CCadSegmentPoints points = current_segment as CCadSegmentPoints;
                        mD2DGeometrySink.AddLines(points.Points.ConvertToDirect2DRawVectors());
                    }
                    break;

                    case TCadSegmentType.Line:
                    {
                        CCadSegmentLine line = current_segment as CCadSegmentLine;
                        mD2DGeometrySink.AddLine(line.EndPoint.ToRawVector2());
                    }
                    break;

                    case TCadSegmentType.Arc:
                    {
                        CCadSegmentArc      arc         = current_segment as CCadSegmentArc;
                        Direct2D.ArcSegment arc_segment = new Direct2D.ArcSegment();

                        arc_segment.ArcSize        = arc.mIsLargeArc ? Direct2D.ArcSize.Large : Direct2D.ArcSize.Small;
                        arc_segment.Point          = arc.mEndPoint.ToRawVector2();
                        arc_segment.RotationAngle  = arc.mRotationAngle;
                        arc_segment.Size           = new Size2F(arc.mRadiusX, arc.mRadiusY);
                        arc_segment.SweepDirection = arc.mIsClockwiseDirection ? Direct2D.SweepDirection.Clockwise : Direct2D.SweepDirection.CounterClockwise;

                        mD2DGeometrySink.AddArc(arc_segment);
                    }
                    break;

                    case TCadSegmentType.Bezier:
                        break;

                    default:
                        break;
                    }
                }

                // Закрывает текущую фигуру
                mD2DGeometrySink.EndFigure(current_figure.IsClosed ? Direct2D.FigureEnd.Closed : Direct2D.FigureEnd.Open);

                mD2DGeometrySink.Close();

                XDisposer.SafeDispose(ref mD2DGeometrySink);
                mBoundsRect = mD2DGeometry.GetWidenedBounds(2).ToRect();
            }