@@ -54,21 +54,33 @@ public GlucoseTaskbar()
54
54
resourceManager = new ( "GlucoseTaskbar.Resources" , typeof ( Program ) . Assembly ) ;
55
55
nsData = new NightscoutData ( ) ;
56
56
settingsForm = new ( this , nsData ) ;
57
- controlPropertiesManager = new ControlPropertiesManager ( this ) ;
58
57
SetOpacity ( ) ;
59
58
CultureManager . SetCulture ( ) ;
60
59
AttachMouseDownEventToControls ( this ) ;
60
+ float dpiScale = DeviceDpi / 96f ;
61
61
SensorBatteryPictureBox = new PictureBox ( )
62
62
{
63
- Size = new Size ( 19 , 36 ) ,
64
- Location = new Point ( 110 , 0 ) ,
63
+ Size = new Size (
64
+ ( int ) ( 19 * dpiScale ) ,
65
+ ( int ) ( 36 * dpiScale )
66
+ ) ,
67
+ Location = new Point (
68
+ ( int ) ( 110 * dpiScale ) ,
69
+ ( int ) ( 0 * dpiScale )
70
+ ) ,
65
71
Image = Properties . Resources . battery_no_signal ,
66
72
SizeMode = PictureBoxSizeMode . Zoom ,
67
73
} ;
68
74
CellPhoneBatteryPictureBox = new PictureBox ( )
69
75
{
70
- Size = new Size ( 19 , 36 ) ,
71
- Location = new Point ( 110 , 0 ) ,
76
+ Size = new Size (
77
+ ( int ) ( 19 * dpiScale ) ,
78
+ ( int ) ( 36 * dpiScale )
79
+ ) ,
80
+ Location = new Point (
81
+ ( int ) ( 110 * dpiScale ) ,
82
+ ( int ) ( 0 * dpiScale )
83
+ ) ,
72
84
Image = Properties . Resources . battery_no_signal ,
73
85
SizeMode = PictureBoxSizeMode . Zoom ,
74
86
} ;
@@ -88,6 +100,7 @@ public GlucoseTaskbar()
88
100
AttachMouseDownEventToControls ( SettingsOpenLabel ) ;
89
101
SetTooltipsTexts ( ) ;
90
102
SetContextMenuTexts ( ) ;
103
+ controlPropertiesManager = new ControlPropertiesManager ( this ) ;
91
104
controlPropertiesManager . StoreOriginalProperties ( this ) ;
92
105
controlPropertiesManager . StoreOriginalProperties ( SensorBatteryPictureBox ) ;
93
106
controlPropertiesManager . StoreOriginalProperties ( CellPhoneBatteryPictureBox ) ;
@@ -197,6 +210,7 @@ private void FillData()
197
210
198
211
private void FillBattery ( )
199
212
{
213
+ float dpiScale = DeviceDpi / 96f ;
200
214
decimal scale = Properties . Settings . Default . ProgramSize ;
201
215
202
216
static void SetBatteryValue ( PictureBox pctBattery , int value , bool oldData )
@@ -234,13 +248,17 @@ static void SetBatteryValue(PictureBox pctBattery, int value, bool oldData)
234
248
else if ( battery == settingsForm . BothRadioButton . Name )
235
249
{
236
250
this . Size = new Size ( originalFormSize . Width + CellPhoneBatteryPictureBox . Width + ( int ) ( 2 * scale ) , originalFormSize . Height ) ;
237
- CellPhoneBatteryPictureBox . Location = new Point ( ( int ) ( SensorBatteryPictureBox . Location . X + 20 * scale ) , ( int ) ( SensorBatteryPictureBox . Location . Y * scale ) ) ;
251
+ CellPhoneBatteryPictureBox . Location = new Point (
252
+ ( int ) ( SensorBatteryPictureBox . Location . X + ( 20 * dpiScale * ( float ) scale ) ) ,
253
+ ( int ) ( SensorBatteryPictureBox . Location . Y * scale )
254
+ ) ;
238
255
this . Controls . Add ( SensorBatteryPictureBox ) ;
239
256
this . Controls . Add ( CellPhoneBatteryPictureBox ) ;
240
257
}
241
258
else if ( battery == settingsForm . NoneRadioButton . Name )
242
259
{
243
260
this . Controls . Remove ( SensorBatteryPictureBox ) ;
261
+ this . Controls . Remove ( CellPhoneBatteryPictureBox ) ;
244
262
this . Size = new Size ( originalFormSize . Width - SensorBatteryPictureBox . Width , originalFormSize . Height ) ;
245
263
}
246
264
0 commit comments