기하학을 그리는 브러시를 만들려고했습니다. Dashing을 셰이프에 추가하려고 할 때까지 모든 것이 잘 동작했습니다.펜에 Null 이외의 DashStyle이있을 때 래스터 화되지 않는 StreamGeometry
Geometry.Parse를 사용하여 지오메트리를 만들면 점선이 올바르게 표시되지만 StreamGeometryContext를 사용하여 직접 만들면 아무 것도 렌더링되지 않습니다.
그런 식으로 일을private void RenderGeometryAndSetAsBackground()
{
Point startPoint = new Point(3505961.52400725, 3281436.57325874);
Point[] points = new Point[] {
new Point(3503831.75515445,3278705.9649394),
new Point(3503905.74802898,3278449.37713916),
new Point(3507242.57331039,3276518.41148474),
new Point(3507700.6914325,3276536.23547958),
new Point(3510146.73449577,3277964.12812859),
new Point(3509498.96473447,3278678.60178448),
new Point(3507412.1889951,3277215.64022219),
new Point(3504326.22698001,3278682.85514017),
new Point(3506053.34789057,3281390.66371786)};
string geom = "M3505961.52400725,3281436.57325874L3503831.75515445,3278705.9649394 3503905.74802898,3278449.37713916 3507242.57331039,3276518.41148474 3507700.6914325,3276536.23547958 3510146.73449577,3277964.12812859 3509498.96473447,3278678.60178448 3507412.1889951,3277215.64022219 3504326.22698001,3278682.85514017 3506053.34789057,3281390.66371786";
//Geometry geometry = StreamGeometry.Parse(geom);
StreamGeometry geometry = new StreamGeometry();
using (StreamGeometryContext sgc = geometry.Open())
{
sgc.BeginFigure(startPoint, false, true);
foreach (Point p in points)
{
sgc.LineTo(p, true, true);
}
}
Pen pen = new Pen(Brushes.Yellow, 3);
pen.DashStyle = new DashStyle(new double[] { 30, 30 }, 0);
//GeometryDrawing gd = new GeometryDrawing(null, pen, path.RenderedGeometry);
GeometryDrawing gd = new GeometryDrawing(null, pen, geometry);
DrawingBrush drawingBrush = new DrawingBrush(gd);
DrawingBrush tile = drawingBrush.Clone();
tile.Viewbox = new Rect(0.5, 0, 0.25, 0.25);
RenderTargetBitmap rtb = new RenderTargetBitmap(256, 256, 96, 96, PixelFormats.Pbgra32);
var drawingVisual = new DrawingVisual();
using (DrawingContext context = drawingVisual.RenderOpen())
{
context.DrawRectangle(tile, null, new Rect(0, 0, 256, 256));
}
rtb.Render(drawingVisual);
ImageBrush bgBrush = new ImageBrush(rtb);
Background = bgBrush;
}
, 아무것도 그려지지지고 :
이
내가 사용하고 코드입니다. 대시를 사용하지 않으면 (또는 null로 대시를 설정하면) 정상적으로 작동합니다.StreamGeometry.Parse(geom)
을 사용하고 돌진을 계속하면 작동합니다.
sgc.Close()
으로 전화를 걸면 도움이되지 않았습니다. 아주 좋은하지 않습니다
geometry = Geometry.Parse(geometry.ToString());
...
내가 무엇을 놓치고을 : 현재 내 유일한 해결 방법은 호출하는 것입니다?