protected override void OnRender(D2DGraphics g) { base.OnRender(g); // set the transform before draw rect g.SetTransform(mat.toD2DMatrix3x2()); g.FillRectangle(rect, isHitted ? D2DColor.LightYellow : D2DColor.LightGray); g.DrawRectangle(rect, isHitted ? D2DColor.Red : D2DColor.Blue, 2); g.DrawText("Drag to move / Click to rotate / Scroll to scale", D2DColor.Black, this.Font.Name, 14, rect, DWriteTextAlignment.Center, DWriteParagraphAlignment.Center); g.ResetTransform(); }