Exemplo n.º 1
0
        public Group(SnapDotNet.ControlClient.SnapcastClient snapcastClient, SnapDotNet.ControlClient.JsonRpcData.Group group)
        {
            InitializeComponent();
            m_Group          = group;
            m_SnapcastClient = snapcastClient;

            foreach (SnapDotNet.ControlClient.JsonRpcData.Client client in m_Group.clients)
            {
                if (SnapSettings.HideOfflineClients == false || client.connected == true)
                {
                    Client c = new Client(client, m_SnapcastClient.ServerData.server.snapserver);
                    c.HorizontalAlignment        = HorizontalAlignment.Stretch;
                    c.HorizontalContentAlignment = HorizontalAlignment.Center;
                    m_ClientControls.Add(c);
                    spClients.Children.Add(c);
                }
            }

            m_Group.SERVER_OnGroupUpdated += () =>
            {
                System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(_OnGroupUpdated));
            };

            m_Group.CLIENT_OnVolumeUpdated += () =>
            {
                System.Windows.Application.Current.Dispatcher.BeginInvoke(new Action(_OnGroupUpdated));
            };

            vcGroup.OnMuteToggled       += VcGroup_OnMuteToggled;
            vcGroup.OnVolumeChanged     += VcGroup_OnVolumeChanged;
            vcGroup.OnVolumeChangeStart += VcGroup_OnVolumeChangeStart;

            _OnGroupUpdated();
        }
Exemplo n.º 2
0
        public Group(SnapcastClient snapcastClient, SnapDotNet.ControlClient.JsonRpcData.Group group)
        {
            InitializeComponent();
            m_Group          = group;
            m_SnapcastClient = snapcastClient;

            foreach (SnapDotNet.ControlClient.JsonRpcData.Client client in m_Group.clients)
            {
                Client c = new Client(client, m_SnapcastClient.ServerData.server.snapserver);
                //c.HorizontalAlignment = HorizontalAlignment.Stretch;
                //c.HorizontalContentAlignment = HorizontalAlignment.Center;
                slClients.Children.Add(c);
            }

            m_Group.SERVER_OnGroupUpdated += () =>
            {
                MainThread.BeginInvokeOnMainThread(_OnGroupUpdated);
            };

            m_Group.CLIENT_OnVolumeUpdated += () =>
            {
                MainThread.BeginInvokeOnMainThread(_OnGroupUpdated);
            };

            vcGroup.OnMuteToggled       += VcGroup_OnMuteToggled;
            vcGroup.OnVolumeChanged     += VcGroup_OnVolumeChanged;
            vcGroup.OnVolumeChangeStart += VcGroup_OnVolumeChangeStart;
            vcGroup.OnSettingsTapped    += VcGroup_OnSettingsTapped;
            _OnGroupUpdated();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Called when snapserver reports group stream update
 /// </summary>
 /// <param name="id">client id</param>
 /// <param name="name">new name</param>
 private void _GroupStreamChanged(string id, string stream_id)
 {
     JsonRpcData.Group group = _GetGroup(id);
     if (group != null)
     {
         group.SERVER_SetStream(stream_id);
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Called when snapserver reports group name update
 /// </summary>
 /// <param name="id">client id</param>
 /// <param name="name">new name</param>
 private void _GroupNameChanged(string id, string name)
 {
     JsonRpcData.Group group = _GetGroup(id);
     if (group != null)
     {
         group.SERVER_SetName(name);
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// Called when snapserver reports group mute update
 /// </summary>
 /// <param name="id">group id</param>
 /// <param name="mute">new mute state</param>
 private void _GroupMuteChanged(string id, bool mute)
 {
     JsonRpcData.Group group = _GetGroup(id);
     if (group != null)
     {
         group.SERVER_SetMute(mute);
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Called when snapserver reports client volume update
        /// </summary>
        /// <param name="id">client id</param>
        /// <param name="volume">new volume object</param>\
        private void _ClientVolumeChanged(string id, Volume volume)
        {
            JsonRpcData.Group  group  = null;
            JsonRpcData.Client client = _GetClient(id, out group);
            if (client != null)
            {
                client.config.SERVER_SetVolume(volume);
                // groups are listening to the clients' volume object for change events,
                // in order to update the group volume slider. when receiving a volume
                // update from the client, the group needs to re-subscribe to this event
                group.SubscribeToClientEvent(client);

                // also resubscribe local event for volume changes, so the server gets
                // updated when the user modifies the volume
                client.config.volume.CLIENT_OnModified += () =>
                {
                    _OnLocalVolumeDataModified(client);
                };
            }
        }
Exemplo n.º 7
0
 /// <summary>
 /// called when we locally modify group's name (aka we need to notify the server)
 /// </summary>
 /// <param name="group"></param>
 private void _OnLocalGroupNameModified(JsonRpcData.Group group)
 {
     Task t = Task.Run(async() => { await _SetGroupNameAsync(group.id, group.name).ConfigureAwait(false); });
 }