protected void LoadSettings() { try { MusicDatabase mdb = MusicDatabase.Instance; List <string> scrobbleusers = new List <string>(); string tmpuser = ""; string tmppass = ""; groupBoxProfile.Visible = false; using (Settings xmlreader = new MPSettings()) { tmpuser = xmlreader.GetValueAsString("audioscrobbler", "user", ""); checkBoxEnableNowPlaying.Checked = xmlreader.GetValueAsBool("audioscrobbler", "EnableNowPlaying", true); scrobbleusers = mdb.GetAllScrobbleUsers(); // no users in database if (scrobbleusers.Count == 0) { tabControlLiveFeeds.Enabled = false; tabControlSettings.TabPages.RemoveAt(1); tabControlSettings.TabPages.RemoveAt(1); tabControlSettings.TabPages.RemoveAt(1); labelNoUser.Visible = true; } // only load settings if a user is present else { int selected = 0; int count = 0; foreach (string scrobbler in scrobbleusers) { if (!comboBoxUserName.Items.Contains(scrobbler)) { comboBoxUserName.Items.Add(scrobbler); } if (scrobbler == tmpuser) { selected = count; } count++; } comboBoxUserName.SelectedIndex = selected; buttonDelUser.Enabled = true; tmppass = mdb.AddScrobbleUserPassword(Convert.ToString(mdb.AddScrobbleUser(_currentUser)), ""); EncryptDecrypt Crypter = new EncryptDecrypt(); if (tmppass != string.Empty) { try { EncryptDecrypt DCrypter = new EncryptDecrypt(); maskedTextBoxASPassword.Text = DCrypter.Decrypt(tmppass); } catch (Exception) { //Log.Info("Audioscrobbler: Password decryption failed {0}", ex.Message); } } int tmpNMode = 1; int tmpRand = 77; int tmpArtists = 2; int tmpPreferTracks = 2; int tmpOfflineMode = 0; string tmpUserID = Convert.ToString(mdb.AddScrobbleUser(_currentUser)); checkBoxLogVerbose.Checked = (mdb.AddScrobbleUserSettings(tmpUserID, "iDebugLog", -1) == 1) ? true : false; tmpRand = mdb.AddScrobbleUserSettings(tmpUserID, "iRandomness", -1); checkBoxEnableSubmits.Checked = (mdb.AddScrobbleUserSettings(tmpUserID, "iSubmitOn", -1) == 1) ? true : false; checkBoxScrobbleDefault.Checked = (mdb.AddScrobbleUserSettings(tmpUserID, "iScrobbleDefault", -1) == 1) ? true : false; tmpArtists = mdb.AddScrobbleUserSettings(tmpUserID, "iAddArtists", -1); //numericUpDownTracksPerArtist.Value = mdb.AddScrobbleUserSettings(tmpUserID, "iAddTracks", -1); tmpNMode = mdb.AddScrobbleUserSettings(tmpUserID, "iNeighbourMode", -1); tmpOfflineMode = mdb.AddScrobbleUserSettings(tmpUserID, "iOfflineMode", -1); tmpPreferTracks = mdb.AddScrobbleUserSettings(tmpUserID, "iPreferCount", -1); checkBoxReAddArtist.Checked = (mdb.AddScrobbleUserSettings(tmpUserID, "iRememberStartArtist", -1) == 1) ? true : false; numericUpDownSimilarArtist.Value = (tmpArtists > 0) ? tmpArtists : 2; trackBarRandomness.Value = (tmpRand >= 25) ? tmpRand : 25; trackBarConsiderCount.Value = (tmpPreferTracks >= 0) ? tmpPreferTracks : 2; comboBoxOfflineMode.SelectedIndex = tmpOfflineMode; lastFmLookup = AudioscrobblerUtils.Instance; switch (tmpNMode) { case 3: lastFmLookup.CurrentNeighbourMode = lastFMFeed.topartists; comboBoxNeighbourMode.SelectedIndex = 0; comboBoxNModeSelect.SelectedIndex = 0; break; case 1: lastFmLookup.CurrentNeighbourMode = lastFMFeed.weeklyartistchart; comboBoxNeighbourMode.SelectedIndex = 1; comboBoxNModeSelect.SelectedIndex = 1; break; case 0: lastFmLookup.CurrentNeighbourMode = lastFMFeed.recenttracks; comboBoxNeighbourMode.SelectedIndex = 2; comboBoxNModeSelect.SelectedIndex = 2; break; default: lastFmLookup.CurrentNeighbourMode = lastFMFeed.weeklyartistchart; comboBoxNeighbourMode.SelectedIndex = 1; comboBoxNModeSelect.SelectedIndex = 1; break; } LoadProfileDetails(tmpuser); } } } catch (Exception ex) { Log.Error("Audioscrobbler settings could not be loaded: {0}", ex.Message); } }