private void TimeRemainingWindow_Closed(object sender, EventArgs e)
 {
     this.Dispatcher.Invoke(() =>
     {
         this.timeRemainingWindow = null;
     });
 }
 private void NotifyIcon_MouseDoubleClick_User(object sender, MouseButtonEventArgs e)
 {
     this.Dispatcher.Invoke(() =>
     {
         if (this.timeRemainingWindow == null)
         {
             this.timeRemainingWindow         = new TimeRemainingWindow();
             this.timeRemainingWindow.Closed += this.TimeRemainingWindow_Closed;
             this.timeRemainingWindow?.Show();
         }
         else
         {
             this.timeRemainingWindow?.Focus();
         }
     });
 }
        private void BL_UserLoggedOut(object sender, EventArgs e)
        {
            this.Dispatcher.Invoke(() =>
            {
                this.txtUsername.Text               = string.Empty;
                this.pswPassword.Password           = string.Empty;
                this.mniOccasionalTime.IsEnabled    = false;
                this.mniOccasionalProgram.IsEnabled = false;
                this.mniChangePassword.IsEnabled    = false;
                this.mniLogOut.IsEnabled            = false;
                this.notifyIcon.MouseDoubleClick   -= this.NotifyIcon_MouseDoubleClick_Admin;
                this.notifyIcon.MouseDoubleClick   -= this.NotifyIcon_MouseDoubleClick_User;
                if (this.adminWindow != null)
                {
                    this.adminWindow.Close();
                    this.adminWindow = null;
                }

                if (this.timeRemainingWindow != null)
                {
                    this.timeRemainingWindow.Close();
                    this.timeRemainingWindow = null;
                }

                this.Show();
                this.Focus();
                this.txtUsername.Focus();
                foreach (Window window in App.Current.Windows)
                {
                    if (window.Tag != null && window.Tag.ToString() == "child")
                    {
                        window.Close();
                    }
                }
            });
        }