Skip to content

Commit 802dd36

Browse files
authored
Merge pull request #126 from arkane-systems/copilot/sub-pr-123-another-one
Guard NotifyIcon.Text against 63-char Windows limit
2 parents b4d32bb + ce9943e commit 802dd36

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

MouseJiggler/MainForm.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ namespace ArkaneSystems.MouseJiggler;
2020

2121
public partial class MainForm : Form
2222
{
23+
private const int MaxNotifyIconTextLength = 63;
24+
2325
/// <summary>
2426
/// Constructor for use by the form designer.
2527
/// </summary>
@@ -94,7 +96,8 @@ private void UpdateNotificationAreaText ()
9496
{
9597
var mode = this.JiggleMode.ToString ();
9698
var rnd = this.RandomTimer ? $@" with random variation," : string.Empty;
97-
this.niTray.Text = $@"Jiggling mouse every {this.JigglePeriod} s,{rnd} mode: {mode}{this.JiggleDistance}).";
99+
var text = $@"Jiggling mouse every {this.JigglePeriod} s,{rnd} mode: {mode}{this.JiggleDistance}).";
100+
this.niTray.Text = text.Length > MaxNotifyIconTextLength ? text[..(MaxNotifyIconTextLength - 3)] + "..." : text;
98101
}
99102
}
100103

0 commit comments

Comments
 (0)