나는 DrawingVisual 개체를 가지고 있으며 채우기 및 획을 변경하고 싶습니다.DrawingVisual 채우기 및 획 바꾸는 방법
나는 채우기 위해 이것을 시도했다 : SetFill는
DrawingVisual MyDrawing = new DrawingVisual();
SetFill(Brushes.Red, MyDrawing.Drawing);
입니다
여기서private void SetFill(Brush fill, DrawingGroup group)
{
foreach (Drawing drw in group.Children)
{
if (drw is DrawingGroup)
SetFill(fill, drw as DrawingGroup);
else if (drw is GeometryDrawing)
{
GeometryDrawing geo = drw as GeometryDrawing;
geo.Brush = fill;
using (DrawingContext context = MyDrawing.RenderOpen())
{
context.DrawDrawing(group);
}
}
}
}
그러나이 방법으로
내 DrawingVisual과는 다른 위치로 그려지는 경우가 발생할 수의 변환 마치 더 이상 (MyDrawing에) 적용되지 않았습니다. 이 서로context.DrawDrawing(group);
: :이 명령 변경하는 경우
또한, context.DrawDrawing(MyDrawing.Drawing);
을 나는 이상한 효과를 얻을 : 내가 처음에 아무 변화가없는 기입 변경하는 경우 채우기가의 위치를 변경하지 않고 올바르게 변경되는 초 동안 그 그림.
어떻게하면됩니까?
** 다시 그리기없이 ** GeometryDrawing.Brush'를 재귀 적으로 설정하려고 했습니까? – Clemens
예, 불행히도 효과가 없습니다. – gliderkite
"SetFillEx"를 호출 할 때마다 기존 DrawingGroup을 새 DrawingGroup의 Children 컬렉션에 넣으므로 "추한 솔루션"이 점점 더 많은 드로잉에 포함될 것입니다. – Clemens