이 질문에 이전에 물어 보지 않았 으면 좋겠어.WPF DrawGeometry가 획을 그리지 않는다
내 문제는 점이있는 내 wpf usercontrol에서 좌표 집합을 그려야한다는 것입니다. 배경색을 사용하여 다각형을 채우지 만 스트로크는 채울 수 없었습니다. 어떤 이유로 스토킹이 그립지 않아? 여기
자세히StreamGeometry streamGeometry = 새로운 StreamGeometry를
System.Windows.Media.Pen penDrawing = new System.Windows.Media.Pen(System.Windows.Media.Brushes.OrangeRed, 2);
drawingContext.DrawGeometry(System.Windows.Media.Brushes.LightSeaGreen, penDrawing, streamGeometry);
코드를 DrawingContext를 사용하여의 OnRender 이벤트에 내 코드()입니다;
System.Windows.Point firstCoordinate = new System.Windows.Point();
System.Windows.Point lastCoordinateAdded = new System.Windows.Point();
bool isMainPolygon = true;
using (StreamGeometryContext geometryContext = streamGeometry.Open())
{
PointCollection points = new PointCollection();
firstCoordinate = new System.Windows.Point(coordinatePoints.ProjectedCoordinates[0].X, coordinatePoints.ProjectedCoordinates[0].Y);
geometryContext.BeginFigure(firstCoordinate, true, true);
System.Windows.Media.Pen penDrawing = new System.Windows.Media.Pen(System.Windows.Media.Brushes.OrangeRed, 5);
penDrawing.EndLineCap = PenLineCap.Round;
penDrawing.DashCap = PenLineCap.Round;
penDrawing.LineJoin = PenLineJoin.Round;
penDrawing.StartLineCap = PenLineCap.Round;
penDrawing.MiterLimit = 10.0;
for (int i = 1; i < coordinatePoints.ProjectedCoordinates.Count; i++)
{
lastCoordinateAdded = new System.Windows.Point() { X = coordinatePoints.ProjectedCoordinates[i].X, Y = coordinatePoints.ProjectedCoordinates[i].Y };
points.Add(lastCoordinateAdded);
//////Check to see if Polygon is done drawing
if (firstCoordinate == lastCoordinateAdded)
{
geometryContext.PolyLineTo(points, true, true);
//drawingContext.DrawGeometry(isMainPolygon ? System.Windows.Media.Brushes.Green : System.Windows.Media.Brushes.White, pen, streamGeometry);
streamGeometry.Freeze();
drawingContext.DrawGeometry(null, penDrawing, streamGeometry);
points = new PointCollection();
streamGeometry = new StreamGeometry();
if (i + 1 < coordinatePoints.ProjectedCoordinates.Count)
{
i++;
isMainPolygon = false;
firstCoordinate = new System.Windows.Point(coordinatePoints.ProjectedCoordinates[i].X, coordinatePoints.ProjectedCoordinates[i].Y);
geometryContext.BeginFigure(firstCoordinate, true, true);
}
}
}
geometryContext.PolyLineTo(points, true, true);
}
coordinatePoints.State = Enums.CoordinateEnum.None;
}
다행 자세한 내용을 제공 할 것입니다.
감사합니다.
보이지 않는 OrangeRed가 있습니까? 크기가 2보다 커지면 어떨까요? – Rui
@Rui 기하학을 생성하는 코드를보고 싶습니다. 스트로크하도록 설정된 그림 세그먼트입니까? – Gusdor
형상의 범위는 무엇입니까? 나는 스트로크 너비가 보이지 않게되는 정도에 맞추기 위해 스트로크 너비가 너무 작아 질 수 있다고 생각합니다. –