private async System.Threading.Tasks.Task AddActionAsync(IDEEventType iDEEventType) { var sourceType = GetIDEEventSource(iDEEventType); if (sourceType == IDEEventSourceType.CommandEvent) { await SetEventForActionAsync(iDEEventType); } else if (sourceType == IDEEventSourceType.DteEvent) { if (iDEEventType == IDEEventType.Building) { _buildEvents.OnBuildDone += Building_OnBuildDone; _buildEvents.OnBuildBegin += Building_OnBuildBegin; } else if (iDEEventType == IDEEventType.Breakepoint) { _debuggerEvents.OnEnterBreakMode += DebuggerEvents_OnEnterBreakMode;; } else if (iDEEventType == IDEEventType.Exception) { _debuggerEvents.OnExceptionNotHandled += DebuggerEvents_OnExceptionNotHandled; _debuggerEvents.OnExceptionThrown += DebuggerEvents_OnExceptionThrown;; } } }
private void SetSoundForSingleEvent(IDEEventType iDEEventType, bool loop) { _ = System.Threading.Tasks.Task.Run(async() => { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); DamnGoodPlayer.Instance.PlaySound(iDEEventType, loop); }).ConfigureAwait(false); }
private async System.Threading.Tasks.Task SetEventForActionAsync(IDEEventType iDEEventType) { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); string actionName = IDEEventTypeMapper.IDEEventTypeToVSAction(iDEEventType); Command cmdobj = _commands.Item(actionName, 0); var commandEvent = _events.CommandEvents[cmdobj.Guid, cmdobj.ID]; commandEvent.BeforeExecute += (string Guid, int ID, object CustomIn, object CustomOut, ref bool CancelDefault) => { DamnGoodPlayer.Instance.PlaySound(iDEEventType); }; _actionCommandEvents.Add(actionName, commandEvent); }
public static string IDEEventTypeToVSAction(IDEEventType iDEEventType) { switch (iDEEventType) { case IDEEventType.FileSave: return(Action_Save); case IDEEventType.FileSaveAll: return(Action_SaveAll); case IDEEventType.Unknown: default: return(string.Empty); } }
public static string IDEEventTypeToSoundPath(IDEEventType iDEEventType) { string path = string.Empty; switch (iDEEventType) { case IDEEventType.Unknown: path = "ohno!"; break; default: path = iDEEventType.ToString(); break; } return(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Audio", $"{path}.wav")); }
public void PlaySound(IDEEventType iDEEventType, bool loop = false) { var path = IDEEventTypeMapper.IDEEventTypeToSoundPath(iDEEventType); _player.Stop(); _player.SoundLocation = path; if (MakeTheSoundEventCatcher.Instance.OptionsPage.IsAudioActive(iDEEventType)) { if (loop) { _player.PlayLooping(); } else { _player.Play(); } } }
private IDEEventSourceType GetIDEEventSource(IDEEventType iDEEventType) { return(typeof(IDEEventType).GetMember(iDEEventType.ToString()) .First() .GetCustomAttribute <IDEEventSourceAttribute>().IDEEventSourceType); }
public bool IsAudioActive(IDEEventType iDEEventType) { return(_eventTypeConfig[iDEEventType]); }