Skip to content

Commit

Permalink
Adding test Success and Failure images to Growl notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
codereflection committed Sep 28, 2011
1 parent 1430f92 commit 54eb62e
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/Giles.Core/Giles.Core.csproj
Expand Up @@ -101,6 +101,7 @@
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Security" />
<Reference Include="System.Xml" />
</ItemGroup>
Expand All @@ -111,6 +112,10 @@
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources\checkmark.png" />
<EmbeddedResource Include="Resources\stop.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
Binary file added src/Giles.Core/Resources/checkmark.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/Giles.Core/Resources/stop.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 14 additions & 2 deletions src/Giles.Core/UI/GrowlUserDisplay.cs
@@ -1,6 +1,9 @@
using System;
using System.Drawing;
using System.Reflection;
using Giles.Core.Runners;
using Growl.Connector;
using Growl.CoreLibrary;

namespace Giles.Core.UI
{
Expand All @@ -9,6 +12,8 @@ public class GrowlUserDisplay : IUserDisplay
private GrowlConnector growl;
private NotificationType notificationType;
private Application application;
private const string successImage = "Giles.Core.Resources.checkmark.png";
private const string failureImage = "Giles.Core.Resources.stop.png";

public GrowlUserDisplay()
{
Expand All @@ -23,7 +28,7 @@ void Initialize()
{
EncryptionAlgorithm = Cryptography.SymmetricAlgorithmType.PlainText
};


growl.Register(application, new[] { notificationType });
}
Expand All @@ -39,8 +44,15 @@ public void DisplayMessage(string message, params object[] parameters)
public void DisplayResult(ExecutionResult result)
{
var title = result.ExitCode == 0 ? "Success!" : "Failures!";
var notification = new Notification(application.Name, notificationType.Name, DateTime.Now.Ticks.ToString(), title, result.Output);
Resource icon = result.ExitCode == 0 ? LoadImage(successImage) : LoadImage(failureImage);
var notification = new Notification(application.Name, notificationType.Name, DateTime.Now.Ticks.ToString(), title, result.Output) { Icon = icon };
growl.Notify(notification);
}

private static Image LoadImage(string resourceName)
{
var file = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
return Image.FromStream(file);
}
}
}

0 comments on commit 54eb62e

Please sign in to comment.