Skip to content

Commit

Permalink
Working version with sounds
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoderok committed Mar 20, 2014
1 parent d6cbed0 commit c02e906
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 22 deletions.
12 changes: 10 additions & 2 deletions VsDingExtensionProject/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 4 additions & 9 deletions VsDingExtensionProject/Resources.resx
Original file line number Diff line number Diff line change
@@ -1,13 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
VS SDK Notes: This resx file contains the resources that will be consumed directly by your package.
For example, if you chose to create a tool window, there is a resource with ID 'CanNotCreateWindow'. This
is used in VsPkg.cs to determine the string to show the user if there is an error when attempting to create
the tool window.
Resources that are accessed directly from your package *by Visual Studio* are stored in the VSPackage.resx
file.
-->
<root>
<!--
Microsoft ResX Schema
Expand Down Expand Up @@ -126,4 +117,8 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="ding" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\ding.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</data>
</root>
Binary file added VsDingExtensionProject/Resources/ding.wav
Binary file not shown.
21 changes: 20 additions & 1 deletion VsDingExtensionProject/VsDingExtensionProject.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.VisualStudio.ComponentModelHost, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL" />
<Reference Include="Microsoft.VisualStudio.OLE.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.Interop.8.0" />
Expand All @@ -52,14 +53,30 @@
<EmbedInteropTypes>true</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.VisualStudio.TestWindow.Interfaces">
<HintPath>..\..\..\..\..\..\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Interfaces.dll</HintPath>
<HintPath>$(DevEnvDir)\CommonExtensions\Microsoft\TestWindow\Microsoft.VisualStudio.TestWindow.Interfaces.dll</HintPath>
</Reference>
<Reference Include="Microsoft.VisualStudio.TextManager.Interop" />
<Reference Include="Microsoft.VisualStudio.Shell.12.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.10.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.11.0" />
<Reference Include="Microsoft.VisualStudio.Shell.Immutable.12.0" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.Composition" />
<Reference Include="System.Composition.AttributedModel">
<HintPath>..\packages\Microsoft.Composition.1.0.20\lib\portable-net45+win8\System.Composition.AttributedModel.dll</HintPath>
</Reference>
<Reference Include="System.Composition.Convention">
<HintPath>..\packages\Microsoft.Composition.1.0.20\lib\portable-net45+win8\System.Composition.Convention.dll</HintPath>
</Reference>
<Reference Include="System.Composition.Hosting">
<HintPath>..\packages\Microsoft.Composition.1.0.20\lib\portable-net45+win8\System.Composition.Hosting.dll</HintPath>
</Reference>
<Reference Include="System.Composition.Runtime">
<HintPath>..\packages\Microsoft.Composition.1.0.20\lib\portable-net45+win8\System.Composition.Runtime.dll</HintPath>
</Reference>
<Reference Include="System.Composition.TypedParts">
<HintPath>..\packages\Microsoft.Composition.1.0.20\lib\portable-net45+win8\System.Composition.TypedParts.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.Data" />
<Reference Include="System.Design" />
Expand Down Expand Up @@ -146,6 +163,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="source.extension.vsixmanifest">
<SubType>Designer</SubType>
</None>
Expand All @@ -154,6 +172,7 @@
<None Include="Key.snk" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\ding.wav" />
<Content Include="Resources\Package.ico" />
</ItemGroup>
<PropertyGroup>
Expand Down
48 changes: 38 additions & 10 deletions VsDingExtensionProject/VsDingExtensionProjectPackage.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
using System;
using System.ComponentModel.Composition;
using System.ComponentModel.Composition.Hosting;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Media;
using System.Reflection;
using System.Runtime.InteropServices;
using System.ComponentModel.Design;
using EnvDTE;
using EnvDTE80;
using Microsoft.Win32;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.TestWindow.Extensibility;

namespace VitaliiGanzha.VsDingExtensionProject
{
Expand All @@ -30,6 +32,7 @@ namespace VitaliiGanzha.VsDingExtensionProject
// in the Help/About dialog of Visual Studio.
[InstalledProductRegistration("#110", "#112", "1.0", IconResourceID = 400)]
[Guid(GuidList.guidVsDingExtensionProjectPkgString)]
[ProvideAutoLoad("{f1536ef8-92ec-443c-9ed7-fdadf150da82}")]
public sealed class VsDingExtensionProjectPackage : Package
{
private DTE2 applicationObject;
Expand Down Expand Up @@ -59,25 +62,50 @@ public VsDingExtensionProjectPackage()
/// </summary>
protected override void Initialize()
{
Debug.WriteLine (string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}", this.ToString()));
Debug.WriteLine(string.Format(CultureInfo.CurrentCulture, "Entering Initialize() of: {0}",
this.ToString()));
base.Initialize();

applicationObject = (DTE2)GetService(typeof(DTE));
applicationObject = (DTE2) GetService(typeof (DTE));

applicationObject.Events.BuildEvents.OnBuildDone += BuildEventsOnOnBuildDone;
applicationObject.Events.DebuggerEvents.OnEnterBreakMode += DebuggerEventsOnOnEnterBreakMode;

IComponentModel componentModel = Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof(SComponentModel)) as IComponentModel;
var componentModel =
Microsoft.VisualStudio.Shell.Package.GetGlobalService(typeof (SComponentModel)) as IComponentModel;

if (componentModel == null)
{
throw new Exception("componentModel is null");
}

var operationState = componentModel.GetService<IOperationState>();
operationState.StateChanged += OperationStateOnStateChanged;
}

private void OperationStateOnStateChanged(object sender, OperationStateChangedEventArgs operationStateChangedEventArgs)
{
if (operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
{
PlaySound();
}
}

private void DebuggerEventsOnOnEnterBreakMode(dbgEventReason reason, ref dbgExecutionAction executionAction)
{
System.Media.SystemSounds.Asterisk.Play();
PlaySound();
}

private void BuildEventsOnOnBuildDone(vsBuildScope scope, vsBuildAction action)
{
System.Media.SystemSounds.Asterisk.Play();
PlaySound();
}

private void PlaySound()
{
SoundPlayer player = new SoundPlayer(Resources.ding);
player.PlaySync();

}

#endregion
Expand Down
3 changes: 3 additions & 0 deletions VsDingExtensionProject/packages.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
</packages>
4 changes: 4 additions & 0 deletions packages/repositories.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<repositories>
<repository path="..\VsDingExtensionProject\packages.config" />
</repositories>

0 comments on commit c02e906

Please sign in to comment.