diff --git a/DesktopEdge/MainWindow.xaml.cs b/DesktopEdge/MainWindow.xaml.cs index 72bf8c5b..d28fd856 100644 --- a/DesktopEdge/MainWindow.xaml.cs +++ b/DesktopEdge/MainWindow.xaml.cs @@ -136,8 +136,9 @@ namespace ZitiDesktopEdge { for (int i=0; i0) { if (_timer != null) _timer.Stop(); _timer = new System.Windows.Forms.Timer(); - _timer.Interval = _identity.MaxTimeout; + _timer.Interval = _identity.MaxTimeout*1000; _timer.Tick += TimerTicked; _timer.Start(); } + if (_identity.MinTimeout > 0) { + if (_timingTimer != null) _timingTimer.Stop(); + countdown = _identity.MinTimeout; + _timingTimer = new System.Windows.Forms.Timer(); + _timingTimer.Interval = 1000; + _timingTimer.Tick += TimingTimerTick; ; + _timingTimer.Start(); + } } else { ServiceCountArea.Visibility = Visibility.Collapsed; MfaRequired.Visibility = Visibility.Visible; @@ -82,6 +92,18 @@ namespace ZitiDesktopEdge { } } + private void TimingTimerTick(object sender, EventArgs e) { + if (countdown>-1) { + countdown--; + if (countdown<1260) { + _identity.IsTimingOut = true; + TimerCountdown.ToolTip = _identity.TimeoutMessage; + if (TimerCountdown.ToolTip.ToString().Length == 0) TimerCountdown.ToolTip = "Timing Out"; + TimerCountdown.Visibility = _identity.IsTimingOut ? Visibility.Visible : Visibility.Collapsed; + } + } + } + private void TimerTicked(object sender, EventArgs e) { _identity.MFAInfo.IsAuthenticated = false; RefreshUI(); diff --git a/DesktopEdge/Views/Screens/IdentityDetails.xaml.cs b/DesktopEdge/Views/Screens/IdentityDetails.xaml.cs index 302e44ef..2897ecfb 100644 --- a/DesktopEdge/Views/Screens/IdentityDetails.xaml.cs +++ b/DesktopEdge/Views/Screens/IdentityDetails.xaml.cs @@ -40,6 +40,7 @@ namespace ZitiDesktopEdge { public event OnRecovery Recovery; public delegate void LoadingEvent(bool isComplete); public event LoadingEvent OnLoading; + private System.Windows.Forms.Timer _timer; public int Page = 1; public int PerPage = 50; @@ -50,6 +51,7 @@ namespace ZitiDesktopEdge { private double scrolledTo = 0; public int totalServices = 0; private ScrollViewer _scroller; + private ZitiService _info; public ObservableCollection _services = new ObservableCollection(); public ObservableCollection ZitiServices { get { return _services; } } @@ -212,27 +214,52 @@ namespace ZitiDesktopEdge { } private void ShowDetails(ZitiService info) { + _info = info; DetailName.Text = info.Name; DetailProtocols.Text = info.ProtocolString; DetailAddress.Text = info.AddressString; DetailPorts.Text = info.PortString; DetailUrl.Text = info.ToString(); + UpdateClock(info); + if (_identity.IsMFAEnabled) { + if (_timer != null) _timer.Stop(); + _timer = new System.Windows.Forms.Timer(); + _timer.Interval = 1000; + _timer.Tick += Ticked; ; + _timer.Start(); + } + + DetailsArea.Visibility = Visibility.Visible; + DetailsArea.Opacity = 0; + DetailsArea.Margin = new Thickness(0, 0, 0, 0); + DoubleAnimation animation = new DoubleAnimation(1, TimeSpan.FromSeconds(.3)); + animation.Completed += ShowCompleted; + DetailsArea.BeginAnimation(Grid.OpacityProperty, animation); + DetailsArea.BeginAnimation(Grid.MarginProperty, new ThicknessAnimation(new Thickness(30, 30, 30, 30), TimeSpan.FromSeconds(.3))); + + ShowModal(); + } + + private void Ticked(object sender, EventArgs e) { + UpdateClock(_info); + } + + private void UpdateClock(ZitiService info) { try { if (_identity.IsMFAEnabled) { if (info.TimeoutRemaining > 0) { - // t = TimeSpan.FromSeconds(info.TimeoutRemaining); TimeSpan t = (DateTime.Now - info.TimeUpdated); int timeout = info.Timeout - (int)Math.Floor(t.TotalSeconds); - if (timeout>0) { + if (timeout > 0) { t = TimeSpan.FromSeconds(timeout); string answer = t.Seconds + " seconds"; if (t.Days > 0) answer = t.Days + " days " + t.Hours + " hours " + t.Minutes + " minutes " + t.Seconds + " seconds"; else { if (t.Hours > 0) answer = t.Hours + " hours " + t.Minutes + " minutes " + t.Seconds + " seconds"; else { - if (t.Minutes>0) answer = t.Minutes + " minutes " + t.Seconds + " seconds"; + if (t.Minutes > 0) answer = t.Minutes + " minutes " + t.Seconds + " seconds"; } } TimeoutDetails.Text = answer; @@ -249,18 +276,8 @@ namespace ZitiDesktopEdge { } } catch (Exception e) { TimeoutDetails.Text = "Never"; - Console.WriteLine("Error: "+e.ToString()); + Console.WriteLine("Error: " + e.ToString()); } - - DetailsArea.Visibility = Visibility.Visible; - DetailsArea.Opacity = 0; - DetailsArea.Margin = new Thickness(0, 0, 0, 0); - DoubleAnimation animation = new DoubleAnimation(1, TimeSpan.FromSeconds(.3)); - animation.Completed += ShowCompleted; - DetailsArea.BeginAnimation(Grid.OpacityProperty, animation); - DetailsArea.BeginAnimation(Grid.MarginProperty, new ThicknessAnimation(new Thickness(30, 30, 30, 30), TimeSpan.FromSeconds(.3))); - - ShowModal(); } private void ShowCompleted(object sender, EventArgs e) {