Change icon for error, Add option to disable message

This commit is contained in:
Samir L. Boulema 2015-12-16 17:18:16 +01:00
parent 610f82311d
commit ce880f40ce
3 changed files with 24 additions and 6 deletions

View File

@ -37,6 +37,10 @@ namespace VitaliiGanzha.VsDingExtension
[Description("Show tray notifications for enabled events")]
public bool ShowTrayNotifications { get; set; }
[DisplayName("Tray notifications message")]
[Description("Show message how to disable tray notifications")]
public bool ShowTrayDisableMessage { get; set; }
public OptionsDialog()
{
IsBeepOnBreakpointHit = true;
@ -45,6 +49,7 @@ namespace VitaliiGanzha.VsDingExtension
IsBeepOnTestFailed = false;
ShowTrayNotifications = true;
IsBeepOnlyWhenVisualStudioIsInBackground = false;
ShowTrayDisableMessage = true;
}
}
}

View File

@ -102,6 +102,11 @@
}
private void HandleEventSafe(SoundPlayer soundPlayer, string messageText)
{
HandleEventSafe(soundPlayer, messageText, ToolTipIcon.Info);
}
private void HandleEventSafe(SoundPlayer soundPlayer, string messageText, ToolTipIcon icon)
{
if (!ShouldPerformNotificationAction())
{
@ -109,25 +114,33 @@
}
PlaySoundSafe(soundPlayer);
ShowNotifyMessage(messageText);
ShowNotifyMessage(messageText, icon);
}
private void ShowNotifyMessage(string messageText)
{
ShowNotifyMessage(messageText, ToolTipIcon.Info);
}
private void ShowNotifyMessage(string messageText, ToolTipIcon icon)
{
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);
if (Options.ShowTrayDisableMessage)
{
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,
BalloonTipIcon = icon,
BalloonTipText = messageText,
BalloonTipTitle = "Visual Studio Ding extension",
Visible = true
@ -171,7 +184,7 @@
var testOperation = ((TestRunRequest)operationStateChangedEventArgs.Operation);
if (testOperation.DominantTestState == TestState.Failed)
{
HandleEventSafe(testCompleteSoundPlayer, "Test execution failed!");
HandleEventSafe(testCompleteSoundPlayer, "Test execution failed!", ToolTipIcon.Error);
}
}
else

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.5" Language="en-US" Publisher="Vitalii Ganzha" />
<Identity Id="26ba08d0-0d25-4479-8684-3054dd122876" Version="1.6" 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