/// <summary>
        /// Checks the default state of the plugins to make sure configuration entries have been created for them
        /// </summary>
        public static void CheckPluginDefaultStatus()
        {
            // The Last.fm preferred configuration for this application is to have iTunes on by default, and Windows Media Player disabled
            // This is because this application exists to solve the problem that iTunes broke their event driven model, by removing the events.
            IScrobbleSource iTunesSource       = ScrobbleFactory.ScrobblePlugins.FirstOrDefault(plugin => plugin.SourceIdentifier == Guid.Parse("a458e8af-4282-4bd7-8894-14969c63a7d5"));
            IScrobbleSource windowsMediaSource = ScrobbleFactory.ScrobblePlugins.FirstOrDefault(plugin => plugin.SourceIdentifier == Guid.Parse("7471fa52-0007-43c9-a644-945fbc7f5897"));

            // Check to see if anything has been configured already, if not, add our two defaults
            if (Settings.ScrobblerStatus.Count == 0)
            {
                Settings.ScrobblerStatus.Add(new ScrobblerSourceStatus()
                {
                    Identifier = iTunesSource.SourceIdentifier, IsEnabled = true
                });
                Settings.ScrobblerStatus.Add(new ScrobblerSourceStatus()
                {
                    Identifier = windowsMediaSource.SourceIdentifier, IsEnabled = false
                });
            }

            // Now iterate all plugins (in case any others have been loaded) and default them to being off
            foreach (IScrobbleSource plugin in ScrobbleFactory.ScrobblePlugins)
            {
                if (Settings.ScrobblerStatus.FirstOrDefault(settingsPlugin => settingsPlugin.Identifier == plugin.SourceIdentifier) == null)
                {
                    Settings.ScrobblerStatus.Add(new ScrobblerSourceStatus()
                    {
                        Identifier = plugin.SourceIdentifier, IsEnabled = false
                    });
                }
            }
        }
Esempio n. 2
0
        // Method used when the user changes any of the checkboxes on the settings ui
        private void SettingItem_Changed()
        {
            // Temporarily pause scrobbling
            ScrobbleFactory.ScrobblingEnabled = false;

            // Modify the settings based on what the current state of the Ui elements are
            Core.Settings.CloseToTray               = chkMinimizeToTray.Checked;
            Core.Settings.StartMinimized            = chkStartMinimized.Checked;
            Core.Settings.ShowScrobbleNotifications = chkShowScrobbleNotifications.Checked;
            Core.Settings.ShowTrackChanges          = chkShowtrackChanges.Checked;
            Core.Settings.ShowNotifications         = chkShowNotifications.Checked;

            // Clear the settings of the current scrobbler plugin status'
            Core.Settings.ScrobblerStatus.Clear();

            // Create a new list of scrobbler plugin status'
            foreach (var checkedItem in checkedPluginList.Items)
            {
                IScrobbleSource plugin = ScrobbleFactory.ScrobblePlugins?.FirstOrDefault(item => item.SourceDescription == checkedItem);

                ScrobblerSourceStatus newStatus = new ScrobblerSourceStatus()
                {
                    Identifier = plugin.SourceIdentifier, IsEnabled = checkedPluginList.CheckedItems.Contains(checkedItem)
                };
                Core.Settings.ScrobblerStatus.Add(newStatus);
            }

            // Re-enable scrobbling based on the mew plugin status'
            bool allowScrobbling = Core.Settings.ScrobblerStatus.Count(plugin => plugin.IsEnabled) > 0;

            base.ScrobbleStateChanging(allowScrobbling);


            // Automatically update the settings file
            Core.SaveSettings();

            // Refresh the scrobble state on the Ui
            ShowIdleStatus();
        }
Esempio n. 3
0
        private void btnSave_Click(object sender, EventArgs e)
        {
            Core.Settings.CloseToTray               = chkMinimizeToTray.Checked;
            Core.Settings.StartMinimized            = chkStartMinimized.Checked;
            Core.Settings.ShowScrobbleNotifications = chkShowScrobbleNotifications.Checked;
            Core.Settings.ShowTrackChanges          = chkShowtrackChanges.Checked;

            Core.Settings.ScrobblerStatus.Clear();

            foreach (var checkedItem in checkedPluginList.Items)
            {
                IScrobbleSource plugin = ScrobbleFactory.ScrobblePlugins?.FirstOrDefault(item => item.SourceDescription == checkedItem);

                Core.Settings.ScrobblerStatus.Add(new LastFM.Common.Classes.ScrobblerSourceStatus()
                {
                    Identifier = plugin.SourceIdentifier, IsEnabled = checkedPluginList.CheckedItems.Contains(checkedItem)
                });
            }

            Core.SaveSettings();

            this.DialogResult = DialogResult.OK;
            this.Close();
        }