From 91b55eb19c662d6f9c6bc81ab3bae8b7632f66f2 Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Thu, 6 Apr 2023 10:54:18 +0200 Subject: [PATCH] 'Starting the system' message on start-up before MainWnd opens, ver. 3.6.2035 --- TBF/Program.cs | 41 ++++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/TBF/Program.cs b/TBF/Program.cs index bb94e222a..223cdd3fc 100644 --- a/TBF/Program.cs +++ b/TBF/Program.cs @@ -1,9 +1,10 @@ /// -/// Copyright (c) 2013-2019 Sensus Slovensko a.s. +/// Copyright (c) 2013-2023 Sensus Slovensko a.s. /// using System; using System.IO; using System.Collections.Generic; +using System.Drawing; using System.Windows.Forms; using log4net; using Common; @@ -228,6 +229,8 @@ namespace TBF bool retryLogin = true; /// true = stay in a login loop do { + LoadingConfigEnd(); + LoginDlgWithBenchSelection loginDlgBench; if (LocalSettings.LastBenchName != null) { @@ -252,6 +255,7 @@ namespace TBF { log.FatalFormat("Test bench name: {0}", loginDlgBench.BenchName); + LoadingConfigStart(); CurrentUser.RemoteUsersDB = LocalSettings.TestBenches[i].UsersDBSettings; CurrentUser.LocalUsersDB = LocalSettings.TestBenches[i].ProceduresDBSettings; @@ -488,11 +492,12 @@ namespace TBF try { - /// Open the main application window + /// Open the main application window log.Info("Creating the main window"); MainWnd = new UI.MainWnd(); log.Info("Opening the main window"); - Application.Run(MainWnd); + LoadingConfigEnd(); + Application.Run(MainWnd); log.Info("The main window was closed"); } catch (Exception e) @@ -527,5 +532,35 @@ namespace TBF log.FatalFormat("StackTrace : {0}{1}", Environment.NewLine, e.StackTrace); log.Fatal("--------------------------------------"); } + + + static UI.Shared.ModelessActivityForm form; + static System.Threading.Thread formThread; + + static void LoadingConfigStart() + { + form = new UI.Shared.ModelessActivityForm() + { + Message = Strings.Starting_system, + FontFamily = "Arial", + FontSize = 24, + FontStyle = FontStyle.Regular, + BackgroundColor = Color.LightBlue, + }; + formThread = new System.Threading.Thread(() => form.ShowDialog()); + formThread.Start(); + System.Threading.Thread.Sleep(500); + } + + static void LoadingConfigEnd() + { + if (form != null && formThread != null) + { + form.CloseForm(null, new EventArgs()); + formThread.Join(); + } + form = null; + formThread = null; + } } } \ No newline at end of file