Skip to content

Commit

Permalink
fix DPI scale
Browse files Browse the repository at this point in the history
  • Loading branch information
RafaelBomfim128 committed Dec 23, 2024
1 parent 4694266 commit 97aa7b5
Show file tree
Hide file tree
Showing 6 changed files with 54 additions and 14 deletions.
8 changes: 7 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,10 @@ ipch

# Visual Studio profiler
.vspxproj
.vspx
.vspx

# Publish profiles
*.[Pp]ublish.xml
*.azurePubxml
*.pubxml
*.publishproj
30 changes: 24 additions & 6 deletions GlucoseTaskbar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,21 +54,33 @@ public GlucoseTaskbar()
resourceManager = new("GlucoseTaskbar.Resources", typeof(Program).Assembly);
nsData = new NightscoutData();
settingsForm = new(this, nsData);
controlPropertiesManager = new ControlPropertiesManager(this);
SetOpacity();
CultureManager.SetCulture();
AttachMouseDownEventToControls(this);
float dpiScale = DeviceDpi / 96f;
SensorBatteryPictureBox = new PictureBox()
{
Size = new Size(19, 36),
Location = new Point(110, 0),
Size = new Size(
(int)(19 * dpiScale),
(int)(36 * dpiScale)
),
Location = new Point(
(int)(110 * dpiScale),
(int)(0 * dpiScale)
),
Image = Properties.Resources.battery_no_signal,
SizeMode = PictureBoxSizeMode.Zoom,
};
CellPhoneBatteryPictureBox = new PictureBox()
{
Size = new Size(19, 36),
Location = new Point(110, 0),
Size = new Size(
(int)(19 * dpiScale),
(int)(36* dpiScale)
),
Location = new Point(
(int)(110 * dpiScale),
(int)(0 * dpiScale)
),
Image = Properties.Resources.battery_no_signal,
SizeMode = PictureBoxSizeMode.Zoom,
};
Expand All @@ -88,6 +100,7 @@ public GlucoseTaskbar()
AttachMouseDownEventToControls(SettingsOpenLabel);
SetTooltipsTexts();
SetContextMenuTexts();
controlPropertiesManager = new ControlPropertiesManager(this);
controlPropertiesManager.StoreOriginalProperties(this);
controlPropertiesManager.StoreOriginalProperties(SensorBatteryPictureBox);
controlPropertiesManager.StoreOriginalProperties(CellPhoneBatteryPictureBox);
Expand Down Expand Up @@ -197,6 +210,7 @@ private void FillData()

private void FillBattery()
{
float dpiScale = DeviceDpi / 96f;
decimal scale = Properties.Settings.Default.ProgramSize;

static void SetBatteryValue(PictureBox pctBattery, int value, bool oldData)
Expand Down Expand Up @@ -234,13 +248,17 @@ static void SetBatteryValue(PictureBox pctBattery, int value, bool oldData)
else if (battery == settingsForm.BothRadioButton.Name)
{
this.Size = new Size(originalFormSize.Width + CellPhoneBatteryPictureBox.Width + (int)(2 * scale), originalFormSize.Height);
CellPhoneBatteryPictureBox.Location = new Point((int)(SensorBatteryPictureBox.Location.X + 20 * scale), (int)(SensorBatteryPictureBox.Location.Y * scale));
CellPhoneBatteryPictureBox.Location = new Point(
(int)(SensorBatteryPictureBox.Location.X + (20 * dpiScale * (float)scale)),
(int)(SensorBatteryPictureBox.Location.Y * scale)
);
this.Controls.Add(SensorBatteryPictureBox);
this.Controls.Add(CellPhoneBatteryPictureBox);
}
else if (battery == settingsForm.NoneRadioButton.Name)
{
this.Controls.Remove(SensorBatteryPictureBox);
this.Controls.Remove(CellPhoneBatteryPictureBox);
this.Size = new Size(originalFormSize.Width - SensorBatteryPictureBox.Width, originalFormSize.Height);
}

Expand Down
3 changes: 2 additions & 1 deletion GlucoseTaskbar.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
<Nullable>enable</Nullable>
<UseWindowsForms>true</UseWindowsForms>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.0.0</Version>
<Version>1.0.1</Version>
<Authors>Rafael Assis</Authors>
<Product>Glucose Taskbar</Product>
<Company>GlucoseTaskbar</Company>
<PackageLicenseExpression>GPL-3.0-or-later</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<ApplicationIcon>Resources\GlucoseTaskbarIcon.ico</ApplicationIcon>
<SignAssembly>True</SignAssembly>
<Copyright>Rafael Assis</Copyright>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion GlucoseTaskbar.csproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_LastSelectedProfileId>C:\Users\Ronaldo\Documents\Visual Studio 2022\Projects\GlucoseTaskbarProjects\GlucoseTaskbar\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
<_LastSelectedProfileId>C:\Users\Ronaldo\Documents\Visual Studio 2022\Projects\GlucoseTaskbar\Properties\PublishProfiles\FolderProfile.pubxml</_LastSelectedProfileId>
</PropertyGroup>
<ItemGroup>
<Compile Update="GlucoseTaskbar.cs">
Expand Down
23 changes: 19 additions & 4 deletions SettingsForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion installer/GlucoseTaskbarInstaller.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "Glucose Taskbar"
#define MyAppVersion "1.0.0"
#define MyAppVersion "1.0.1"
#define MyAppPublisher "GlucoseTaskbar"
#define MyAppExeName "GlucoseTaskbar.exe"
#define SourceDir "..\..\GlucoseTaskbar\bin\Release\net8.0-windows7.0"
Expand Down

0 comments on commit 97aa7b5

Please sign in to comment.