[chronojump] Compujump shows autologout countdown starting at last 10 seconds



commit cf8a2da94bd4146788db0402b060dab1037d4220
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Apr 6 20:03:59 2018 +0200

    Compujump shows autologout countdown starting at last 10 seconds

 src/gui/chronojump.cs |   10 ++++++++++
 src/gui/networks.cs   |   38 +++++++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 1 deletions(-)
---
diff --git a/src/gui/chronojump.cs b/src/gui/chronojump.cs
index b744a99..a9afa0f 100644
--- a/src/gui/chronojump.cs
+++ b/src/gui/chronojump.cs
@@ -4300,6 +4300,16 @@ public partial class ChronoJumpWindow
                                label_logout_seconds.Text = compujumpAutologout.RemainingSeconds(false);
                                label_logout_seconds_encoder.Text = 
compujumpAutologout.RemainingSeconds(false);
                                */
+                               string logoutSecondsStr = "";
+                               if(! compujumpAutologout.IsCompujumpCapturing())
+                               {
+                                       int remainingSeconds = compujumpAutologout.RemainingSeconds();
+                                       if(remainingSeconds <= 10)
+                                               logoutSecondsStr = string.Format("Logout\nin {0} s", 
compujumpAutologout.RemainingSeconds());
+                               }
+
+                               label_logout_seconds.Text = logoutSecondsStr;
+                               label_logout_seconds_encoder.Text = logoutSecondsStr;
                        }
                }
 
diff --git a/src/gui/networks.cs b/src/gui/networks.cs
index bec64ce..d950d1e 100644
--- a/src/gui/networks.cs
+++ b/src/gui/networks.cs
@@ -1090,9 +1090,45 @@ public class CompujumpAutologout
                return false;
        }
 
+       private double sSinceLogin()
+       {
+               return DateTime.Now.Subtract(loginTime).TotalSeconds;
+       }
+       private double sSinceRunInterval()
+       {
+               return DateTime.Now.Subtract(lastRunIntervalTime).TotalSeconds;
+       }
+       private double sSinceEncoderCapture()
+       {
+               return DateTime.Now.Subtract(lastEncoderCaptureTime).TotalSeconds;
+       }
+       private double sSinceEncoderAnalyze()
+       {
+               return DateTime.Now.Subtract(lastEncoderAnalyzeTime).TotalSeconds;
+       }
+       public int RemainingSeconds ()
+       {
+               int logoutDefaultS = logoutMinutes * 60;
+               double seconds = 0;
+
+               if(sSinceLogin() > seconds)
+                       seconds = logoutDefaultS - sSinceLogin();
+
+               if(lastRunIntervalTime > DateTime.MinValue && logoutDefaultS - sSinceRunInterval() > seconds)
+                       seconds = logoutDefaultS - sSinceRunInterval();
+
+               if(lastEncoderCaptureTime > DateTime.MinValue && logoutDefaultS - sSinceEncoderCapture() > 
seconds)
+                       seconds = logoutDefaultS - sSinceEncoderCapture();
+
+               if(lastEncoderAnalyzeTime > DateTime.MinValue && logoutDefaultS - sSinceEncoderAnalyze() > 
seconds)
+                       seconds = logoutDefaultS - sSinceEncoderAnalyze();
+
+               return Convert.ToInt32(seconds);
+       }
+
        //showAll is for debug, user will see only one value
        //TODO: separate between minutes and seconds and only display when remaining 10 seconds
-       public string RemainingSeconds(bool showAll)
+       public string RemainingSecondsOld(bool showAll)
        {
                if(! Active)
                        return "";


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]