일부 이미지가 포함 된 캔버스가 있으며, DrawGeometry를 사용하여 시간이 경과하면 채우는 원을 그립니다.WPF DrawingContext가 내 객체 뒤에 그려집니다.
이 내가 내 DrawingContext에서 원 그리기 방법은 다음과 같습니다
protected override void OnRender(DrawingContext drawingContext)
{
base.OnRender(drawingContext);
MyUtils.RenderProgressClock(drawingContext, clockPosition, 50, gameTime/totalTime);
}
그리고)합니다 (InvalidateVisual를 호출을; 그것을 부르는 것.
하지만이 내 서클은 내 이미지 뒤에 있으며 볼 수 없습니다. 어떻게 그 이미지를 그 앞으로 가져갈 수 있습니까?
임 완전히 WPF에 새와는 .... 나에게 힘든 시간을 제공
이 요청에 따라 다른 방법 코드입니다 : 내가 조금 더 잘 이해하는 것이 지금
private static PathGeometry GetClockGeometry(Point position, double percentage, double radius)
{
const double innerFactor = 0.90;
double innerRadius = radius * innerFactor;
PathGeometry pie = new PathGeometry();
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = new Point(0, -innerRadius);
pathFigure.IsClosed = true;
if (percentage > kMaxClockPercentage)
{
percentage = kMaxClockPercentage;
}
double angle = 360.0 * percentage;
// Starting Point
LineSegment inOutLine = new LineSegment(new Point(0, -radius), true);
// Arc
ArcSegment outerArc = new ArcSegment();
outerArc.IsLargeArc = angle >= 180.0;
outerArc.Point = new Point(Math.Cos((angle - 90) * Math.PI/180.0) * radius, Math.Sin((angle - 90) * Math.PI/180.0) * radius);
outerArc.Size = new Size(radius, radius);
outerArc.SweepDirection = SweepDirection.Clockwise;
LineSegment outInLine = new LineSegment(new Point(outerArc.Point.X * innerFactor, outerArc.Point.Y * innerFactor), true);
ArcSegment innerArc = new ArcSegment();
innerArc.IsLargeArc = angle >= 180.0;
innerArc.Point = pathFigure.StartPoint;
innerArc.Size = new Size(innerRadius, innerRadius);
innerArc.SweepDirection = SweepDirection.Counterclockwise;
pathFigure.Segments.Add(inOutLine);
pathFigure.Segments.Add(outerArc);
pathFigure.Segments.Add(outInLine);
pathFigure.Segments.Add(innerArc);
pie.Transform = new TranslateTransform(position.X, position.Y);
pie.Figures.Add(pathFigure);
return pie;
}
여기서 [_TimeLayer]는 [Panel.ZIndex] (http://msdn.microsoft.com/en-us/library/system.windows.)를 설정하지 않는 한 * 위에 '* _ImageLayer'가 선언되어야합니다. controls.panel.zindex (v = vs.110) .aspx). – Clemens
오버 라이드 된 OnRender의 경우 상위 컨트롤은 캔버스 일 필요는 없습니다. 간단한 UIElement 일 수 있습니다. – Clemens
그래, 나는 그걸 뒤로했다. 너무 빨리하는 것. 감사 Clemens – Tim