예제 #1
0
        private void StartAudio()
        {
            AudioPattern selectedAudioPattern = (AudioPattern)_audioPatterns.SelectedItems[0].Tag;

            _audioEndTime = DateTime.Now.AddMilliseconds((double)(_audioDuration.Value * 100));
            Program.SirenOfShameDevice.PlayAudioPattern(selectedAudioPattern, new TimeSpan(0, 0, 0, 0, (int)(_audioDuration.Value * 100)));
        }
예제 #2
0
        // no need to marshall this to the UI thread b/c we don't do any UI work
        private void OnSetAudio(int?audioPatternIndex, TimeSpan?audioDuration)
        {
            if (!_sirenOfShameDevice.IsConnected)
            {
                _log.Warn("Retrieved request to play siren, but siren wasn't connected");
                return;
            }

            AudioPattern audioPattern = audioPatternIndex == null ? null : _sirenOfShameDevice.AudioPatterns.FirstOrDefault(i => i.Id == audioPatternIndex);

            _sirenOfShameDevice.PlayAudioPattern(audioPattern, audioDuration);
        }
예제 #3
0
        private ToolStripMenuItem AudioPatternMenu(AudioPattern ap, Rule rule, string buildDefinitionId, TriggerType triggerType, string person)
        {
            bool patternIsMatch = false;

            if (rule != null && !rule.InheritAudioSettings && rule.AudioPattern != null)
            {
                patternIsMatch = rule.AudioPattern.Equals(ap);
            }
            var menu = new ToolStripMenuItem(ap.Name)
            {
                Checked = patternIsMatch
            };

            AddToolStripItems(menu.DropDownItems, GetDurations(rule, null, ap, patternIsMatch, buildDefinitionId, triggerType, person));
            return(menu);
        }
예제 #4
0
        public void InvokeSetAudio(AudioPattern audioPattern, int?duration)
        {
            if (_settings.Mute)
            {
                return;
            }

            var startSiren = SetAudio;

            if (startSiren == null)
            {
                return;
            }
            startSiren(this, new SetAudioEventArgs {
                AudioPattern = audioPattern, Duration = duration
            });
        }
예제 #5
0
 private void SelectAudioPattern(AudioPattern aPattern)
 {
     _refAudioPattern = aPattern;
     _dateAudio.SetPattern(_refAudioPattern);
     _dateAudio.Refrash();
 }
예제 #6
0
 public void SetPattern(AudioPattern audioP)
 {
     _intervals = audioP.getIntervals();
     _lenght    = audioP.getLenght();
 }
예제 #7
0
        private IEnumerable <ToolStripMenuItem> GetDurations(Rule rule, LedPattern ledPattern, AudioPattern audioPattern, bool patternIsMatch, string buildDefinitionId, TriggerType triggerType, string person)
        {
            int?duration = null;

            if (rule != null)
            {
                duration = ledPattern == null ? rule.AudioDuration : rule.LightsDuration;
            }

            var durations = _durations.Select(d => new ToolStripMenuItem(d.Value)
            {
                Checked = patternIsMatch && duration == d.Key,
                Tag     = new RuleDropDownItemTag
                {
                    AlertType         = null,
                    BuildDefinitionId = buildDefinitionId,
                    TriggerPerson     = person,
                    TriggerType       = triggerType,
                    LedPattern        = ledPattern,
                    AudioPattern      = audioPattern,
                    Duration          = d.Key
                }
            }).ToArray();

            foreach (var toolStripMenuItem in durations)
            {
                toolStripMenuItem.Click += RuleDropDownItemClick;
            }
            return(durations);
        }