Exemplo n.º 1
0
        private void applyButton_Click(object sender, EventArgs e)
        {
            List <Plugin.FileCodec> formats = new List <Plugin.FileCodec> {
                Plugin.FileCodec.Unknown
            };

            foreach (var item in transcodeFormats.CheckedItems)
            {
                Plugin.FileCodec codec = AudioStream.GetFileCodec(transcodeFormats.GetItemText(item));
                Debug.Assert(codec != Plugin.FileCodec.Unknown);
                formats.Add(codec);
            }

            ushort validPort;

            if (ushort.TryParse(portInput.Text, out validPort))
            {
                if (port != validPort && port > 1)
                {
                    validPort = Plugin.settings.serverPort;
                }
            }

            Settings settings = new Settings
            {
                serverName = serverNameInput.Text,
                serverPort = validPort,
                transcode  = new AudioStream.TranscodeOptions
                {
                    usePCM = pcm.Checked,
                    useMusicBeeSettings = mbAudio.Checked,
                    enableDSP           = dsp.Checked,
                    replayGainMode      = replayGainTrack.Checked ? Plugin.ReplayGainMode.Track
                                   : replayGainAlbum.Checked ? Plugin.ReplayGainMode.Album
                                   : replayGainSmart.Checked ? Plugin.ReplayGainMode.Smart
                                   : Plugin.ReplayGainMode.Off,
                    formats = formats
                },
                optimisedUserAgent = null,
                optimisedMetadata  = null,
                optimisationPinned = pinOptimisation.Checked
            };

            Save(settings);
        }
Exemplo n.º 2
0
        private void SetFormSettingsInternal(Settings settings)
        {
            serverNameInput.Text = settings.serverName;
            portInput.Text       = settings.serverPort.ToString();

            pinOptimisation.Checked = settings.optimisationPinned;
            pinOptimisation.Enabled = settings.optimisedMetadata != null;
            optimiseLabel.Text      = Plugin.TrimToCharacter(optimiseLabel.Text, ':') + ": " + (settings.optimisedUserAgent ?? "None");

            pcm.Checked     = settings.transcode.usePCM;
            mbAudio.Checked = settings.transcode.useMusicBeeSettings;
            dsp.Checked     = settings.transcode.enableDSP;

            switch (settings.transcode.replayGainMode)
            {
            case Plugin.ReplayGainMode.Album:
                replayGainAlbum.Checked = true;
                break;

            case Plugin.ReplayGainMode.Track:
                replayGainTrack.Checked = true;
                break;

            case Plugin.ReplayGainMode.Smart:
                replayGainSmart.Checked = true;
                break;

            default:
                replayGainOff.Checked = true;
                break;
            }

            for (int i = 0; i < transcodeFormats.Items.Count; i++)
            {
                var item = transcodeFormats.Items[i];
                Plugin.FileCodec codec = AudioStream.GetFileCodec(transcodeFormats.GetItemText(item));
                Debug.Assert(codec != Plugin.FileCodec.Unknown);
                if (settings.transcode.formats.Contains(codec))
                {
                    transcodeFormats.SetItemChecked(i, true);
                }
            }
        }