private void DebugLayer_D2DPaint(D2DGraphics g) { g.RenderTarget.AntialiasMode = AntialiasMode.PerPrimitive; RawRectangleF rect = new RawRectangleF(1, 1, Width - 1, Height - 1); RawColor4 rawColor = GDIDataD2DUtils.TransToRawColor4(Color.DarkBlue); SolidColorBrush brush = new SolidColorBrush(g.RenderTarget, rawColor); //宽度 TextFormat textFormat = new TextFormat(D2DGraphics.dwriteFactory, "微软雅黑", 12) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center }; RawRectangleF rectw = new RawRectangleF(0, Height - 20, Width - 1, Height - 1); g.RenderTarget.DrawText(Width.ToString(), textFormat, rectw, brush); //高度 TextFormat textFormat2 = new TextFormat(D2DGraphics.dwriteFactory, "微软雅黑", 12) { TextAlignment = TextAlignment.Center, ParagraphAlignment = ParagraphAlignment.Center, FlowDirection = SharpDX.DirectWrite.FlowDirection.TopToBottom }; RawRectangleF recth = new RawRectangleF(Width - 10, 0, Width - 1, Height - 1); g.RenderTarget.DrawText(Height.ToString(), textFormat2, recth, brush); //全局坐标位置 PointF pt = parent.TransLocalToGlobal(Location); textFormat.ParagraphAlignment = ParagraphAlignment.Near; textFormat.TextAlignment = TextAlignment.Justified; RawRectangleF rectxy = new RawRectangleF(0, 0, Width - 1, 10); g.RenderTarget.DrawText(pt.ToString(), textFormat, rectxy, brush); //层类名称 string mm = this.GetType().Name; if (!string.IsNullOrWhiteSpace(Name)) { mm += "(" + Name + ")"; } textFormat.ParagraphAlignment = ParagraphAlignment.Center; textFormat.TextAlignment = TextAlignment.Center; RawRectangleF rectname = new RawRectangleF(0, 0, Width - 1, 10); g.RenderTarget.DrawText(mm, textFormat, rectxy, brush); g.RenderTarget.DrawRectangle(rect, brush, 1f); }