Пример #1
0
 /// <summary>
 /// Handle checking or unchecking of the <see cref="checkbox_apply_equalizer"/>.
 /// Applies or doesn't apply the equalizer as given by the state of the checkbox.
 /// </summary>
 /// <param name="sender">N/A</param>
 /// <param name="e">N/A</param>
 /// <seealso cref="equalizerapo_api.ApplyEqualizer"/>
 private void checkbox_apply_equalizer_CheckedChanged(object sender, EventArgs e)
 {
     if (checkbox_apply_equalizer.InvokeRequired)
     {
         EventInvokeDelegate d = new EventInvokeDelegate(checkbox_apply_equalizer_CheckedChanged);
         this.Invoke(d, new object[] { sender, e });
     }
     else
     {
         eqAPI.ApplyEqualizer(checkbox_apply_equalizer.Checked);
         messenger.Send(messageParser.CreateMessage(
                            MessageParser.MESSAGE_TYPE.FILTER_APPLY),
                        true);
     }
 }
Пример #2
0
        /// <summary>
        /// Given a message from the client, parse the message to enact changes
        /// in the equalizer or zune instances.
        /// </summary>
        /// <param name="message">The message to be parsed.</param>
        public void ParseMessage(string message)
        {
            // get the message parts
            string[] messageParts = message.Split(new char[] { ':' }, 2);
            if (messageParts.Length < 2)
            {
                return;
            }
            string messageType   = messageParts[0];
            string restOfMessage = messageParts[1];

            // parse the message
            switch (messageType)
            {
            case "apply_filter":
                eqAPI.ApplyEqualizer((restOfMessage == "true")
                        ? true
                        : false);
                break;

            case "filter":
                if (restOfMessage == "added")
                {
                    eqAPI.AddFilter();
                }
                else if (restOfMessage == "removed")
                {
                    eqAPI.RemoveFilter();
                }
                break;

            case "filters":
                eqAPI.SetNewGainValues(restOfMessage.Split(new char[] { ',' }));
                break;

            case "playback":
                switch (restOfMessage)
                {
                case "pause":
                    zuneAPI.PauseTrack();
                    break;

                case "play":
                    zuneAPI.PlayTrack();
                    break;

                case "previous":
                    zuneAPI.ToPreviousTrack();
                    break;

                case "next":
                    zuneAPI.ToNextTrack();
                    break;
                }
                break;

            case "volume":
                eqAPI.PreAmp = Convert.ToInt32(
                    Convert.ToDouble(restOfMessage));
                break;
            }
        }