Exemple #1
0
        public override void SaveSettings()
        {
            using (Settings xmlwriter = new MPSettings())
            {
                #region Player Settings
                xmlwriter.SetValue("audioplayer", "playerId", audioPlayerComboBox.SelectedIndex);
                xmlwriter.SetValue("audioplayer", "sounddevice", (soundDeviceComboBox.SelectedItem as SoundDeviceItem).Name);
                xmlwriter.SetValue("audioplayer", "sounddeviceid", (soundDeviceComboBox.SelectedItem as SoundDeviceItem).ID);

                xmlwriter.SetValue("audioplayer", "crossfade", trackBarCrossfade.Value);
                xmlwriter.SetValue("audioplayer", "buffering", trackBarBuffering.Value);
                xmlwriter.SetValueAsBool("audioplayer", "useSkipSteps", UseSkipStepsCheckBox.Checked);
                xmlwriter.SetValueAsBool("audioplayer", "fadeOnStartStop", FadeOnStartStopChkbox.Checked);
                xmlwriter.SetValueAsBool("audioplayer", "gaplessPlayback", GaplessPlaybackChkBox.Checked);
                xmlwriter.SetValueAsBool("audioplayer", "enableReplayGain", EnableReplayGainChkBox.Checked);
                xmlwriter.SetValueAsBool("audioplayer", "enableAlbumReplayGain", EnableAlbumReplayGainChkBox.Checked);
                xmlwriter.SetValue("audioplayer", "streamOutputLevel", StreamOutputLevelNud.Value);

                xmlwriter.SetValue("audioplayer", "asiobalance", hScrollBarBalance.Value);

                xmlwriter.SetValueAsBool("audioplayer", "wasapiExclusive", WasapiExclusiveModeCkBox.Checked);
                xmlwriter.SetValue("audioplayer", "wasApiSpeakers", WasApiSpeakersCombo.SelectedIndex);

                xmlwriter.SetValue("audioplayer", "upMixMono", cbUpmixMono.SelectedIndex);
                xmlwriter.SetValue("audioplayer", "upMixStereo", cbUpmixStereo.SelectedIndex);
                xmlwriter.SetValue("audioplayer", "upMixQuadro", cbUpmixQuadro.SelectedIndex);
                xmlwriter.SetValue("audioplayer", "upMixFiveDotOne", cbUpmixFiveDotOne.SelectedIndex);

                xmlwriter.SetValueAsBool("audioplayer", "enableResume", chkEnableResumeSupport.Checked);
                xmlwriter.SetValue("audioplayer", "resumeAfter", tbResumeAfter.Text);
                xmlwriter.SetValue("audioplayer", "resumeSelect", cbResumeSelect.Text);
                xmlwriter.SetValue("audioplayer", "resumeSearch", tbResumeSearchValue.Text);

                #endregion

                #region Visualization Settings
                if (IVizMgr != null && VisualizationsCmbBox.SelectedIndex > 0) // Something else than "None" selected
                {
                    List <VisualizationInfo> vizPluginsInfo = IVizMgr.VisualizationPluginsInfo;
                    int selIndex = VisualizationsCmbBox.SelectedIndex;

                    if (selIndex < 0 || selIndex >= vizPluginsInfo.Count)
                    {
                        selIndex = 0;
                    }

                    xmlwriter.SetValue("musicvisualization", "name", vizPluginsInfo[selIndex].Name);
                    xmlwriter.SetValue("musicvisualization", "vizType",
                                       ((int)vizPluginsInfo[selIndex].VisualizationType).ToString());
                    xmlwriter.SetValue("musicvisualization", "path", vizPluginsInfo[selIndex].FilePath);
                    xmlwriter.SetValue("musicvisualization", "clsid", vizPluginsInfo[selIndex].CLSID);
                    xmlwriter.SetValue("musicvisualization", "preset", vizPluginsInfo[selIndex].PresetIndex.ToString());
                    xmlwriter.SetValueAsBool("musicvisualization", "useOpenGL", ckUseOpenGL.Checked);
                    xmlwriter.SetValueAsBool("musicvisualization", "useCover", ckUseCover.Checked);
                    xmlwriter.SetValue("musicvisualization", "renderTiming", soniqueRenderTiming.Value.ToString());
                    xmlwriter.SetValue("musicvisualization", "fftSensitivity", winampFFTsensitivity.Value.ToString());
                    xmlwriter.SetValue("musicvisualization", "viewPort", comboViewPortSizes.SelectedIndex.ToString());
                    xmlwriter.SetValueAsBool("musicfiles", "doVisualisation", true);
                }
                else if (VizPluginInfo.VisualizationType != VisualizationInfo.PluginType.None)
                // This is the case, when we started Config without activating the Vis Tab
                {
                    xmlwriter.SetValue("musicvisualization", "name", VizPluginInfo.Name);
                    xmlwriter.SetValue("musicvisualization", "vizType", ((int)VizPluginInfo.VisualizationType).ToString());
                    xmlwriter.SetValue("musicvisualization", "path", VizPluginInfo.FilePath);
                    xmlwriter.SetValue("musicvisualization", "clsid", VizPluginInfo.CLSID);
                    xmlwriter.SetValue("musicvisualization", "preset", VizPluginInfo.PresetIndex.ToString());
                    xmlwriter.SetValueAsBool("musicvisualization", "useOpenGL", ckUseOpenGL.Checked);
                    xmlwriter.SetValueAsBool("musicvisualization", "useCover", ckUseCover.Checked);
                    xmlwriter.SetValue("musicvisualization", "renderTiming", soniqueRenderTiming.Value.ToString());
                    xmlwriter.SetValue("musicvisualization", "fftSensitivity", winampFFTsensitivity.Value.ToString());
                    xmlwriter.SetValue("musicvisualization", "viewPort", comboViewPortSizes.SelectedIndex.ToString());
                    xmlwriter.SetValueAsBool("musicfiles", "doVisualisation", true);
                }
                else
                {
                    xmlwriter.SetValue("musicvisualization", "name", "");
                    xmlwriter.SetValue("musicvisualization", "vizType", 0);
                    xmlwriter.SetValue("musicvisualization", "path", "");
                    xmlwriter.SetValue("musicvisualization", "clsid", "");
                    xmlwriter.SetValue("musicvisualization", "preset", "");
                    xmlwriter.SetValueAsBool("musicvisualization", "useOpenGL", false);
                    xmlwriter.SetValueAsBool("musicvisualization", "useCover", false);
                    xmlwriter.SetValue("musicvisualization", "renderTiming", "");
                    xmlwriter.SetValue("musicvisualization", "fftSensitivity", "");
                    xmlwriter.SetValue("musicvisualization", "viewPort", "");
                    xmlwriter.SetValueAsBool("musicfiles", "doVisualisation", false);
                }

                xmlwriter.SetValue("musicvisualization", "fps", VisualizationFpsNud.Value);

                xmlwriter.SetValueAsBool("musicvisualization", "enableStatusOverlays", EnableStatusOverlaysChkBox.Checked);
                xmlwriter.SetValueAsBool("musicvisualization", "showTrackInfo", ShowTrackInfoChkBox.Checked);
                #endregion

                #region Playlist Settings
                xmlwriter.SetValue("music", "playlists", playlistFolderTextBox.Text);
                xmlwriter.SetValueAsBool("musicfiles", "repeat", repeatPlaylistCheckBox.Checked);
                xmlwriter.SetValueAsBool("musicfiles", "autoshuffle", autoShuffleCheckBox.Checked);
                xmlwriter.SetValueAsBool("musicfiles", "savePlaylistOnExit", SavePlaylistOnExitChkBox.Checked);
                xmlwriter.SetValueAsBool("musicfiles", "resumePlaylistOnMusicEnter", ResumePlaylistChkBox.Checked);
                xmlwriter.SetValueAsBool("musicfiles", "playlistIsCurrent", PlaylistCurrentCheckBox.Checked);

                //Play behaviour
                xmlwriter.SetValue("musicfiles", "selectOption", cmbSelectOption.Text.ToLowerInvariant());
                xmlwriter.SetValueAsBool("musicfiles", "addall", chkAddAllTracks.Checked);
                #endregion

                #region Misc Settings
                string playNowJumpTo = string.Empty;

                switch (PlayNowJumpToCmbBox.Text)
                {
                case JumpToOption0:
                    playNowJumpTo = JumpToValue0;
                    break;

                case JumpToOption1:
                    playNowJumpTo = JumpToValue1;
                    break;

                case JumpToOption2:
                    playNowJumpTo = JumpToValue2;
                    break;

                case JumpToOption3:
                    playNowJumpTo = JumpToValue3;
                    break;

                case JumpToOption4:
                    playNowJumpTo = JumpToValue4;
                    break;

                case JumpToOption5:
                    playNowJumpTo = JumpToValue5;
                    break;

                case JumpToOption6:
                    playNowJumpTo = JumpToValue6;
                    break;

                default:
                    playNowJumpTo = JumpToValue0;
                    break;
                }

                xmlwriter.SetValue("music", "playnowjumpto", playNowJumpTo);
                xmlwriter.SetValueAsBool("musicmisc", "showVisInNowPlaying", ShowVizInNowPlayingChkBox.Checked);
                xmlwriter.SetValueAsBool("musicmisc", "lookupSimilarTracks", !chkDisableSimilarTrackLookups.Checked);

                string vuMeter = VUMeterValue0;

                if (radioButtonVUAnalog.Checked)
                {
                    vuMeter = VUMeterValue1;
                }
                else if (radioButtonVULed.Checked)
                {
                    vuMeter = VUMeterValue2;
                }

                xmlwriter.SetValue("musicmisc", "vumeter", vuMeter);

                #endregion
            }

            // Make sure we shut down the viz engine
            if (IVizMgr != null)
            {
                IVizMgr.Stop();
                IVizMgr.ShutDown();
            }
        }