diff --git a/Common/.shared/SharedAssemblyInfo.cs b/Common/.shared/SharedAssemblyInfo.cs index 62f0cb85..b198312b 100644 --- a/Common/.shared/SharedAssemblyInfo.cs +++ b/Common/.shared/SharedAssemblyInfo.cs @@ -14,5 +14,5 @@ using System.Reflection; //[assembly: AssemblyVersion("1.2.*.0")] -[assembly: AssemblyVersion("2.6.7.*")] -[assembly: AssemblyFileVersion("2.6.7.0")] \ No newline at end of file +[assembly: AssemblyVersion("2.6.8.*")] +[assembly: AssemblyFileVersion("2.6.8.0")] \ No newline at end of file diff --git a/Common/Ui/GenesisToolBox/frmMainForm.cs b/Common/Ui/GenesisToolBox/frmMainForm.cs index 0386e533..21db103a 100644 --- a/Common/Ui/GenesisToolBox/frmMainForm.cs +++ b/Common/Ui/GenesisToolBox/frmMainForm.cs @@ -12,6 +12,7 @@ using Ctls; using Infrastructure; using Utils.Logging; + using System.Collections.Generic; internal delegate void UpdateLayout(); @@ -393,12 +394,23 @@ /// private void HideContent() { - foreach (var control in Controls) + var controlsToRemove = new List(); + + foreach (Control control in Controls) { if (control is GroupBox groupBox) { groupBox.Hide(); } + else if (control is IIdentityForm _ ) + { + controlsToRemove.Add(control); + } + } + + foreach (var control in controlsToRemove) + { + this.Controls.Remove(control); } } @@ -407,7 +419,7 @@ /// private void SetSoftwareFunctions() { - // changePassword.Tag = SoftwareFunctions.LAA_ADMIN; + changePassword.Enabled = Software.IsAutenticated; btnSetup.Tag = SoftwareFunctions.GENERAL_SETUP; btnAlarm.Tag = SoftwareFunctions.GENERAL_ALARM; @@ -545,17 +557,7 @@ { Software.Logout(); - foreach (var control in Controls) - { - if (control is LoginForm loginForm) - { - Controls.Remove(loginForm); - - break; - } - } - - ShowAvailableSoftwareFunctions(); + InitializeFormState(); } private void OnLoginClick(Object sender, EventArgs args) @@ -576,43 +578,17 @@ if (!hasLoginForm) { - var loginForm = new LoginForm(LoginFormSubmitted); - loginForm.OnCancellation += OnControlCancellation; + var loginForm = new LoginForm(this.OnControlCancellation); Controls.Add(loginForm); } } - /// - /// Callback method that is called when user enters valid username and password. - /// - /// Not null or empty string. - /// Not null or empty string. - /// Is the LoginForm from witch is this method called. - private void LoginFormSubmitted(String username, String password, Object sender) - { - if (sender is LoginForm loginForm) - { - if (Software.Login(username, password)) - { - Controls.Remove(loginForm); - ShowAvailableSoftwareFunctions(); - - optionsMenuItem.Text = Software.UserName; - } - else - { - loginForm.ShowError("Invalid login attempt"); - } - } - } - private void OnChangePasswordClick(Object _, EventArgs _1) { this.HideContent(); var control = new ChangePassword(this.OnControlCancellation); - control.OnCancellation += this.OnControlCancellation; this.Controls.Add(control); } @@ -621,9 +597,9 @@ { if (control != null) { + this.HideContent(); + Software.Initialize(); - - this.Controls.Remove(control); } this.InitializeFormState();