@@ -13,7 +13,7 @@ namespace Demo;
1313public class DXCanvas : DXControl
1414{
1515 private IComObject < ID2D1Bitmap > ? _bitmapD2d = null ;
16- private Rectangle rectText = new ( 100 , 100 , 0 , 200 ) ;
16+ private Rectangle rectText = new ( 40 , 40 , 300 , 200 ) ;
1717
1818 public WicBitmapSource ? Image
1919 {
@@ -100,19 +100,11 @@ protected override void OnRender(IGraphics g)
100100 g . DrawRectangle ( ClientSize . Width / 1.5f , ClientSize . Height / 1.5f , 300 , 100 ,
101101 20f , Color . LightCyan , Color . FromArgb ( 180 , Color . Cyan ) , 3f ) ;
102102
103-
104- // draw and fill rectangle
105- g . DrawRectangle ( rectText , 0 , Color . Green , Color . FromArgb ( 100 , Color . Yellow ) ) ;
106-
107- // draw text
108- g . DrawText ( $ "Dương Diệu Pháp 😛💋", Font . Name , 9 , rectText ,
109- Color . Lavender , DeviceDpi , StringAlignment . Center , isBold : true , isItalic : true ) ;
110-
111-
112103 // draw and fill ellipse
113104 g . DrawEllipse ( 200 , 200 , 300 , 200 , Color . FromArgb ( 120 , Color . Magenta ) , Color . Purple , 5 ) ;
114105
115106
107+ // draw geometry D2D only
116108 if ( UseHardwareAcceleration && g is D2DGraphics dg )
117109 {
118110 using var geo = dg . GetCombinedRectanglesGeometry ( new RectangleF ( 200 , 300 , 300 , 300 ) ,
@@ -125,6 +117,19 @@ protected override void OnRender(IGraphics g)
125117 }
126118
127119
120+ // draw and fill rectangle
121+ g . DrawRectangle ( rectText , 0 , Color . Green , Color . FromArgb ( 100 , Color . Yellow ) ) ;
122+
123+
124+ // draw text
125+ var text = "Dương\r \n Diệu\r \n Pháp\r \n 😵🪺🐷😶🌫️🤯🫶🏿" ;
126+ var textSize = g . MeasureText ( text , Font . Name , 12 , textDpi : DeviceDpi , isBold : true , isItalic : true ) ;
127+ g . DrawText ( $ "{ text } \r \n { textSize } ", Font . Name , 12 , rectText ,
128+ Color . Red , DeviceDpi , StringAlignment . Near , isBold : true , isItalic : true ) ;
129+ g . DrawRectangle ( new RectangleF ( rectText . Location , textSize ) , 0 , Color . Red ) ;
130+
131+
132+ // draw FPD info
128133 var engine = UseHardwareAcceleration ? "GPU" : "GDI+" ;
129134 g . DrawText ( $ "FPS: { FPS } - { engine } ", Font . Name , 18 , 0 , 0 , Color . Purple , DeviceDpi ) ;
130135
@@ -134,6 +139,6 @@ protected override void OnRender(IGraphics g)
134139 protected override void OnFrame ( FrameEventArgs e )
135140 {
136141 base . OnFrame ( e ) ;
137- rectText . Width ++ ;
142+ // rectText.Width++;
138143 }
139144}
0 commit comments