コード例 #1
0
        void IContent.OnNavigatedTo(NavigationEventArgs e)
        {
            InterfaceHelpers.CurrentPage = e.Source.OriginalString;

            FillFavouriteDBConnectionsComboBox();

            // Disable "Reconnect to last used Database" if the connection cannot be found
            DBConnectionHelpers.LoadConnectionParameters();
            if (DBConnectionHelpers.LoadLastUsedDatabase() == null)
            {
                ReconnectToLastUsedConnectionButton.IsEnabled = false;
            }
            else
            {
                ReconnectToLastUsedConnectionButton.IsEnabled = true;
            }

            // Disable "Restore saved results" button if no file exists
            if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\LastMiningResults.mpm"))
            {
                RestoreSavedResultsButton.IsEnabled = false;
            }
            else
            {
                RestoreSavedResultsButton.IsEnabled = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Add a new connection to the DatabaseSettings.xml and connect to the Database
        /// </summary>
        /// <author>Bernhard Bruns</author>
        private void SaveAndConnectClick(object sender, RoutedEventArgs e)
        {
            DBConnectionHelpers.LoadConnectionParameters();

            ConnectionParameters connectionParameters = new ConnectionParameters(DBTypeComboBox.Text, DBConnectionnameTextBox.Text, DBHostnameTextBox.Text, DBDatabaseTextBox.Text, DBUsernameTextBox.Text, DBPasswordTextBox.Password, DBPortTextBox.Text);

            if (connectionParameters.IsComplete())
            {
                if (DBConnectionHelpers.CheckIfDatabaseNameExists(connectionParameters.Name))
                {
                    DBConnectionHelpers.AddDatabaseConnectionToConnectionList(connectionParameters);

                    if (ConnectToDb(connectionParameters))
                    {
                        DBConnectionHelpers.SaveConnectionParameters();
                        DBConnectionHelpers.SaveLastUsedDatabase(connectionParameters);
                        AddConnectionGrid.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        ModernDialog.ShowMessage("Can't connect to database!", "New Connection", MessageBoxButton.OK);
                    }
                }
                else
                {
                    ModernDialog.ShowMessage("Connection Name \"" + connectionParameters.Name + "\" already exists! \r\nPlease choose a new Name for your connection.", "New Connection", MessageBoxButton.OK);
                }
            }
            else
            {
                ModernDialog.ShowMessage("Please fill out all fields to add the new connection!", "New Connection", MessageBoxButton.OK);
            }
        }
コード例 #3
0
        /// <summary>
        /// Fills the listbox with saved database connections
        /// </summary>
        /// <author>Bernhard Bruns</author>
        private void FillListboxWithDatabaseConections()
        {
            DBConnectionHelpers.LoadConnectionParameters();
            ConnectionsListBox.ItemsSource = DBConnectionHelpers.ConnectionParametersList;

            if (ConnectionsListBox.Items.Count > 0)
            {
                ConnectionsListBox.SelectedIndex = 0;
            }
        }
コード例 #4
0
        public void LoadConnectionParametersTest()
        {
            bool expected;
            bool actual;

            if (File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"\DatabaseSettings.mpm"))
            {
                expected = true;
            }
            else
            {
                expected = false;
            }

            actual = DBConnectionHelpers.LoadConnectionParameters();
            Assert.AreEqual(expected, actual);
        }
コード例 #5
0
        /// <summary>
        /// Read the DatabaseSettings xml-file and write it in the connectionlist
        /// </summary>
        /// <author>Bernhard Bruns</author>
        public void FillFavouriteDBConnectionsComboBox()
        {
            DBConnectionHelpers.LoadConnectionParameters();

            if (DBConnectionHelpers.ConnectionParametersList != null)
            {
                // Binding
                FavouriteDBConnectionsComboBox.ItemsSource       = DBConnectionHelpers.ConnectionParametersList;
                FavouriteDBConnectionsComboBox.DisplayMemberPath = "Name";

                if (DBConnectionHelpers.ConnectionParametersList.Count == 0)
                {
                    ConnectToFavouriteButton.IsEnabled       = false;
                    FavouriteDBConnectionsComboBox.IsEnabled = false;
                }
                else
                {
                    ConnectToFavouriteButton.IsEnabled           = true;
                    FavouriteDBConnectionsComboBox.IsEnabled     = true;
                    FavouriteDBConnectionsComboBox.SelectedIndex = 0;
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// handle Shortcuts
        /// </summary>
        /// <param Name="sender"></param>
        /// <param Name="e"></param>
        /// <author>Thomas Meents, Bernd Nottbeck, Jannik Arndt</author>
        private void HandleShortcuts(object sender, KeyEventArgs e)
        {
            if (Keyboard.Modifiers.HasFlag(ModifierKeys.Control))
            {
                switch (e.Key)
                {
                case Key.R:
                    Cursor = Cursors.Wait;
                    try
                    {
                        DBConnectionHelpers.LoadConnectionParameters();
                        DBConnectionHelpers.EstablishDatabaseConnection(DBConnectionHelpers.LoadLastUsedDatabase());
                    }
                    finally
                    {
                        Cursor = Cursors.Arrow;
                    }
                    break;
                }
            }
            else
            {
                switch (e.Key)
                {
                case Key.Enter:
                    switch (ContentSource.ToString())
                    {
                    case ("/Pages/P1connection.xaml"):
                        ContentSource = new Uri("/Pages/P2metadata.xaml", UriKind.RelativeOrAbsolute);
                        break;

                    case ("/Pages/P2metadata.xaml"):
                        ContentSource = new Uri("/Pages/P3dimensionselection.xaml", UriKind.RelativeOrAbsolute);
                        break;

                    case ("/Pages/P3dimensionselection.xaml"):
                        ContentSource = new Uri("/Pages/P4eventselection.xaml", UriKind.RelativeOrAbsolute);
                        break;

                    case ("/Pages/P4eventselection.xaml"):
                        ContentSource = new Uri("/Pages/P5configuration.xaml", UriKind.RelativeOrAbsolute);
                        break;

                    case ("/Pages/P5configuration.xaml"):
                        if (MinerSettings.IsAlgorithmSet)
                        {
                            ContentSource = new Uri("/Pages/P6mining.xaml", UriKind.RelativeOrAbsolute);
                        }
                        break;

                    case ("/Pages/P6mining.xaml"):
                        // Start / Continue
                        break;

                    case ("/Pages/P7consolidation.xaml"):
                        ContentSource = new Uri("/Pages/P8results.xaml", UriKind.RelativeOrAbsolute);
                        break;
                    }
                    break;

                case Key.F11:
                    if (WindowState.Equals(WindowState.Maximized))
                    {
                        ViewRegularscreen();
                    }
                    else
                    {
                        ViewFullscreen();
                    }
                    break;
                }
            }
        }
コード例 #7
0
 /// <summary>
 /// Reconnect to the Last used database connection
 /// </summary>
 /// <author>Bernhard Bruns</author>
 private void ReconnectToLastUsedConnectionClick(object sender, RoutedEventArgs e)
 {
     DBConnectionHelpers.LoadConnectionParameters();
     ConnectToDb(DBConnectionHelpers.LoadLastUsedDatabase());
 }