Skip to content

Commit 97aa7b5

Browse files
fix DPI scale
1 parent 4694266 commit 97aa7b5

6 files changed

+54
-14
lines changed

.gitignore

+7-1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,10 @@ ipch
7575

7676
# Visual Studio profiler
7777
.vspxproj
78-
.vspx
78+
.vspx
79+
80+
# Publish profiles
81+
*.[Pp]ublish.xml
82+
*.azurePubxml
83+
*.pubxml
84+
*.publishproj

GlucoseTaskbar.cs

+24-6
Original file line numberDiff line numberDiff line change
@@ -54,21 +54,33 @@ public GlucoseTaskbar()
5454
resourceManager = new("GlucoseTaskbar.Resources", typeof(Program).Assembly);
5555
nsData = new NightscoutData();
5656
settingsForm = new(this, nsData);
57-
controlPropertiesManager = new ControlPropertiesManager(this);
5857
SetOpacity();
5958
CultureManager.SetCulture();
6059
AttachMouseDownEventToControls(this);
60+
float dpiScale = DeviceDpi / 96f;
6161
SensorBatteryPictureBox = new PictureBox()
6262
{
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+
),
6571
Image = Properties.Resources.battery_no_signal,
6672
SizeMode = PictureBoxSizeMode.Zoom,
6773
};
6874
CellPhoneBatteryPictureBox = new PictureBox()
6975
{
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+
),
7284
Image = Properties.Resources.battery_no_signal,
7385
SizeMode = PictureBoxSizeMode.Zoom,
7486
};
@@ -88,6 +100,7 @@ public GlucoseTaskbar()
88100
AttachMouseDownEventToControls(SettingsOpenLabel);
89101
SetTooltipsTexts();
90102
SetContextMenuTexts();
103+
controlPropertiesManager = new ControlPropertiesManager(this);
91104
controlPropertiesManager.StoreOriginalProperties(this);
92105
controlPropertiesManager.StoreOriginalProperties(SensorBatteryPictureBox);
93106
controlPropertiesManager.StoreOriginalProperties(CellPhoneBatteryPictureBox);
@@ -197,6 +210,7 @@ private void FillData()
197210

198211
private void FillBattery()
199212
{
213+
float dpiScale = DeviceDpi / 96f;
200214
decimal scale = Properties.Settings.Default.ProgramSize;
201215

202216
static void SetBatteryValue(PictureBox pctBattery, int value, bool oldData)
@@ -234,13 +248,17 @@ static void SetBatteryValue(PictureBox pctBattery, int value, bool oldData)
234248
else if (battery == settingsForm.BothRadioButton.Name)
235249
{
236250
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+
);
238255
this.Controls.Add(SensorBatteryPictureBox);
239256
this.Controls.Add(CellPhoneBatteryPictureBox);
240257
}
241258
else if (battery == settingsForm.NoneRadioButton.Name)
242259
{
243260
this.Controls.Remove(SensorBatteryPictureBox);
261+
this.Controls.Remove(CellPhoneBatteryPictureBox);
244262
this.Size = new Size(originalFormSize.Width - SensorBatteryPictureBox.Width, originalFormSize.Height);
245263
}
246264

GlucoseTaskbar.csproj

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
<Nullable>enable</Nullable>
77
<UseWindowsForms>true</UseWindowsForms>
88
<ImplicitUsings>enable</ImplicitUsings>
9-
<Version>1.0.0</Version>
9+
<Version>1.0.1</Version>
1010
<Authors>Rafael Assis</Authors>
1111
<Product>Glucose Taskbar</Product>
1212
<Company>GlucoseTaskbar</Company>
1313
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
1414
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
1515
<ApplicationIcon>Resources\GlucoseTaskbarIcon.ico</ApplicationIcon>
1616
<SignAssembly>True</SignAssembly>
17+
<Copyright>Rafael Assis</Copyright>
1718
</PropertyGroup>
1819

1920
<ItemGroup>

GlucoseTaskbar.csproj.user

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<_LastSelectedProfileId>C:\Users\Ronaldo\Documents\Visual Studio 2022\Projects\GlucoseTaskbarProjects\GlucoseTaskbar\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
4+
<_LastSelectedProfileId>C:\Users\Ronaldo\Documents\Visual Studio 2022\Projects\GlucoseTaskbar\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
55
</PropertyGroup>
66
<ItemGroup>
77
<Compile Update="GlucoseTaskbar.cs">

SettingsForm.Designer.cs

+19-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

installer/GlucoseTaskbarInstaller.iss

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!
33

44
#define MyAppName "Glucose Taskbar"
5-
#define MyAppVersion "1.0.0"
5+
#define MyAppVersion "1.0.1"
66
#define MyAppPublisher "GlucoseTaskbar"
77
#define MyAppExeName "GlucoseTaskbar.exe"
88
#define SourceDir "..\..\GlucoseTaskbar\bin\Release\net8.0-windows7.0"

0 commit comments

Comments
 (0)