@@ -95,7 +95,7 @@ public SensorNotifyIcon(SystemTray sensorSystemTray, ISensor sensor,
9595 }
9696
9797 font = new Font ( family , baseSize * width / 16.0f , GraphicsUnit . Pixel ) ;
98- smallFont = new Font ( family , 0.75f * baseSize * width / 16.0f , GraphicsUnit . Pixel ) ;
98+ smallFont = new Font ( family , 0.7f * baseSize * width / 16.0f , GraphicsUnit . Pixel ) ;
9999
100100 bitmap = new Bitmap ( width , height , PixelFormat . Format32bppArgb ) ;
101101 graphics = Graphics . FromImage ( bitmap ) ;
@@ -209,19 +209,22 @@ private Icon CreateTransparentIcon() {
209209 graphics . Clear ( defaultBackColor ) ;
210210 }
211211
212- var textShift = bitmap . Width / 8 - 1 ; //todo: tested for 16 & 32 only
213212 if ( small ) {
214213 if ( text [ 1 ] == '.' || text [ 1 ] == ',' ) {
215214 var bigPart = text . Substring ( 0 , 1 ) ;
216215 var smallPart = text . Substring ( 1 ) ;
217- TextRenderer . DrawText ( graphics , bigPart , font , new Point ( - 4 , - 2 ) , color , defaultBackColor ) ;
218- TextRenderer . DrawText ( graphics , smallPart , smallFont , new Point ( 4 * textShift , 1 * textShift ) , color , defaultBackColor ) ;
216+ var bigSize = TextRenderer . MeasureText ( bigPart , font ) ;
217+ var smallSize = TextRenderer . MeasureText ( smallPart , smallFont ) ;
218+ TextRenderer . DrawText ( graphics , bigPart , font , new Point ( - 4 , ( bitmap . Height - bigSize . Height ) / 2 ) , color , defaultBackColor ) ;
219+ TextRenderer . DrawText ( graphics , smallPart , smallFont , new Point ( 4 * ( bitmap . Width / 8 - 1 ) , bitmap . Height - smallSize . Height ) , color , defaultBackColor ) ;
219220 } else {
220- TextRenderer . DrawText ( graphics , text , smallFont , new Point ( - 2 * textShift , 2 * textShift ) , color , defaultBackColor ) ;
221+ var size = TextRenderer . MeasureText ( text , smallFont ) ;
222+ TextRenderer . DrawText ( graphics , text , smallFont , new Point ( ( bitmap . Width - size . Width ) / 2 , ( bitmap . Height - size . Height ) / 2 ) , color , defaultBackColor ) ;
221223 }
222224 }
223225 else {
224- TextRenderer . DrawText ( graphics , text , font , new Point ( - 2 * textShift , - 1 * textShift ) , color , defaultBackColor ) ;
226+ var size = TextRenderer . MeasureText ( text , font ) ;
227+ TextRenderer . DrawText ( graphics , text , font , new Point ( ( bitmap . Width - size . Width ) / 2 , ( bitmap . Height - size . Height ) / 2 ) , color , defaultBackColor ) ;
225228 }
226229
227230 var data = bitmap . LockBits (
0 commit comments