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))); }
// 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); }
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); }
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 }); }
private void SelectAudioPattern(AudioPattern aPattern) { _refAudioPattern = aPattern; _dateAudio.SetPattern(_refAudioPattern); _dateAudio.Refrash(); }
public void SetPattern(AudioPattern audioP) { _intervals = audioP.getIntervals(); _lenght = audioP.getLenght(); }
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); }