/// <summary> /// Initialises a new instance of the ParentForm class. /// </summary> public ParentForm() { try { MainThread.CheckDBExistence(); Preferences.SetPreferences(); BackgroundWorker bw = new BackgroundWorker() { WorkerReportsProgress = true, WorkerSupportsCancellation = true }; bw.DoWork += delegate { BackgroundWorkerRunProcess(bw); }; bw.RunWorkerCompleted += delegate { BackgroundWorkerCompletedProcess(); }; bw.RunWorkerAsync(); if (splashScreen == null) { splashScreen = new SplashScreen(); ShowInTaskbar = false; WindowState = FormWindowState.Minimized; WindowInteropHelper helper = new WindowInteropHelper(this); Screen currentScreen = Screen.FromHandle(helper.Handle); Shown += delegate { if (Preferences.ShowWelcomeScreen) { new WelcomeScreen().ShowDialog(); } AnalyseFileExistenceResults(); }; FormClosing += OnFormClosing; Resize += delegate { UpdateControlSizes(); }; Text = szAppName; iDesktopWorkingWidth = currentScreen.WorkingArea.Width; iDesktopWorkingHeight = currentScreen.WorkingArea.Height; Size size = new Size(iDesktopWorkingWidth, iDesktopWorkingHeight); InitialiseForm(size); foreach (Control control in Controls) { UpdateControlColorsFonts(control, ControlColour, ColourFont, SystemFont); } UpdateControlSizes(); SermonReader.parentForm = this; StatusBarMessages.statusLabelAction = statusLabelAction; StatusBarMessages.statusLabelShowing = statusLabelShowing; StatusBarMessages.statusLabelUpdates = statusLabelUpdates; startPage = new StartPageForm(this); AddNewTabPage(startPage); } } catch (Exception e) { MessageBox.Show("An error was encountered while trying to load the application. Re-run the application.\nIf the error persists, reinstall the application. See error details below:\n\n\n" + e.ToString()); try { Close(); } catch { } } }