protected override PathGeometry GetPathGeometry(SweepSection s, RenderTarget t) { var pbegin = CalIntersectionPoint(s.Begin + RotateAngle); var pend = CalIntersectionPoint(s.End + RotateAngle); PathGeometry sweepSectionGraphic = t.Factory.CreatePathGeometry(); GeometrySink gs = sweepSectionGraphic.Open(); Point2F oPoint = ReferenceSystem.ScreenOriginalPoint.ToPoint2F(); gs.BeginFigure(oPoint, FigureBegin.Filled); gs.AddLine(pbegin.ToPoint2F()); //扇形的X轴Y轴半径是矩形框width的一半 SizeF size = new SizeF((float)ReferenceSystem.ScreenWidth / 2, (float)ReferenceSystem.ScreenWidth / 2); //添加弧线 ArcSegment arc = new ArcSegment(pend.ToPoint2F(), size, 0, SweepDirection.Clockwise, ArcSize.Small); gs.AddArc(arc); //添加第二条线 gs.AddLine(oPoint); gs.EndFigure(FigureEnd.Closed); gs.Close(); gs.Dispose(); return(sweepSectionGraphic); }
public override PathGeometry BuildWaveGateGeometry(Point2F position1, Point2F position2) { Point2F innerLeft, outterLeft, outterRight, innerRight; PathGeometry waveGate = Factory.CreatePathGeometry(); float mouseBeginAngle = Tools.AngleToNorth(OriginalPoint, position1); float mouseEndAngle = Tools.AngleToNorth(OriginalPoint, position2); float begin = Tools.FindSmallArcBeginAngle(mouseBeginAngle, mouseEndAngle); float end = Tools.FindSmallArcEndAngle(mouseBeginAngle, mouseEndAngle); float mouseBeginDis = (float)Tools.DistanceBetween(OriginalPoint, position1); float mouseEndDis = (float)Tools.DistanceBetween(OriginalPoint, position2); Point2F mouseBeginZoomed = RadiusWiseZoomPosition(position1, mouseEndDis); Point2F mouseDragZoomed = RadiusWiseZoomPosition(position2, mouseBeginDis); if (begin == mouseBeginAngle) //扇形在鼠标点击一侧开始顺时针扫过 { if (mouseBeginDis < mouseEndDis) //鼠标向外拖 { innerLeft = position1; outterLeft = mouseBeginZoomed; outterRight = position2; innerRight = mouseDragZoomed; } else //鼠标向内拖 { innerLeft = mouseBeginZoomed; outterLeft = position1; outterRight = mouseDragZoomed; innerRight = position2; } } else //扇形在鼠标拖动一侧开始顺时针扫过 { if (mouseBeginDis < mouseEndDis) //鼠标向外拖 { innerLeft = mouseDragZoomed; outterLeft = position2; outterRight = mouseBeginZoomed; innerRight = position1; } else //鼠标向内拖 { innerLeft = position2; outterLeft = mouseDragZoomed; outterRight = position1; innerRight = mouseBeginZoomed; } } GeometrySink gs = waveGate.Open(); gs.BeginFigure(innerLeft, FigureBegin.Filled); gs.AddLine(outterLeft); float disMax = Math.Max(mouseBeginDis, mouseEndDis); float disMin = Math.Min(mouseBeginDis, mouseEndDis); Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF size = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF(disMax, disMax); ArcSegment arc = new ArcSegment(outterRight, size, 0, SweepDirection.Clockwise, ArcSize.Small); gs.AddArc(arc); gs.AddLine(innerRight); size = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF(disMin, disMin); arc = new ArcSegment(innerLeft, size, 0, SweepDirection.Counterclockwise, ArcSize.Small); gs.AddArc(arc); gs.EndFigure(FigureEnd.Closed); gs.Close(); return(waveGate); }
public static PathGeometry GetPathGeometry(RenderTarget t, PointF OriginalPoint, PointF p1, PointF p2) { Point2F innerLeft, outterLeft, outterRight, innerRight; PathGeometry waveGate = t.Factory.CreatePathGeometry(); double mouseBeginAngle = Functions.AngleToNorth(OriginalPoint, p1); double mouseEndAngle = Functions.AngleToNorth(OriginalPoint, p2); double begin = Functions.FindSmallArcBeginAngle(mouseBeginAngle, mouseEndAngle); double end = Functions.FindSmallArcEndAngle(mouseBeginAngle, mouseEndAngle); double mouseBeginDis = (float)Functions.DistanceBetween(OriginalPoint.ToPoint2F(), p1.ToPoint2F()); double mouseEndDis = (float)Functions.DistanceBetween(OriginalPoint.ToPoint2F(), p2.ToPoint2F()); Point2F mouseBeginZoomed = RadiusWiseZoomPosition(p1, mouseEndDis, OriginalPoint); Point2F mouseDragZoomed = RadiusWiseZoomPosition(p2, mouseBeginDis, OriginalPoint); if (begin == mouseBeginAngle) //扇形在鼠标点击一侧开始顺时针扫过 { if (mouseBeginDis < mouseEndDis) //鼠标向外拖 { innerLeft = p1.ToPoint2F(); outterLeft = mouseBeginZoomed; outterRight = p2.ToPoint2F(); innerRight = mouseDragZoomed; } else //鼠标向内拖 { innerLeft = mouseBeginZoomed; outterLeft = p1.ToPoint2F(); outterRight = mouseDragZoomed; innerRight = p2.ToPoint2F(); } } else //扇形在鼠标拖动一侧开始顺时针扫过 { if (mouseBeginDis < mouseEndDis) //鼠标向外拖 { innerLeft = mouseDragZoomed; outterLeft = p2.ToPoint2F(); outterRight = mouseBeginZoomed; innerRight = p1.ToPoint2F(); } else //鼠标向内拖 { innerLeft = p2.ToPoint2F(); outterLeft = mouseDragZoomed; outterRight = p1.ToPoint2F(); innerRight = mouseBeginZoomed; } } GeometrySink gs = waveGate.Open(); gs.BeginFigure(innerLeft, FigureBegin.Filled); gs.AddLine(outterLeft); double disMax = Math.Max(mouseBeginDis, mouseEndDis); double disMin = Math.Min(mouseBeginDis, mouseEndDis); Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF size = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF((float)disMax, (float)disMax); ArcSegment arc = new ArcSegment(outterRight, size, 0, SweepDirection.Clockwise, ArcSize.Small); gs.AddArc(arc); gs.AddLine(innerRight); size = new Microsoft.WindowsAPICodePack.DirectX.Direct2D1.SizeF((float)disMin, (float)disMin); arc = new ArcSegment(innerLeft, size, 0, SweepDirection.Counterclockwise, ArcSize.Small); gs.AddArc(arc); gs.EndFigure(FigureEnd.Closed); gs.Close(); gs.Dispose(); return(waveGate); }