Beispiel #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlayerTextView" /> class.
 /// </summary>
 /// <param name="playerController">The player controller.</param>
 /// <param name="playerStatusUpdater">The player information.</param>
 /// <param name="volumeStatus">The volume status.</param>
 public PlayerTextView(PlayerController playerController, IPlayerStatusUpdater playerStatusUpdater, IVolumeStatus volumeStatus)
 {
     this.playerController    = playerController;
     this.playerStatusUpdater = playerStatusUpdater;
     this.volumeStatus        = volumeStatus;
     this.ResetPlayerState();
 }
 public VolumeStatusResponse([NotNull] IVolumeStatus status)
 {
     if (status == null)
     {
         throw new ArgumentNullException("status");
     }
     Status = status;
 }
Beispiel #3
0
        protected virtual IVolumeStatusResponse ParseE2(string response)
        {
            response = Helpers.SanitizeXmlString(response);
            IVolumeStatus status = _factory.VolumeStatus();

            using (XmlReader reader = XmlReader.Create(new StringReader(response)))
            {
                bool canRead = reader.Read();
                while (canRead)
                {
                    if (reader.IsStartElement())
                    {
                        switch (reader.Name.ToLower())
                        {
                        case "e2ismuted":
                            reader.Read();
                            bool muted;
                            if (!bool.TryParse(reader.Value.Trim(), out muted))
                            {
                                throw new ParsingException(
                                          string.Format("Enigma2 volume status parsing failed. Unable to convert {0} to boolean value.", reader.Value));
                            }
                            status.Mute = muted;
                            break;

                        case "e2current":
                            reader.Read();
                            int current;
                            if (!int.TryParse(reader.Value.Trim(), out current))
                            {
                                throw new ParsingException(
                                          string.Format("Enigma2 volume status parsing failed. Unable to convert {0} to integer value.", reader.Value));
                            }
                            status.Level = current;
                            break;
                        }
                    }
                    canRead = reader.Read();
                }
            }
            return(_factory.VolumeStatusResponse(status));
        }
Beispiel #4
0
        protected virtual IVolumeStatusResponse ParseE1(string response)
        {
            bool          mute;
            int           current;
            IVolumeStatus status = _factory.VolumeStatus();

            string muteString    = GetE1StatusValue(response, @"var mute = ");
            string currentString = GetE1StatusValue(response, @"var volume = ");

            if (!bool.TryParse(muteString, out mute))
            {
                throw new ParsingException(string.Format("Enigma1 volume status parsing failed. Unable to convert {0} to boolean value.", muteString));
            }
            status.Mute = mute;

            if (!int.TryParse(currentString, out current))
            {
                throw new ParsingException(string.Format("Enigma1 volume status parsing failed. Unable to convert {0} to integer value.", currentString));
            }
            status.Mute = mute;

            return(_factory.VolumeStatusResponse(status));
        }
Beispiel #5
0
 public virtual IVolumeStatusResponse VolumeStatusResponse(IVolumeStatus status)
 {
     return(new VolumeStatusResponse(status));
 }