Skip to content

Commit

Permalink
Fixed a bug with checkmarks missing in the systray icon
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkessel authored Jul 30, 2024
1 parent d3df584 commit c0d3d8a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions sit-stand.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ $MainFunction = {
else {
$y = [System.Windows.MessageBox]::Show("Sit down.", 'Stand Reminder', 'OKCancel', 'Info')
}
$global:sitting = -not $global:sit
$global:sitting = -not $global:sitting
}
if ($global:sitting) {
$global:remaining = $global:sittime
Expand Down Expand Up @@ -242,6 +242,8 @@ function UpdateIcon {
$objNotifyIcon.Icon = GetIcon $global:remaining $global:sitting
$contextMenu.Items[0].Text = ("Sit" + (& { If ($global:sitting) { " (" + $Global:Remaining + ")" } }))
$contextMenu.Items[1].Text = ("Stand" + (& { If (-not $global:sitting) { " (" + $Global:Remaining + ")" } }))
$contextMenu.Items[0].Checked = ( $global:sitting)
$contextMenu.Items[1].Checked = ( -not $global:sitting)
foreach ($x in $contextMenu.Items[2].DropDownItems[2].DropDownItems) {
$x.checked = ($x.text -eq $global:TrayFont)
}
Expand Down Expand Up @@ -296,7 +298,7 @@ Function GetIcon {
System.Drawing.Icon. An icon object that can be added to the systray.
#>
$bmp = new-object System.Drawing.Bitmap 128, 128
$font = new-object System.Drawing.Font $Global:TrayFont, ([math]::floor(128 / ([string]$number).length))
$font = new-object System.Drawing.Font $Global:TrayFont, ([math]::floor(100 / ([string]$number).length))
if ($reverse) {
$bg = new-object System.Drawing.SolidBrush $Global:TrayColorFg
$fg = new-object System.Drawing.SolidBrush $Global:TrayColorBg
Expand All @@ -316,4 +318,4 @@ Function GetIcon {
Return [System.Drawing.Icon]::FromHandle(([System.Drawing.Bitmap]::new($bmp).GetHIcon()))
}

& $MainFunction
& $MainFunction

0 comments on commit c0d3d8a

Please sign in to comment.