Ejemplo n.º 1
0
 public void StartDatabaseListRefresh()
 {
     Cursor = Cursors.WaitCursor;
     _databaseComboBox.Enabled = false;
     _usernameTextBox.Enabled  = false;
     _passwordTextBox.Enabled  = false;
     _loginButton.Enabled      = false;
     _loader.AttachTo(_databaseComboBox);
     _loader.Start();
 }
Ejemplo n.º 2
0
        private void InitDatabaseList()
        {
            var backgroundWorker = new BackgroundWorker();
            var databases        = new List <SqlDatabaseSettings>();
            var loaderControl    = new LoaderControl();

            backgroundWorker.DoWork += (sender, args) =>
            {
                var databaseService = ServicesProvider.GetInstance().GetDatabaseServices();
                databases = databaseService.GetOpenCbsDatabases();
            };
            backgroundWorker.RunWorkerCompleted += (sender, args) =>
            {
                loaderControl.Stop();
                if (args.Error != null)
                {
                    MessageBox.Show(args.Error.Message);
                    return;
                }
                Enable();
                var index = -1;
                var i     = 0;
                foreach (var database in databases)
                {
                    databaseCombobox.Items.Add(database.Name);
                    if (database.Name == TechnicalSettings.DatabaseName)
                    {
                        index = i;
                    }
                    i++;
                }
                databaseCombobox.SelectedIndex = index;
                usernameTextbox.Focus();
                databaseCombobox.SelectedIndexChanged += (sender2, args2) => ChangeDefaultDatabaseAndRestart();
            };
            Controls.Add(loaderControl);
            loaderControl.AttachTo(databaseCombobox);
            loaderControl.Start();
            Disable();
            backgroundWorker.RunWorkerAsync();
        }