Пример #1
0
 private void EmergyStop(object sender, HotkeyEventArgs e)
 {
     using (var soundboarClient = new SoundBoardClient(_serverAddress))
     {
         soundboarClient.EmergencyStopAsync();
     }
 }
Пример #2
0
        private async Task GetSoundBoardItemsAsync()
        {
            while (!_tokenSource.Token.IsCancellationRequested)
            {
                using (var soundboarClient = new SoundBoardClient(_serverAddress))
                {
                    try
                    {
                        var soundBoardItems = Mapper.Map<IList<SoundBoardItem>, IList<Model.SoundBoardItem>>(soundboarClient.GetSoundBoardItems().ToList());
                        IEnumerable<QueueLogInfo> logs = new List<QueueLogInfo>();
                        try
                        {
                            logs = soundboarClient.GetQueueLog(QueueLogInfos != null && QueueLogInfos.Any() ? QueueLogInfos.Max(d => d.QueueTimestamp) : DateTime.Today);
                        }
                        catch (Exception ex)
                        {
                            //Old server connection??
                        }

                        RunOnGuiThread(() =>
                        {
                            if (SoundBoardItems == null)
                            {
                                SoundBoardItems = new ObservableCollection<Model.SoundBoardItem>(soundBoardItems);
                                FilteredItems.UpdateFrom(SoundBoardItems);
                            }
                            else
                                SoundBoardItems.UpdateFrom(soundBoardItems, (a, b) => a.Id == b.Id);

                            if (QueueLogInfos == null)
                                QueueLogInfos = new ObservableCollection<QueueLogInfo>(logs);
                            else
                            {
                                foreach (var logItem in logs)
                                {
                                    QueueLogInfos.Add(logItem);
                                }
                            }
                            Connected = true;
                        });
                    }
                    catch (Exception exception)
                    {
                        //todo log!!
                        Connected = false;
                        SoundBoardItems = null;
                    }
                }
                await Task.Delay(TimeSpan.FromSeconds(2), _tokenSource.Token);
            }
        }
Пример #3
0
 private void PlayItem(Guid id)
 {
     using (var soundboarClient = new SoundBoardClient(_serverAddress))
     {
         try
         {
             soundboarClient.AddToQueue(id);
         }
         catch (Exception exception)
         {
             //Todo log the exception
             ErrorMessage.Content = "Error playing soundbank item";
             var tm = new Timer(state => { _syncContext.Post(s => { ErrorMessage.Content = ""; }, null); }, null, TimeSpan.FromSeconds(6), TimeSpan.FromSeconds(6));
         }
     }
 }
Пример #4
0
 private async Task GetCurrentQueue()
 {
     while (!_tokenSource.Token.IsCancellationRequested)
     {
         using (var soundboardClient = new SoundBoardClient(_serverAddress))
         {
             try
             {
                 var queue = new ObservableCollection<SoundBoardItem>(soundboardClient.GetQueue());
                 var emergencyOn = await soundboardClient.GetEmergencyStatusAsync();
                 Debug.WriteLine(queue.Count);
                 RunOnGuiThread(() =>
                 {
                     CurrentQueue = queue;
                     Connected = true;
                     EmergencyOn = emergencyOn;
                 });
             }
             catch (Exception exception)
             {
                 //todo log!!
                 Connected = false;
                 CurrentQueue = null;
             }
         }
         await Task.Delay(TimeSpan.FromMilliseconds(500), _tokenSource.Token);
     }
 }