2014-03-22 00:03:52 +00:00
|
|
|
|
using System.Diagnostics;
|
2014-03-13 22:21:47 +00:00
|
|
|
|
using System.Globalization;
|
2014-03-20 23:28:02 +00:00
|
|
|
|
using System.Media;
|
2014-03-13 22:21:47 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using EnvDTE;
|
|
|
|
|
using EnvDTE80;
|
2014-03-20 23:28:02 +00:00
|
|
|
|
using Microsoft.VisualStudio.ComponentModelHost;
|
2014-03-13 22:21:47 +00:00
|
|
|
|
using Microsoft.VisualStudio.Shell;
|
2014-03-20 23:28:02 +00:00
|
|
|
|
using Microsoft.VisualStudio.TestWindow.Extensibility;
|
2014-03-13 22:21:47 +00:00
|
|
|
|
|
2014-03-22 00:03:52 +00:00
|
|
|
|
namespace VitaliiGanzha.VsDingExtension
|
2014-03-13 22:21:47 +00:00
|
|
|
|
{
|
|
|
|
|
[PackageRegistration(UseManagedResourcesOnly = true)]
|
|
|
|
|
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
|
|
|
|
|
[Guid(GuidList.guidVsDingExtensionProjectPkgString)]
|
2014-03-20 23:28:02 +00:00
|
|
|
|
[ProvideAutoLoad("{f1536ef8-92ec-443c-9ed7-fdadf150da82}")]
|
2014-03-13 22:21:47 +00:00
|
|
|
|
public sealed class VsDingExtensionProjectPackage : Package
|
|
|
|
|
{
|
|
|
|
|
private DTE2 applicationObject;
|
|
|
|
|
private AddIn addInInstance;
|
2014-03-22 00:03:52 +00:00
|
|
|
|
private BuildEvents buildEvents;
|
|
|
|
|
private DebuggerEvents debugEvents;
|
|
|
|
|
private SoundPlayer buildCompleteSoundPlayer;
|
|
|
|
|
private SoundPlayer debugSoundPlayer;
|
|
|
|
|
private SoundPlayer testCompleteSoundPlayer;
|
2014-03-13 22:21:47 +00:00
|
|
|
|
|
|
|
|
|
public VsDingExtensionProjectPackage()
|
|
|
|
|
{
|
|
|
|
|
Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering constructor for: {0}", this.ToString()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region Package Members
|
|
|
|
|
|
|
|
|
|
protected override void Initialize()
|
|
|
|
|
{
|
2014-03-20 23:28:02 +00:00
|
|
|
|
Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}",
|
|
|
|
|
this.ToString()));
|
2014-03-13 22:21:47 +00:00
|
|
|
|
base.Initialize();
|
|
|
|
|
|
2014-03-22 00:03:52 +00:00
|
|
|
|
buildCompleteSoundPlayer = new SoundPlayer(Resources.build);
|
|
|
|
|
debugSoundPlayer = new SoundPlayer(Resources.debug);
|
|
|
|
|
testCompleteSoundPlayer = new SoundPlayer(Resources.ding);
|
|
|
|
|
|
2014-03-20 23:28:02 +00:00
|
|
|
|
applicationObject = (DTE2) GetService(typeof (DTE));
|
2014-03-13 22:21:47 +00:00
|
|
|
|
|
2014-03-22 00:03:52 +00:00
|
|
|
|
this.buildEvents = applicationObject.Events.BuildEvents;
|
|
|
|
|
this.debugEvents = applicationObject.Events.DebuggerEvents;
|
|
|
|
|
|
|
|
|
|
buildEvents.OnBuildDone += (scope, action) => buildCompleteSoundPlayer.Play();
|
|
|
|
|
debugEvents.OnEnterBreakMode += (dbgEventReason reason, ref dbgExecutionAction action) => debugSoundPlayer.Play();
|
2014-03-13 22:21:47 +00:00
|
|
|
|
|
2014-03-20 23:28:02 +00:00
|
|
|
|
var componentModel =
|
|
|
|
|
Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof (SComponentModel)) as IComponentModel;
|
2014-03-13 22:21:47 +00:00
|
|
|
|
|
2014-03-20 23:28:02 +00:00
|
|
|
|
if (componentModel == null)
|
|
|
|
|
{
|
2014-03-22 00:03:52 +00:00
|
|
|
|
Debug.WriteLine("componentModel is null");
|
|
|
|
|
return;
|
2014-03-20 23:28:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var operationState = componentModel.GetService<IOperationState>();
|
|
|
|
|
operationState.StateChanged += OperationStateOnStateChanged;
|
2014-03-13 22:21:47 +00:00
|
|
|
|
}
|
2014-03-20 23:28:02 +00:00
|
|
|
|
|
|
|
|
|
private void OperationStateOnStateChanged(object sender, OperationStateChangedEventArgs operationStateChangedEventArgs)
|
|
|
|
|
{
|
2014-03-22 00:03:52 +00:00
|
|
|
|
|
2014-03-20 23:28:02 +00:00
|
|
|
|
if (operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
|
|
|
|
|
{
|
2014-03-22 00:03:52 +00:00
|
|
|
|
testCompleteSoundPlayer.Play();
|
2014-03-20 23:28:02 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-03-13 22:21:47 +00:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|