Ejemplo n.º 1
0
        static void Main()
        {
            // Set culture info to US
            // This is done so that '.' is used instead of ',' for decimals.
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // If a database file does not exist, create a new one with empty tables.
            if (!File.Exists(DatabaseProperties.DATABASE_NAME) && !File.Exists(DatabaseProperties.ENCRYPTED_DATABASE_NAME))
            {
                SplashScreenForm splashForm = new SplashScreenForm();
                splashForm.Show();

                // Execute startup events so that splash screen images are loaded.
                Application.DoEvents();

                DatabaseGenerator.GenerateDB();

                Application.Run(new fec_Main(splashForm));
            }

            // If an unencrypted datbase file exists, open the main form.
            else if (File.Exists(DatabaseProperties.DATABASE_NAME))
            {
                SplashScreenForm splashForm = new SplashScreenForm();
                splashForm.Show();

                // Execute startup events so that splash screen images are loaded.
                Application.DoEvents();

                Application.Run(new fec_Main(splashForm));
            }

            // If an encrypted database file exists, prompt the user for a password.
            else if (File.Exists(DatabaseProperties.ENCRYPTED_DATABASE_NAME))
            {
                EnterPasswordForm enterPasswordForm = new EnterPasswordForm();
                enterPasswordForm.Show();

                Application.Run();
            }
        }
Ejemplo n.º 2
0
        static void Main()
        {
            CultureInfo ci = new CultureInfo("en-US");

            Thread.CurrentThread.CurrentCulture = ci;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            SplashScreenForm splashForm = new SplashScreenForm();

            splashForm.Show();

            // Execute startup events so that splash screen images are loaded
            Application.DoEvents();

            // Open main form
            Application.Run(new fec_Main(splashForm));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// If the background worker completed without errors, proceed with displaying the main UI.
        /// </summary>
        private void DecryptionWorker_WorkCompleted(object sender, System.ComponentModel.RunWorkerCompletedEventArgs e)
        {
            // If the execution of the background worker was cancelled, hide the progress bar and show an error.
            if (e.Cancelled)
            {
                HideProgressBar();
                MessageBoxAdv.Show(this, "Failed to decrypt database.\n\n" + decryptionError, "Error");
                return;
            }

            SplashScreenForm splashForm = new SplashScreenForm();

            // Hide this form so that only the splash screen is visible.
            this.Hide();

            splashForm.Show();

            // Execute startup events so that splash screen images are loaded.
            Application.DoEvents();

            // Release the encrypted database lock.
            ENCRYPTED_DB_LOCK.Close();

            // Delete the encrypted database file.
            File.Delete(DatabaseProperties.ENCRYPTED_DATABASE_NAME);

            // Create a secure string from the entered password.
            foreach (char c in passwordTextBox.Text)
            {
                DatabaseProperties.password.AppendChar(c);
            }

            // Create and display the main form.
            fec_Main mainForm = new fec_Main(splashForm);

            mainForm.Show();

            closed = true;
            this.Close();
        }