Skip to content

Commit

Permalink
Changes countdown to minutes:seconds
Browse files Browse the repository at this point in the history
  • Loading branch information
ryannewington committed Aug 28, 2020
1 parent 71ff504 commit e86c442
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 21 deletions.
5 changes: 2 additions & 3 deletions src/Lithnet.IdleLogoff/LogoffWarning.Designer.cs

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

7 changes: 5 additions & 2 deletions src/Lithnet.IdleLogoff/LogoffWarning.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading;
Expand Down Expand Up @@ -58,13 +59,15 @@ private void Timer_Tick(object sender, EventArgs e)

private void UpdateLabelText()
{
if (this.LogoffDateTime > DateTime.Now)
TimeSpan remaining = this.LogoffDateTime.Subtract(DateTime.Now);

if (remaining.Ticks > 0)
{
string message = Settings.WarningMessage;

if (message.Contains("{0}"))
{
message = string.Format(message, (int)((this.LogoffDateTime.Subtract(DateTime.Now)).TotalSeconds));
message = string.Format(message, $"{(int)remaining.TotalMinutes}{CultureInfo.CurrentCulture.DateTimeFormat.TimeSeparator}{remaining.Seconds:00}");
}

this.lbWarning.Text = message;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
<string id="cat_idle_logoff">IdleLogoff</string>
<string id="pol_enable_idle_logoff">Log off inactive users</string>
<string id="pol_show_warning_message">Show a warning message before logging off</string>
<string id="pol_show_warning_message_help">Shows a pop up notification informing the user of the number of seconds remaining before they are logged off.
<string id="pol_show_warning_message_help">Shows a pop up notification informing the user of the time remaining before they are logged off.

You can optionally provide a custom message to show the user. Use {0} as a placeholder for the remaining seconds until logoff.
You can optionally provide a custom message to show the user. Use {0} as a placeholder for the remaining time until logoff.
</string>
<string id="string_logoff">Log off</string>
<string id="string_reboot">Reboot</string>
Expand All @@ -23,7 +23,7 @@
<decimalTextBox refId="txt_warning_period" defaultValue="0">Duration of warning message (seconds)</decimalTextBox>
<textBox refId="txt_warning_message">
<label>Warning message text</label>
<defaultValue>Your session has been idle for too long, and you will be logged out in {0} seconds</defaultValue>
<defaultValue>Your session has been idle for too long, and you will be logged out in {0}</defaultValue>
</textBox>
</presentation>
<presentation id="pol_enable_idle_logoff">
Expand Down
2 changes: 1 addition & 1 deletion src/Lithnet.IdleLogoff/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public static string WarningMessage

if (string.IsNullOrWhiteSpace(value))
{
return "Your session has been idle for too long, and you will be logged out in {0} seconds";
return "Your session has been idle for too long, and you will be logged out in {0}";
}
else
{
Expand Down
24 changes: 12 additions & 12 deletions src/Lithnet.IdleLogoff/frmSettings.Designer.cs

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

0 comments on commit e86c442

Please sign in to comment.