Пример #1
0
    //Remove a HDR audio source to the collection
    public void RemoveAudioSource(HDRAudioSource source)
    {
        int index = AudioSources.FindIndex(p => p.Audio == source);

        if (index != -1)
        {
            AudioSources.RemoveAt(index);
        }
    }
Пример #2
0
        private async void Ws_SourceChanged(SLOBSWebsocket sender, SLOBSSourceEvent eventdata)
        {
            if (eventdata.Type == ESLOBSEventType.SourceAdded)
            {
                var sourceItem = _translateSource(eventdata.Source, Sources.Count + 1);
                Sources.Add(sourceItem);
                if (SourceChanged != null)
                {
                    SourceChanged(this, EOBSEvent.SourceAdded, sourceItem);
                }

                //Audio item
                if (sourceItem.Audio)
                {
                    var audio = await ws.ListAudioSources();

                    AudioSources.Clear();
                    AudioSources = _translateAudioSources(audio);
                    if (AudioSourceChanged != null)
                    {
                        AudioSourceChanged(this, EOBSEvent.SourceAdded);
                    }
                }
            }
            else if (eventdata.Type == ESLOBSEventType.SourceRemoved)
            {
                var sourceItem = _translateSource(eventdata.Source, 0);
                int reindex    = 0;
                for (int i = 0; i < Sources.Count; i++)
                {
                    if (Sources[i].Id == eventdata.Source.Id)
                    {
                        Sources.RemoveAt(i);
                        sourceItem.Index = i;
                        if (SourceChanged != null)
                        {
                            SourceChanged(this, EOBSEvent.SourceRemoved, sourceItem);
                            //audio item
                            if (sourceItem.Audio)
                            {
                                for (int ia = 0; ia < AudioSources.Count; ia++)
                                {
                                    if (AudioSources[i].SourceId == sourceItem.Id)
                                    {
                                        AudioSources.RemoveAt(ia);
                                        if (AudioSourceChanged != null)
                                        {
                                            AudioSourceChanged(this, EOBSEvent.SourceUpdated);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        var source = Sources[i];
                        source.Index = reindex;
                        Sources[i]   = source;
                        reindex++;
                    }
                }
            }
            else if (eventdata.Type == ESLOBSEventType.SourceUpdated)
            {
                var sourceItem = _translateSource(eventdata.Source, 0);

                for (int i = 0; i < Sources.Count; i++)
                {
                    if (Sources[i].Id == eventdata.Source.Id)
                    {
                        sourceItem.Index = i;
                        Sources[i]       = sourceItem;
                        if (SourceChanged != null)
                        {
                            SourceChanged(this, EOBSEvent.SourceUpdated, sourceItem);
                        }

                        //audio item
                        if (sourceItem.Audio)
                        {
                            var audio = await ws.ListAudioSources();

                            AudioSources.Clear();
                            AudioSources = _translateAudioSources(audio);

                            if (AudioSourceChanged != null)
                            {
                                AudioSourceChanged(this, EOBSEvent.SourceUpdated);
                            }
                        }
                    }
                }
            }
        }