Skip to content

Commit 45ca50d

Browse files
committed
Adds adjustment for display scaling != 100%
1 parent 7490f2c commit 45ca50d

File tree

3 files changed

+22
-2
lines changed

3 files changed

+22
-2
lines changed

Source/Menu/MainForm.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,6 +1613,15 @@ public void UpdateNotificationPageAlert()
16131613
pbNotificationsSome.Visible = true;
16141614
lblNotificationCount.Visible = true;
16151615
lblNotificationCount.Text = $"{NotificationManager.NewPages.Count - NotificationManager.NewPages.Viewed}";
1616+
1617+
// If screen scaling != 100%, then the count doesn't lie on top of the red circle, so adjust its position.
1618+
if (NotificationManager.ScreenScaling != 1.0 & NotificationManager.ScreenAdjusted == false)
1619+
{
1620+
var adjustment = (int)((NotificationManager.ScreenScaling - 1.0) * 20); // 20 to adjust 125% by 5 pixels
1621+
lblNotificationCount.Top -= adjustment;
1622+
lblNotificationCount.Left -= adjustment;
1623+
NotificationManager.ScreenAdjusted = true;
1624+
}
16161625
}
16171626
else
16181627
{

Source/Menu/Menu.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
<SpecificVersion>False</SpecificVersion>
3232
<HintPath>..\3rdPartyLibs\GNU.Gettext.WinForms.dll</HintPath>
3333
</Reference>
34+
<Reference Include="PresentationFramework" />
3435
<Reference Include="System.DirectoryServices" />
3536
<Reference Include="System.Net.Http" />
3637
<Reference Include="WindowsBase" />

Source/Menu/Notifications/NotificationManager.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
using System.Linq;
2323
using System.Net;
2424
using System.Resources;
25+
using System.Runtime.InteropServices;
2526
using System.Text;
27+
using System.Windows;
2628
using System.Windows.Forms;
2729
using Newtonsoft.Json;
2830
using ORTS.Common;
@@ -75,6 +77,8 @@ public class PageTracking
7577
public Image FirstImage { get; private set; }
7678
public Image LastImage { get; private set; }
7779
public PageTracking NewPages { get; private set; }
80+
public double ScreenScaling { get; private set; }
81+
public bool ScreenAdjusted { get; set; }
7882

7983
public NotificationManager(MainForm mainForm, ResourceManager resources, UpdateManager updateManager, UserSettings settings, Panel panel)
8084
{
@@ -83,14 +87,20 @@ public NotificationManager(MainForm mainForm, ResourceManager resources, UpdateM
8387
this.Settings = settings;
8488
Panel = panel;
8589
NewPages = new PageTracking();
86-
90+
ScreenScaling = GetScalingFactor();
91+
8792
// Load images of arrows
8893
PreviousImage = (Image)resources.GetObject("Notification_previous");
8994
NextImage = (Image)resources.GetObject("Notification_next");
9095
FirstImage = (Image)resources.GetObject("Notification_first");
9196
LastImage = (Image)resources.GetObject("Notification_last");
9297
}
93-
98+
99+
public double GetScalingFactor()
100+
{
101+
return Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth;
102+
}
103+
94104
public void CheckNotifications()
95105
{
96106
try

0 commit comments

Comments
 (0)