private void PreferencesWindow_Loaded(object sender, RoutedEventArgs e)
		{
			PreferencesWindow.loadPreferences();

			mySqlHostTextBox.Text = Preferences.HostAddress;
			mySqlPortTextBox.Text = Preferences.PortAddress;
			mySqlDatabaseTextBox.Text = Preferences.DatabaseName;
			mySqlUsernameTextBox.Text = Preferences.Username;
			mySqlPasswordBox.Password = Preferences.Password;
		}
        /// <summary>
        /// MainWindow Loaded event handler.
        /// </summary>
        private void Window_Loaded(object sender, System.Windows.RoutedEventArgs e)
        {
            //make sure preferences has the main window as its owner
            PreferencesWindow.Instance.Owner = this;

            PreferencesWindow.loadPreferences();

            DBConnection dbCon = new DBConnection
            (
                Preferences.HostAddress,
                Preferences.PortAddress,
                Preferences.DatabaseName,
                Preferences.Username,
                Preferences.Password
            );

            (new SplashScreenWindow()).ShowDialog();
        }
Exemple #3
0
        /// <summary>
        /// Attempts a connection to the MySQL server specified in the PreferencesWindow
        /// using the credentials also specified there and returns true or false depending
        /// on if the connection was successful.
        /// </summary>
        /// <returns>A boolean value reflecting whether or not the connection to the
        /// MySQL database was successful or not.</returns>
        public static bool connect()
        {
            //This is tightly coupled with DBConnection and preferably shouldn't be.
            PreferencesWindow.loadPreferences();

            if (dbCon != null)
                dbCon.closeConnection();

            dbCon = new DBConnection
            (
                Preferences.HostAddress,
                Preferences.PortAddress,
                Preferences.DatabaseName,
                Preferences.Username,
                Preferences.Password
            );

            return dbCon.openConnection();
        }