version 1.5, taskbar notificaitons

This commit is contained in:
Vitalii Ganzha 2015-06-12 14:09:04 -07:00
parent 53734e0f8d
commit f18fcd2a14
7 changed files with 81 additions and 22 deletions

View File

@ -14,3 +14,12 @@ Useful when working with big solutions or when build/test run/hitting a breakpoi
This is an open source project, join!
Twitter: @GanzhaVitalii
Version 1.5:
* Added Task bar notifications. (https://github.com/thecoderok/vsdingextension/issues/1)
It can be disabled in Tools->Options->Ding->Show tray notifications
Version 1.4:
* Added options dialog (Tools->Options->Ding). Now it is possible to enable/disable what sounds to play. Thanks to https://github.com/dannoh
* Added option to play sounds only if Visual Studio in background. Thanks to https://github.com/dannoh
* Support for Visual studio 2015

View File

@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{5BD9D4DB-8683-4698-8D24-01EE7306F73A}"
ProjectSection(SolutionItems) = preProject
IntegrationTests.testsettings = IntegrationTests.testsettings
README.md = README.md
UnitTests.testsettings = UnitTests.testsettings
EndProjectSection
EndProject

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="ab75aa82-c4e8-42a7-b4ec-b5bae2fa4925" Version="1.4" Language="en-US" Publisher="Vitalii Ganzha" />
<Identity Id="ab75aa82-c4e8-42a7-b4ec-b5bae2fa4925" Version="1.5" Language="en-US" Publisher="Vitalii Ganzha" />
<DisplayName>Visual Studio Ding extension for VS 2012</DisplayName>
<Description xml:space="preserve">This small extension will play notification sounds when following events occur:
- Build Complete

View File

@ -12,28 +12,33 @@ namespace VitaliiGanzha.VsDingExtension
[Category("Beeps")]
[DisplayName("Breakpoint")]
[Description("Beep when a breakpoint is hit")]
public bool BreakpointBeep { get; set; }
public bool IsBeepOnBreakpointHit { get; set; }
[Category("Beeps")]
[DisplayName("Build")]
[Description("Beep when a build is completed")]
public bool BuildBeep { get; set; }
public bool IsBeepOnBuildComplete { get; set; }
[Category("Beeps")]
[DisplayName("Tests")]
[Description("Beep when a test run is completed")]
public bool TestBeep { get; set; }
public bool IsBuildOnTestComplete { get; set; }
[DisplayName("Only when in background")]
[Description("Beep only when Visual Studio does not have focus")]
public bool BeepOnUnfocus { get; set; }
public bool IsBeepOnlyWhenVisualStudioIsInBackground { get; set; }
[DisplayName("Show tray notifications")]
[Description("Show tray notifications for enabled events")]
public bool ShowTrayNotifications { get; set; }
public OptionsDialog()
{
BreakpointBeep = true;
BuildBeep = true;
TestBeep = true;
BeepOnUnfocus = false;
IsBeepOnBreakpointHit = true;
IsBeepOnBuildComplete = true;
IsBuildOnTestComplete = true;
ShowTrayNotifications = true;
IsBeepOnlyWhenVisualStudioIsInBackground = false;
}
}
}

View File

@ -1,4 +1,8 @@
Version 1.4:
Version 1.5:
* Added Task bar notifications. (https://github.com/thecoderok/vsdingextension/issues/1)
It can be disabled in Tools->Options->Ding->Show tray notifications
Version 1.4:
* Added options dialog (Tools->Options->Ding). Now it is possible to enable/disable what sounds to play. Thanks to https://github.com/dannoh
* Added option to play sounds only if Visual Studio in background. Thanks to https://github.com/dannoh
* Support for Visual studio 2015

View File

@ -2,9 +2,11 @@
{
using System;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.Media;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using EnvDTE;
@ -59,14 +61,17 @@
buildEvents.OnBuildDone += (scope, action) =>
{
if (Options.BuildBeep)
PlaySafe(buildCompleteSoundPlayer);
if (Options.IsBeepOnBuildComplete)
{
HandleEventSafe(buildCompleteSoundPlayer, "Build has been completed.");
}
};
debugEvents.OnEnterBreakMode += delegate(dbgEventReason reason, ref dbgExecutionAction action)
{
if (reason != dbgEventReason.dbgEventReasonStep && Options.BreakpointBeep)
if (reason != dbgEventReason.dbgEventReasonStep && Options.IsBeepOnBreakpointHit)
{
PlaySafe(debugSoundPlayer);
HandleEventSafe(debugSoundPlayer, "Breakpoint was hit.");
}
};
@ -95,7 +100,42 @@
}
}
private void PlaySafe(SoundPlayer soundPlayer)
private void HandleEventSafe(SoundPlayer soundPlayer, string messageText)
{
PlaySoundSafe(soundPlayer);
ShowNotifyMessage(messageText);
}
private void ShowNotifyMessage(string messageText)
{
if (!_options.ShowTrayNotifications)
{
return;
}
string autoAppendMessage = System.Environment.NewLine + "You can disable this notification in:" + System.Environment.NewLine + "Tools->Options->Ding->Show tray notifications";
messageText = string.Format("{0}{1}", messageText, autoAppendMessage);
System.Threading.Tasks.Task.Run(async () =>
{
var tray = new NotifyIcon
{
Icon = SystemIcons.Application,
BalloonTipIcon = ToolTipIcon.Info,
BalloonTipText = messageText,
BalloonTipTitle = "Visual Studio Ding extension",
Visible = true
};
tray.ShowBalloonTip(5000);
await System.Threading.Tasks.Task.Delay(5000);
tray.Icon = (Icon)null;
tray.Visible = false;
tray.Dispose();
});
}
private void PlaySoundSafe(SoundPlayer soundPlayer)
{
if (ShouldPlaySound())
{
@ -112,23 +152,23 @@
private bool ShouldPlaySound()
{
if (!Options.BeepOnUnfocus)
if (!Options.IsBeepOnlyWhenVisualStudioIsInBackground)
{
return true;
}
return Options.BeepOnUnfocus && !ApplicationIsActivated();
return Options.IsBeepOnlyWhenVisualStudioIsInBackground && !ApplicationIsActivated();
}
private void OperationStateOnStateChanged(object sender, OperationStateChangedEventArgs operationStateChangedEventArgs)
{
if (Options.TestBeep && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
if (Options.IsBuildOnTestComplete && operationStateChangedEventArgs.State.HasFlag(TestOperationStates.TestExecutionFinished))
{
PlaySafe(testCompleteSoundPlayer);
HandleEventSafe(testCompleteSoundPlayer, "Test execution has been completed.");
}
}
#endregion
public bool ApplicationIsActivated()
private bool ApplicationIsActivated()
{
var activatedHandle = GetForegroundWindow();
if (activatedHandle == IntPtr.Zero)

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata>
<Identity Id="26ba08d0-0d25-4479-8684-3054dd122876" Version="1.4" Language="en-US" Publisher="Vitalii Ganzha" />
<Identity Id="26ba08d0-0d25-4479-8684-3054dd122876" Version="1.5" Language="en-US" Publisher="Vitalii Ganzha" />
<DisplayName>Visual Studio Ding extension</DisplayName>
<Description xml:space="preserve">This small extension will play notification sounds when following events occur:
- Build Complete