Skip to content

Commit

Permalink
added source for PhonyBalloony and SystemBalloonIntercepter
Browse files Browse the repository at this point in the history
  • Loading branch information
briandunnington committed Mar 17, 2010
1 parent 0719af9 commit 1065d5b
Show file tree
Hide file tree
Showing 28 changed files with 2,006 additions and 0 deletions.
82 changes: 82 additions & 0 deletions Growl Extras/PhonyBalloony/AppContext.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;

namespace GrowlExtras.PhonyBalloony
{
class AppContext : ApplicationContext, IDisposable
{
private WndProcReader wpr;
private SystemBalloonIntercepter sbi;

public AppContext()
{
this.wpr = new WndProcReader(WndProc);
Microsoft.Win32.SystemEvents.SessionEnding += new Microsoft.Win32.SessionEndingEventHandler(SystemEvents_SessionEnding);

// this is just a useful addition for debugging. this allows us to stop the process without logging of or shutting down the computer
#if DEBUG
Microsoft.Win32.SystemEvents.SessionSwitch += new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch);
#endif
}

public void Start()
{
Stop();

this.sbi = new SystemBalloonIntercepter(this.wpr.Handle);
sbi.Start();
}

public void Stop()
{
if (sbi != null)
{
this.sbi.Stop();
this.sbi = null;
}
}

private void WndProc(ref Message m)
{
/* this is for handling intercepted system balloon messages */
if (this.sbi != null)
sbi.ProcessWindowMessage(ref m);
}

void SystemEvents_SessionEnding(object sender, Microsoft.Win32.SessionEndingEventArgs e)
{
Stop();
}

void SystemEvents_SessionSwitch(object sender, Microsoft.Win32.SessionSwitchEventArgs e)
{
if(e.Reason == Microsoft.Win32.SessionSwitchReason.SessionUnlock)
Stop();
}

#region IDisposable Members

protected override void Dispose(bool disposing)
{
if (disposing)
{
try
{
Microsoft.Win32.SystemEvents.SessionEnding -= new Microsoft.Win32.SessionEndingEventHandler(SystemEvents_SessionEnding);
#if DEBUG
Microsoft.Win32.SystemEvents.SessionSwitch -= new Microsoft.Win32.SessionSwitchEventHandler(SystemEvents_SessionSwitch);
#endif
this.Stop();
}
catch
{
// suppress
}
}
}

#endregion
}
}
95 changes: 95 additions & 0 deletions Growl Extras/PhonyBalloony/PhonyBalloony.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>8.0.50727</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{34A423AD-4D5F-42AB-9339-DFB5FD717642}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>GrowlExtras.PhonyBalloony</RootNamespace>
<AssemblyName>PhonyBalloony</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="Growl.Connector, Version=2.0.0.0, Culture=neutral, PublicKeyToken=980c2339411be384, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Growl Connectors\NET\libraries\Growl.Connector.dll</HintPath>
</Reference>
<Reference Include="Growl.CoreLibrary, Version=2.0.0.0, Culture=neutral, PublicKeyToken=13e59d82e007b064, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\Growl Connectors\NET\libraries\Growl.CoreLibrary.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AppContext.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="SystemBalloonIntercepter.cs" />
<Compile Include="WndProcReader.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="README.txt">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Include="Resources\error.png" />
<None Include="Resources\info.png" />
<None Include="Resources\warning.png" />
<Content Include="SystemBalloonIntercepter.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="SystemBalloonIntercepter64.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
20 changes: 20 additions & 0 deletions Growl Extras/PhonyBalloony/PhonyBalloony.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PhonyBalloony", "PhonyBalloony.csproj", "{34A423AD-4D5F-42AB-9339-DFB5FD717642}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{34A423AD-4D5F-42AB-9339-DFB5FD717642}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34A423AD-4D5F-42AB-9339-DFB5FD717642}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34A423AD-4D5F-42AB-9339-DFB5FD717642}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34A423AD-4D5F-42AB-9339-DFB5FD717642}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
26 changes: 26 additions & 0 deletions Growl Extras/PhonyBalloony/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;

namespace GrowlExtras.PhonyBalloony
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
AppContext context = new AppContext();
using (context)
{
context.Start();
Application.Run(context);
context.Stop();
}
}
}
}
33 changes: 33 additions & 0 deletions Growl Extras/PhonyBalloony/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
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("PhonyBalloony")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("element code project")]
[assembly: AssemblyProduct("PhonyBalloony")]
[assembly: AssemblyCopyright("Copyright © element code project 2010")]
[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("d6ec9a72-c9a2-45c4-8960-2c0401d48677")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
84 changes: 84 additions & 0 deletions Growl Extras/PhonyBalloony/Properties/Resources.Designer.cs

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

Loading

0 comments on commit 1065d5b

Please sign in to comment.