diff --git a/SampleTestProject/Properties/AssemblyInfo.cs b/SampleTestProject/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..1dce719
--- /dev/null
+++ b/SampleTestProject/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("SampleTestProject")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("SampleTestProject")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("f0230a17-5be1-4adb-b2b9-39fed6d8b4c8")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/SampleTestProject/SampleTestProject.csproj b/SampleTestProject/SampleTestProject.csproj
new file mode 100644
index 0000000..cf7ae38
--- /dev/null
+++ b/SampleTestProject/SampleTestProject.csproj
@@ -0,0 +1,83 @@
+
+
+
+ Debug
+ AnyCPU
+ {3A315AD2-E21E-4FC6-A601-795989A45514}
+ Library
+ Properties
+ SampleTestProject
+ SampleTestProject
+ v4.5
+ 512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 10.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
+ False
+ UnitTest
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/SampleTestProject/UnitTests.cs b/SampleTestProject/UnitTests.cs
new file mode 100644
index 0000000..c81cc85
--- /dev/null
+++ b/SampleTestProject/UnitTests.cs
@@ -0,0 +1,21 @@
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace SampleTestProject
+{
+ [TestClass]
+ public class UnitTests
+ {
+ [TestMethod]
+ public void TestMethodSuccess()
+ {
+ Assert.IsTrue(true);
+ }
+
+ [TestMethod]
+ public void TestMethodFailure()
+ {
+ Assert.IsTrue(false);
+ }
+ }
+}
diff --git a/VsDingExtension.sln b/VsDingExtension.sln
index 17da8a4..e6aab38 100644
--- a/VsDingExtension.sln
+++ b/VsDingExtension.sln
@@ -14,6 +14,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VsDingExtensionProject", "V
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VsDingExtensionFor2012", "VsDingExtensionFor2012\VsDingExtensionFor2012.csproj", "{F37A5870-9786-4196-A3BE-51FEC6155623}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleTestProject", "SampleTestProject\SampleTestProject.csproj", "{3A315AD2-E21E-4FC6-A601-795989A45514}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -28,6 +30,10 @@ Global
{F37A5870-9786-4196-A3BE-51FEC6155623}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F37A5870-9786-4196-A3BE-51FEC6155623}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F37A5870-9786-4196-A3BE-51FEC6155623}.Release|Any CPU.Build.0 = Release|Any CPU
+ {3A315AD2-E21E-4FC6-A601-795989A45514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {3A315AD2-E21E-4FC6-A601-795989A45514}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {3A315AD2-E21E-4FC6-A601-795989A45514}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {3A315AD2-E21E-4FC6-A601-795989A45514}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
diff --git a/VsDingExtensionProject/Players.cs b/VsDingExtensionProject/Players.cs
index 5b093fa..0144d02 100644
--- a/VsDingExtensionProject/Players.cs
+++ b/VsDingExtensionProject/Players.cs
@@ -1,24 +1,61 @@
-using Microsoft.VisualStudio.Shell;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Media;
-using System.Text;
-using System.Threading.Tasks;
-
namespace VitaliiGanzha.VsDingExtension
{
- public class Players : IDisposable
- {
- private readonly Dictionary> eventTypeToSoundPlayerMapping;
+ using System;
+ using System.Collections.Generic;
+ using System.IO;
+ using System.Media;
+ using Microsoft.VisualStudio.Shell;
- public Players()
+ public sealed class Players : IDisposable
+ {
+ private readonly SoundsSelectOptionsPage overridesSettings;
+ private Dictionary> eventTypeToSoundPlayerMapping;
+
+ public Players(SoundsSelectOptionsPage overridesSettings)
{
- eventTypeToSoundPlayerMapping = new Dictionary>();
- eventTypeToSoundPlayerMapping[EventType.BuildCompleted] = new List() { new SoundPlayer(Resources.build) };
- eventTypeToSoundPlayerMapping[EventType.BreakpointHit] = new List() { new SoundPlayer(Resources.debug) };
- eventTypeToSoundPlayerMapping[EventType.TestsCompletedSuccess] = new List() { new SoundPlayer(Resources.ding) };
- eventTypeToSoundPlayerMapping[EventType.TestsCompletedFailure] = new List() { new SoundPlayer(Resources.test_failed) };
+ this.overridesSettings = overridesSettings;
+ this.SetupSounds();
+ }
+
+ private void SetupSounds()
+ {
+ // Add regular sounds
+ var tempMapping = new Dictionary>();
+ tempMapping[EventType.BuildCompleted] = new List() { new SoundPlayer(Resources.build) };
+ tempMapping[EventType.BreakpointHit] = new List() { new SoundPlayer(Resources.debug) };
+ tempMapping[EventType.TestsCompletedSuccess] = new List()
+ {
+ new SoundPlayer(Resources.ding)
+ };
+ tempMapping[EventType.TestsCompletedFailure] = new List()
+ {
+ new SoundPlayer(Resources.test_failed)
+ };
+
+ // Add custom sounds
+ this.AddSoundOverrideIf(tempMapping, this.overridesSettings.OverrideOnBuildSound, this.overridesSettings.CustomOnBuildSoundLocation, EventType.BuildCompleted);
+ this.AddSoundOverrideIf(tempMapping, this.overridesSettings.OverrideOnBreakpointHitSound, this.overridesSettings.CustomOnBreakpointHitSoundLocation, EventType.BreakpointHit);
+ this.AddSoundOverrideIf(tempMapping, this.overridesSettings.OverrideOnTestCompleteFailureSound, this.overridesSettings.CustomOnTestCompleteFailureSoundLocation, EventType.TestsCompletedFailure);
+ this.AddSoundOverrideIf(tempMapping, this.overridesSettings.OverrideOnTestCompleteSuccesSound, this.overridesSettings.CustomOnTestCompleteSuccesSoundLocation, EventType.TestsCompletedSuccess);
+
+ this.eventTypeToSoundPlayerMapping = tempMapping;
+ }
+
+ private void AddSoundOverrideIf(Dictionary> tempMapping, bool shouldAdd, string fileLocation, EventType eventType)
+ {
+ if (shouldAdd)
+ {
+ if (!string.IsNullOrWhiteSpace(fileLocation) &&
+ File.Exists(fileLocation))
+ {
+ tempMapping[eventType].Insert(0, new SoundPlayer(fileLocation));
+ }
+ }
+ }
+
+ public void SoundSettingsChanged()
+ {
+ this.SetupSounds();
}
public void PlaySoundSafe(EventType eventType)
diff --git a/VsDingExtensionProject/SingleSoundSelectControl.cs b/VsDingExtensionProject/SingleSoundSelectControl.cs
index db70a6e..e5a920e 100644
--- a/VsDingExtensionProject/SingleSoundSelectControl.cs
+++ b/VsDingExtensionProject/SingleSoundSelectControl.cs
@@ -9,7 +9,19 @@ namespace VitaliiGanzha.VsDingExtension
{
private EventType eventType = EventType.None;
- public SoundsSelectOptionsPage OptionsPage = null;
+ public SoundsSelectOptionsPage optionsPage = null;
+
+ public SoundsSelectOptionsPage OptionsPage
+ {
+ get { return this.optionsPage; }
+ set
+ {
+ this.optionsPage = value;
+ this.ReadOptions();
+ this.optionsPage.StoreOptionsNotifier += this.StoreOptions;
+ this.optionsPage.OnActivateHandler += this.ReadOptions;
+ }
+ }
[Category("Data")]
[Description("Gets or sets the event type of the sound to override sound for")]
@@ -30,13 +42,11 @@ namespace VitaliiGanzha.VsDingExtension
public SingleSoundSelectControl()
{
InitializeComponent();
- ReadOptions();
}
private void chkUseDifferentSound_CheckedChanged(object sender, System.EventArgs e)
{
ValidateProperties();
- this.StoreOptions();
}
private void btnBrowse_Click(object sender, EventArgs e)
@@ -52,7 +62,6 @@ namespace VitaliiGanzha.VsDingExtension
if (File.Exists(file))
{
this.selectedFileEdit.Text = file;
- this.StoreOptions();
}
}
diff --git a/VsDingExtensionProject/SoundsSelectOptionsPage.cs b/VsDingExtensionProject/SoundsSelectOptionsPage.cs
index c78c558..93be1e3 100644
--- a/VsDingExtensionProject/SoundsSelectOptionsPage.cs
+++ b/VsDingExtensionProject/SoundsSelectOptionsPage.cs
@@ -18,6 +18,12 @@ namespace VitaliiGanzha.VsDingExtension
#region Properties
+ public Action OnApplyHandler { get; set; }
+
+ public Action StoreOptionsNotifier { get; set; }
+
+ public Action OnActivateHandler { get; set; }
+
///
/// Gets the window an instance of DialogPage that it uses as its user interface.
///
@@ -46,6 +52,27 @@ namespace VitaliiGanzha.VsDingExtension
}
}
+ protected override void OnApply(DialogPage.PageApplyEventArgs e)
+ {
+ if (this.StoreOptionsNotifier != null)
+ {
+ this.StoreOptionsNotifier();
+ }
+
+ if (this.OnApplyHandler != null)
+ {
+ this.OnApplyHandler();
+ }
+ }
+
+ protected override void OnActivate(CancelEventArgs cancelEventArgs)
+ {
+ if (this.OnActivateHandler != null)
+ {
+ this.OnActivateHandler();
+ }
+ }
+
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
public bool OverrideOnBuildSound { get; set; }
diff --git a/VsDingExtensionProject/VsDingExtensionProjectPackage.cs b/VsDingExtensionProject/VsDingExtensionProjectPackage.cs
index 7f22586..31f9709 100644
--- a/VsDingExtensionProject/VsDingExtensionProjectPackage.cs
+++ b/VsDingExtensionProject/VsDingExtensionProjectPackage.cs
@@ -1,24 +1,19 @@
-namespace VitaliiGanzha.VsDingExtension
+namespace VitaliiGanzha.VsDingExtension
{
using System;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
- using System.Media;
using System.Runtime.InteropServices;
using System.Windows.Forms;
-
using EnvDTE;
-
using EnvDTE80;
-
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Shell;
- using Microsoft.VisualStudio.TestWindow.Extensibility;
using Microsoft.VisualStudio.TestWindow.Controller;
+ using Microsoft.VisualStudio.TestWindow.Extensibility;
+ using Task = System.Threading.Tasks.Task;
- using Process = System.Diagnostics.Process;
-
[PackageRegistration(UseManagedResourcesOnly = true)]
[InstalledProductRegistration("#110", "#112", "1.1", IconResourceID = 400)]
[Guid(GuidList.guidVsDingExtensionProjectPkgString)]
@@ -31,7 +26,8 @@
private BuildEvents buildEvents;
private DebuggerEvents debugEvents;
private OptionsDialog _options = null;
- private Players players = new Players();
+ private SoundsSelectOptionsPage soundOverridesSettings = null;
+ private Players players = null;
public VsDingExtensionProjectPackage()
{
@@ -49,6 +45,8 @@
buildEvents = applicationObject.Events.BuildEvents;
debugEvents = applicationObject.Events.DebuggerEvents;
+ players = new Players(this.SoundSettingsOverrides);
+ this.soundOverridesSettings.OnApplyHandler += () => this.players.SoundSettingsChanged();
SetupEventHandlers();
}
@@ -95,12 +93,19 @@
}
}
- private void HandleEventSafe(EventType eventType, string messageText)
+ private SoundsSelectOptionsPage SoundSettingsOverrides
{
- HandleEventSafe(eventType, messageText, ToolTipIcon.Info);
+ get
+ {
+ if (this.soundOverridesSettings == null)
+ {
+ this.soundOverridesSettings = (SoundsSelectOptionsPage)GetDialogPage(typeof(SoundsSelectOptionsPage));
+ }
+ return this.soundOverridesSettings;
+ }
}
- private void HandleEventSafe(EventType eventType, string messageText, ToolTipIcon icon)
+ private void HandleEventSafe(EventType eventType, string messageText, ToolTipIcon icon = ToolTipIcon.Info)
{
if (!ShouldPerformNotificationAction())
{
@@ -111,12 +116,7 @@
ShowNotifyMessage(messageText, icon);
}
- private void ShowNotifyMessage(string messageText)
- {
- ShowNotifyMessage(messageText, ToolTipIcon.Info);
- }
-
- private void ShowNotifyMessage(string messageText, ToolTipIcon icon)
+ private void ShowNotifyMessage(string messageText, ToolTipIcon icon = ToolTipIcon.Info)
{
if (!_options.ShowTrayNotifications)
{
@@ -125,11 +125,11 @@
if (Options.ShowTrayDisableMessage)
{
- string autoAppendMessage = System.Environment.NewLine + "You can disable this notification in:" + System.Environment.NewLine + "Tools->Options->Ding->Show tray notifications";
+ string autoAppendMessage = Environment.NewLine + "You can disable this notification in:" + Environment.NewLine + "Tools->Options->Ding->Show tray notifications";
messageText = string.Format("{0}{1}", messageText, autoAppendMessage);
}
- System.Threading.Tasks.Task.Run(async () =>
+ Task.Run(async () =>
{
var tray = new NotifyIcon
{
@@ -141,7 +141,7 @@
};
tray.ShowBalloonTip(5000);
- await System.Threading.Tasks.Task.Delay(5000);
+ await Task.Delay(5000);
tray.Icon = (Icon)null;
tray.Visible = false;
tray.Dispose();
diff --git a/VsDingExtensionProject/WinApiHelper.cs b/VsDingExtensionProject/WinApiHelper.cs
index dd96f75..7663240 100644
--- a/VsDingExtensionProject/WinApiHelper.cs
+++ b/VsDingExtensionProject/WinApiHelper.cs
@@ -1,13 +1,9 @@
-using System;
-using System.Collections.Generic;
-using System.Diagnostics;
-using System.Linq;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Threading.Tasks;
-
namespace VitaliiGanzha.VsDingExtension
{
+ using System;
+ using System.Diagnostics;
+ using System.Runtime.InteropServices;
+
public static class WinApiHelper
{
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]