WPF NotifyIcon

--------------
Initial import

git-svn-id: https://svn.evolvesoftware.ch/repos/evolve.net/WPF/NotifyIcon@52 9f600761-6f11-4665-b6dc-0185e9171623
This commit is contained in:
Philipp Sumi
2009-03-30 22:01:35 +00:00
commit 94085b7293
41 changed files with 4161 additions and 0 deletions

38
Source/NotifyIconWpf.sln Normal file
View File

@@ -0,0 +1,38 @@
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NotifyIconWpf", "NotifyIconWpf\NotifyIconWpf.csproj", "{7AC63864-7638-41C4-969C-D3197EF2BED9}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication2", "ConsoleApplication2\ConsoleApplication2.csproj", "{A92D287A-6DD2-4D75-9CE5-64BFB990E2D8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApplication1", "ConsoleApplication1\ConsoleApplication1.csproj", "{10BB9EF0-20F9-460E-96A3-284FF0D1C2E6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample Project", "Sample Project\Sample Project.csproj", "{71C74F29-F1C2-49C5-969F-C25AC4CDFCCC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{7AC63864-7638-41C4-969C-D3197EF2BED9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AC63864-7638-41C4-969C-D3197EF2BED9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AC63864-7638-41C4-969C-D3197EF2BED9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AC63864-7638-41C4-969C-D3197EF2BED9}.Release|Any CPU.Build.0 = Release|Any CPU
{A92D287A-6DD2-4D75-9CE5-64BFB990E2D8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A92D287A-6DD2-4D75-9CE5-64BFB990E2D8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A92D287A-6DD2-4D75-9CE5-64BFB990E2D8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A92D287A-6DD2-4D75-9CE5-64BFB990E2D8}.Release|Any CPU.Build.0 = Release|Any CPU
{10BB9EF0-20F9-460E-96A3-284FF0D1C2E6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{10BB9EF0-20F9-460E-96A3-284FF0D1C2E6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{10BB9EF0-20F9-460E-96A3-284FF0D1C2E6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{10BB9EF0-20F9-460E-96A3-284FF0D1C2E6}.Release|Any CPU.Build.0 = Release|Any CPU
{71C74F29-F1C2-49C5-969F-C25AC4CDFCCC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71C74F29-F1C2-49C5-969F-C25AC4CDFCCC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71C74F29-F1C2-49C5-969F-C25AC4CDFCCC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71C74F29-F1C2-49C5-969F-C25AC4CDFCCC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,236 @@
<Project DefaultTargets="Build" ToolsVersion="3.5" InitialTargets="ValidateSolutionConfiguration;ValidateToolsVersions" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_SolutionProjectConfiguration>Debug|Any CPU</_SolutionProjectConfiguration>
<_SolutionProjectToolsVersion>3.5</_SolutionProjectToolsVersion>
<_SolutionProjectCacheVersion>3.5</_SolutionProjectCacheVersion>
</PropertyGroup>
<ItemGroup>
<_SolutionProjectProjects Include="ConsoleApplication1\ConsoleApplication1.csproj" />
<_SolutionProjectProjects Include="ConsoleApplication2\ConsoleApplication2.csproj" />
<_SolutionProjectProjects Include="NotifyIconWpf\NotifyIconWpf.csproj" />
<_SolutionProjectProjects Include="Sample Project\Sample Project.csproj" />
</ItemGroup>
<ItemGroup Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') ">
<BuildLevel0 Include="ConsoleApplication1\ConsoleApplication1.csproj">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</BuildLevel0>
<BuildLevel0 Include="ConsoleApplication2\ConsoleApplication2.csproj">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</BuildLevel0>
<BuildLevel0 Include="NotifyIconWpf\NotifyIconWpf.csproj">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</BuildLevel0>
<BuildLevel1 Include="Sample Project\Sample Project.csproj">
<Configuration>Debug</Configuration>
<Platform>AnyCPU</Platform>
</BuildLevel1>
</ItemGroup>
<ItemGroup Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') ">
<BuildLevel0 Include="ConsoleApplication1\ConsoleApplication1.csproj">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</BuildLevel0>
<BuildLevel0 Include="ConsoleApplication2\ConsoleApplication2.csproj">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</BuildLevel0>
<BuildLevel0 Include="NotifyIconWpf\NotifyIconWpf.csproj">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</BuildLevel0>
<BuildLevel1 Include="Sample Project\Sample Project.csproj">
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</BuildLevel1>
</ItemGroup>
<UsingTask TaskName="Microsoft.Build.Tasks.CreateTemporaryVCProject" AssemblyName="Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<UsingTask TaskName="Microsoft.Build.Tasks.ResolveVCProjectOutput" AssemblyName="Microsoft.Build.Tasks.v3.5, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<PropertyGroup Condition=" '$(Configuration)' == '' ">
<Configuration>Debug</Configuration>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == '' ">
<Platform>Any CPU</Platform>
</PropertyGroup>
<PropertyGroup Condition=" ('$(AspNetConfiguration)' == '') ">
<AspNetConfiguration>$(Configuration)</AspNetConfiguration>
</PropertyGroup>
<PropertyGroup>
<SolutionDir>D:\Philipp\Repositories\evolve.net\WPF\NotifyIcon\Source\</SolutionDir>
<SolutionExt>.sln</SolutionExt>
<SolutionFileName>NotifyIconWpf.sln</SolutionFileName>
<SolutionName>NotifyIconWpf</SolutionName>
<SolutionPath>D:\Philipp\Repositories\evolve.net\WPF\NotifyIcon\Source\NotifyIconWpf.sln</SolutionPath>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == '' and '$(MSBuildToolsVersion)' == '2.0'">v2.0</TargetFrameworkVersion>
<TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == '' and '$(MSBuildToolsVersion)' != '2.0'">v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') ">
<CurrentSolutionConfigurationContents>
<SolutionConfiguration xmlns="">
<ProjectConfiguration Project="{7AC63864-7638-41C4-969C-D3197EF2BED9}">Debug|AnyCPU</ProjectConfiguration>
<ProjectConfiguration Project="{A92D287A-6DD2-4D75-9CE5-64BFB990E2D8}">Debug|AnyCPU</ProjectConfiguration>
<ProjectConfiguration Project="{10BB9EF0-20F9-460E-96A3-284FF0D1C2E6}">Debug|AnyCPU</ProjectConfiguration>
<ProjectConfiguration Project="{71C74F29-F1C2-49C5-969F-C25AC4CDFCCC}">Debug|AnyCPU</ProjectConfiguration>
</SolutionConfiguration>
</CurrentSolutionConfigurationContents>
</PropertyGroup>
<PropertyGroup Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') ">
<CurrentSolutionConfigurationContents>
<SolutionConfiguration xmlns="">
<ProjectConfiguration Project="{7AC63864-7638-41C4-969C-D3197EF2BED9}">Release|AnyCPU</ProjectConfiguration>
<ProjectConfiguration Project="{A92D287A-6DD2-4D75-9CE5-64BFB990E2D8}">Release|AnyCPU</ProjectConfiguration>
<ProjectConfiguration Project="{10BB9EF0-20F9-460E-96A3-284FF0D1C2E6}">Release|AnyCPU</ProjectConfiguration>
<ProjectConfiguration Project="{71C74F29-F1C2-49C5-969F-C25AC4CDFCCC}">Release|AnyCPU</ProjectConfiguration>
</SolutionConfiguration>
</CurrentSolutionConfigurationContents>
</PropertyGroup>
<Target Name="ValidateSolutionConfiguration">
<Error Text="The specified solution configuration &quot;$(Configuration)|$(Platform)&quot; is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform=&quot;Any CPU&quot;) or leave those properties blank to use the default solution configuration." Code="MSB4126" HelpKeyword="MSBuild.SolutionInvalidSolutionConfiguration" Condition="('$(CurrentSolutionConfigurationContents)' == '') and ('$(SkipInvalidConfigurations)' != 'true')" />
<Warning Text="The specified solution configuration &quot;$(Configuration)|$(Platform)&quot; is invalid. Please specify a valid solution configuration using the Configuration and Platform properties (e.g. MSBuild.exe Solution.sln /p:Configuration=Debug /p:Platform=&quot;Any CPU&quot;) or leave those properties blank to use the default solution configuration." Code="MSB4126" HelpKeyword="MSBuild.SolutionInvalidSolutionConfiguration" Condition="('$(CurrentSolutionConfigurationContents)' == '') and ('$(SkipInvalidConfigurations)' == 'true')" />
<Message Text="Building solution configuration &quot;$(Configuration)|$(Platform)&quot;." Condition="'$(CurrentSolutionConfigurationContents)' != ''" />
</Target>
<Target Name="ValidateToolsVersions">
<Error Text="The tools version &quot;$(MSBuildToolsVersion)&quot; of the solution does not support building projects with a different tools version." Code="MSB4149" HelpKeyword="MSBuild.SolutionToolsVersionDoesNotSupportProjectToolsVersion" Condition="'$(MSBuildToolsVersion)' == '2.0' and ('$(ProjectToolsVersion)' != '2.0' and '$(ProjectToolsVersion)' != '')" />
</Target>
<Target Name="NotifyIconWpf" Condition="'$(CurrentSolutionConfigurationContents)' != ''" Outputs="@(NotifyIconWpfBuildOutput)">
<MSBuild Projects="NotifyIconWpf\NotifyIconWpf.csproj" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="NotifyIconWpfBuildOutput" />
</MSBuild>
<MSBuild Projects="NotifyIconWpf\NotifyIconWpf.csproj" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="NotifyIconWpfBuildOutput" />
</MSBuild>
</Target>
<Target Name="NotifyIconWpf:Clean" Condition="'$(CurrentSolutionConfigurationContents)' != ''">
<MSBuild Projects="NotifyIconWpf\NotifyIconWpf.csproj" Targets="Clean" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') " />
<MSBuild Projects="NotifyIconWpf\NotifyIconWpf.csproj" Targets="Clean" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') " />
</Target>
<Target Name="NotifyIconWpf:Rebuild" Condition="'$(CurrentSolutionConfigurationContents)' != ''" Outputs="@(NotifyIconWpfBuildOutput)">
<MSBuild Projects="NotifyIconWpf\NotifyIconWpf.csproj" Targets="Rebuild" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="NotifyIconWpfBuildOutput" />
</MSBuild>
<MSBuild Projects="NotifyIconWpf\NotifyIconWpf.csproj" Targets="Rebuild" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="NotifyIconWpfBuildOutput" />
</MSBuild>
</Target>
<Target Name="NotifyIconWpf:Publish" Condition="'$(CurrentSolutionConfigurationContents)' != ''">
<MSBuild Projects="NotifyIconWpf\NotifyIconWpf.csproj" Targets="Publish" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') " />
<MSBuild Projects="NotifyIconWpf\NotifyIconWpf.csproj" Targets="Publish" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') " />
</Target>
<Target Name="ConsoleApplication2" Condition="'$(CurrentSolutionConfigurationContents)' != ''" Outputs="@(ConsoleApplication2BuildOutput)">
<MSBuild Projects="ConsoleApplication2\ConsoleApplication2.csproj" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="ConsoleApplication2BuildOutput" />
</MSBuild>
<MSBuild Projects="ConsoleApplication2\ConsoleApplication2.csproj" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="ConsoleApplication2BuildOutput" />
</MSBuild>
</Target>
<Target Name="ConsoleApplication2:Clean" Condition="'$(CurrentSolutionConfigurationContents)' != ''">
<MSBuild Projects="ConsoleApplication2\ConsoleApplication2.csproj" Targets="Clean" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') " />
<MSBuild Projects="ConsoleApplication2\ConsoleApplication2.csproj" Targets="Clean" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') " />
</Target>
<Target Name="ConsoleApplication2:Rebuild" Condition="'$(CurrentSolutionConfigurationContents)' != ''" Outputs="@(ConsoleApplication2BuildOutput)">
<MSBuild Projects="ConsoleApplication2\ConsoleApplication2.csproj" Targets="Rebuild" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="ConsoleApplication2BuildOutput" />
</MSBuild>
<MSBuild Projects="ConsoleApplication2\ConsoleApplication2.csproj" Targets="Rebuild" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="ConsoleApplication2BuildOutput" />
</MSBuild>
</Target>
<Target Name="ConsoleApplication2:Publish" Condition="'$(CurrentSolutionConfigurationContents)' != ''">
<MSBuild Projects="ConsoleApplication2\ConsoleApplication2.csproj" Targets="Publish" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') " />
<MSBuild Projects="ConsoleApplication2\ConsoleApplication2.csproj" Targets="Publish" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') " />
</Target>
<Target Name="ConsoleApplication1" Condition="'$(CurrentSolutionConfigurationContents)' != ''" Outputs="@(ConsoleApplication1BuildOutput)">
<MSBuild Projects="ConsoleApplication1\ConsoleApplication1.csproj" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="ConsoleApplication1BuildOutput" />
</MSBuild>
<MSBuild Projects="ConsoleApplication1\ConsoleApplication1.csproj" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="ConsoleApplication1BuildOutput" />
</MSBuild>
</Target>
<Target Name="ConsoleApplication1:Clean" Condition="'$(CurrentSolutionConfigurationContents)' != ''">
<MSBuild Projects="ConsoleApplication1\ConsoleApplication1.csproj" Targets="Clean" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') " />
<MSBuild Projects="ConsoleApplication1\ConsoleApplication1.csproj" Targets="Clean" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') " />
</Target>
<Target Name="ConsoleApplication1:Rebuild" Condition="'$(CurrentSolutionConfigurationContents)' != ''" Outputs="@(ConsoleApplication1BuildOutput)">
<MSBuild Projects="ConsoleApplication1\ConsoleApplication1.csproj" Targets="Rebuild" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="ConsoleApplication1BuildOutput" />
</MSBuild>
<MSBuild Projects="ConsoleApplication1\ConsoleApplication1.csproj" Targets="Rebuild" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="ConsoleApplication1BuildOutput" />
</MSBuild>
</Target>
<Target Name="ConsoleApplication1:Publish" Condition="'$(CurrentSolutionConfigurationContents)' != ''">
<MSBuild Projects="ConsoleApplication1\ConsoleApplication1.csproj" Targets="Publish" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') " />
<MSBuild Projects="ConsoleApplication1\ConsoleApplication1.csproj" Targets="Publish" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') " />
</Target>
<Target Name="Sample Project" DependsOnTargets="NotifyIconWpf" Condition="'$(CurrentSolutionConfigurationContents)' != ''" Outputs="@(Sample_ProjectBuildOutput)">
<MSBuild Projects="Sample Project\Sample Project.csproj" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="Sample_ProjectBuildOutput" />
</MSBuild>
<MSBuild Projects="Sample Project\Sample Project.csproj" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="Sample_ProjectBuildOutput" />
</MSBuild>
</Target>
<Target Name="Sample Project:Clean" DependsOnTargets="NotifyIconWpf:Clean" Condition="'$(CurrentSolutionConfigurationContents)' != ''">
<MSBuild Projects="Sample Project\Sample Project.csproj" Targets="Clean" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') " />
<MSBuild Projects="Sample Project\Sample Project.csproj" Targets="Clean" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') " />
</Target>
<Target Name="Sample Project:Rebuild" DependsOnTargets="NotifyIconWpf:Rebuild" Condition="'$(CurrentSolutionConfigurationContents)' != ''" Outputs="@(Sample_ProjectBuildOutput)">
<MSBuild Projects="Sample Project\Sample Project.csproj" Targets="Rebuild" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="Sample_ProjectBuildOutput" />
</MSBuild>
<MSBuild Projects="Sample Project\Sample Project.csproj" Targets="Rebuild" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') ">
<Output TaskParameter="TargetOutputs" ItemName="Sample_ProjectBuildOutput" />
</MSBuild>
</Target>
<Target Name="Sample Project:Publish" DependsOnTargets="NotifyIconWpf:Publish" Condition="'$(CurrentSolutionConfigurationContents)' != ''">
<MSBuild Projects="Sample Project\Sample Project.csproj" Targets="Publish" Properties="Configuration=Debug; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Debug') and ('$(Platform)' == 'Any CPU') " />
<MSBuild Projects="Sample Project\Sample Project.csproj" Targets="Publish" Properties="Configuration=Release; Platform=AnyCPU; BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" Condition=" ('$(Configuration)' == 'Release') and ('$(Platform)' == 'Any CPU') " />
</Target>
<Target Name="Build" Condition="'$(CurrentSolutionConfigurationContents)' != ''" Outputs="@(CollectedBuildOutput)">
<MSBuild Condition="@(BuildLevel0) != ''" Projects="@(BuildLevel0)" Properties="Configuration=%(Configuration); Platform=%(Platform); BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" BuildInParallel="true" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)">
<Output TaskParameter="TargetOutputs" ItemName="CollectedBuildOutput" />
</MSBuild>
<Message Text="The project &quot;%(SkipLevel0.Identity)&quot; is not selected for building in solution configuration &quot;$(Configuration)|$(Platform)&quot;." Condition="@(SkipLevel0) != ''" />
<Warning Text="The project configuration for project &quot;%(MissingConfigLevel0.Identity)&quot; was not specified in the solution file for the solution configuration &quot;$(Configuration)|$(Platform)&quot;." Code="MSB4121" HelpKeyword="MSBuild.SolutionProjectConfigurationMissing" Condition="@(MissingConfigLevel0) != ''" />
<MSBuild Condition="@(BuildLevel1) != ''" Projects="@(BuildLevel1)" Properties="Configuration=%(Configuration); Platform=%(Platform); BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" ToolsVersion="$(ProjectToolsVersion)" BuildInParallel="true" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)">
<Output TaskParameter="TargetOutputs" ItemName="CollectedBuildOutput" />
</MSBuild>
<Message Text="The project &quot;%(SkipLevel1.Identity)&quot; is not selected for building in solution configuration &quot;$(Configuration)|$(Platform)&quot;." Condition="@(SkipLevel1) != ''" />
<Warning Text="The project configuration for project &quot;%(MissingConfigLevel1.Identity)&quot; was not specified in the solution file for the solution configuration &quot;$(Configuration)|$(Platform)&quot;." Code="MSB4121" HelpKeyword="MSBuild.SolutionProjectConfigurationMissing" Condition="@(MissingConfigLevel1) != ''" />
</Target>
<Target Name="Clean" Condition="'$(CurrentSolutionConfigurationContents)' != ''">
<MSBuild Condition="@(BuildLevel0) != ''" Projects="@(BuildLevel0)" Properties="Configuration=%(Configuration); Platform=%(Platform); BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" Targets="Clean" ToolsVersion="$(ProjectToolsVersion)" BuildInParallel="true" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" />
<Message Text="The project &quot;%(SkipLevel0.Identity)&quot; is not selected for building in solution configuration &quot;$(Configuration)|$(Platform)&quot;." Condition="@(SkipLevel0) != ''" />
<Warning Text="The project configuration for project &quot;%(MissingConfigLevel0.Identity)&quot; was not specified in the solution file for the solution configuration &quot;$(Configuration)|$(Platform)&quot;." Code="MSB4121" HelpKeyword="MSBuild.SolutionProjectConfigurationMissing" Condition="@(MissingConfigLevel0) != ''" />
<MSBuild Condition="@(BuildLevel1) != ''" Projects="@(BuildLevel1)" Properties="Configuration=%(Configuration); Platform=%(Platform); BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" Targets="Clean" ToolsVersion="$(ProjectToolsVersion)" BuildInParallel="true" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" />
<Message Text="The project &quot;%(SkipLevel1.Identity)&quot; is not selected for building in solution configuration &quot;$(Configuration)|$(Platform)&quot;." Condition="@(SkipLevel1) != ''" />
<Warning Text="The project configuration for project &quot;%(MissingConfigLevel1.Identity)&quot; was not specified in the solution file for the solution configuration &quot;$(Configuration)|$(Platform)&quot;." Code="MSB4121" HelpKeyword="MSBuild.SolutionProjectConfigurationMissing" Condition="@(MissingConfigLevel1) != ''" />
<Delete Files="NotifyIconWpf.sln.cache" />
</Target>
<Target Name="Rebuild" Condition="'$(CurrentSolutionConfigurationContents)' != ''" Outputs="@(CollectedBuildOutput)">
<MSBuild Condition="@(BuildLevel0) != ''" Projects="@(BuildLevel0)" Properties="Configuration=%(Configuration); Platform=%(Platform); BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" Targets="Rebuild" ToolsVersion="$(ProjectToolsVersion)" BuildInParallel="true" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)">
<Output TaskParameter="TargetOutputs" ItemName="CollectedBuildOutput" />
</MSBuild>
<Message Text="The project &quot;%(SkipLevel0.Identity)&quot; is not selected for building in solution configuration &quot;$(Configuration)|$(Platform)&quot;." Condition="@(SkipLevel0) != ''" />
<Warning Text="The project configuration for project &quot;%(MissingConfigLevel0.Identity)&quot; was not specified in the solution file for the solution configuration &quot;$(Configuration)|$(Platform)&quot;." Code="MSB4121" HelpKeyword="MSBuild.SolutionProjectConfigurationMissing" Condition="@(MissingConfigLevel0) != ''" />
<MSBuild Condition="@(BuildLevel1) != ''" Projects="@(BuildLevel1)" Properties="Configuration=%(Configuration); Platform=%(Platform); BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" Targets="Rebuild" ToolsVersion="$(ProjectToolsVersion)" BuildInParallel="true" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)">
<Output TaskParameter="TargetOutputs" ItemName="CollectedBuildOutput" />
</MSBuild>
<Message Text="The project &quot;%(SkipLevel1.Identity)&quot; is not selected for building in solution configuration &quot;$(Configuration)|$(Platform)&quot;." Condition="@(SkipLevel1) != ''" />
<Warning Text="The project configuration for project &quot;%(MissingConfigLevel1.Identity)&quot; was not specified in the solution file for the solution configuration &quot;$(Configuration)|$(Platform)&quot;." Code="MSB4121" HelpKeyword="MSBuild.SolutionProjectConfigurationMissing" Condition="@(MissingConfigLevel1) != ''" />
</Target>
<Target Name="Publish" Condition="'$(CurrentSolutionConfigurationContents)' != ''">
<MSBuild Condition="@(BuildLevel0) != ''" Projects="@(BuildLevel0)" Properties="Configuration=%(Configuration); Platform=%(Platform); BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" Targets="Publish" ToolsVersion="$(ProjectToolsVersion)" BuildInParallel="true" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" />
<Message Text="The project &quot;%(SkipLevel0.Identity)&quot; is not selected for building in solution configuration &quot;$(Configuration)|$(Platform)&quot;." Condition="@(SkipLevel0) != ''" />
<Warning Text="The project configuration for project &quot;%(MissingConfigLevel0.Identity)&quot; was not specified in the solution file for the solution configuration &quot;$(Configuration)|$(Platform)&quot;." Code="MSB4121" HelpKeyword="MSBuild.SolutionProjectConfigurationMissing" Condition="@(MissingConfigLevel0) != ''" />
<MSBuild Condition="@(BuildLevel1) != ''" Projects="@(BuildLevel1)" Properties="Configuration=%(Configuration); Platform=%(Platform); BuildingSolutionFile=true; CurrentSolutionConfigurationContents=$(CurrentSolutionConfigurationContents); SolutionDir=$(SolutionDir); SolutionExt=$(SolutionExt); SolutionFileName=$(SolutionFileName); SolutionName=$(SolutionName); SolutionPath=$(SolutionPath)" Targets="Publish" ToolsVersion="$(ProjectToolsVersion)" BuildInParallel="true" UnloadProjectsOnCompletion="$(UnloadProjectsOnCompletion)" UseResultsCache="$(UseResultsCache)" />
<Message Text="The project &quot;%(SkipLevel1.Identity)&quot; is not selected for building in solution configuration &quot;$(Configuration)|$(Platform)&quot;." Condition="@(SkipLevel1) != ''" />
<Warning Text="The project configuration for project &quot;%(MissingConfigLevel1.Identity)&quot; was not specified in the solution file for the solution configuration &quot;$(Configuration)|$(Platform)&quot;." Code="MSB4121" HelpKeyword="MSBuild.SolutionProjectConfigurationMissing" Condition="@(MissingConfigLevel1) != ''" />
</Target>
</Project>

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Hardcodet.Wpf.TaskbarNotification
{
///<summary>
/// Supported icons for the tray's ballon messages.
///</summary>
public enum BalloonIcon
{
/// <summary>
/// The balloon message is displayed without an icon.
/// </summary>
None,
/// <summary>
/// An information is displayed.
/// </summary>
Info,
/// <summary>
/// A warning is displayed.
/// </summary>
Warning,
/// <summary>
/// An error is displayed.
/// </summary>
Error
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,55 @@
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
/// <summary>
/// Flags that define the icon that is shown on a balloon
/// tooltip.
/// </summary>
public enum BalloonFlags
{
/// <summary>
/// No icon is displayed.
/// </summary>
None = 0x00,
/// <summary>
/// An information icon is displayed.
/// </summary>
Info = 0x01,
/// <summary>
/// A warning icon is displayed.
/// </summary>
Warning = 0x02,
/// <summary>
/// An error icon is displayed.
/// </summary>
Error = 0x03,
/// <summary>
/// Windows XP Service Pack 2 (SP2) and later.
/// Use a custom icon as the title icon.
/// </summary>
User = 0x04,
/// <summary>
/// Windows XP (Shell32.dll version 6.0) and later.
/// Do not play the associated sound. Applies only to balloon ToolTips.
/// </summary>
NoSound = 0x10,
/// <summary>
/// Windows Vista (Shell32.dll version 6.0.6) and later. The large version
/// of the icon should be used as the balloon icon. This corresponds to the
/// icon with dimensions SM_CXICON x SM_CYICON. If this flag is not set,
/// the icon with dimensions XM_CXSMICON x SM_CYSMICON is used.<br/>
/// - This flag can be used with all stock icons.<br/>
/// - Applications that use older customized icons (NIIF_USER with hIcon) must
/// provide a new SM_CXICON x SM_CYICON version in the tray icon (hIcon). These
/// icons are scaled down when they are displayed in the System Tray or
/// System Control Area (SCA).<br/>
/// - New customized icons (NIIF_USER with hBalloonIcon) must supply an
/// SM_CXICON x SM_CYICON version in the supplied icon (hBalloonIcon).
/// </summary>
LargeIcon = 0x20,
/// <summary>
/// Windows 7 and later.
/// </summary>
RespectQuietTime = 0x80
}
}

View File

@@ -0,0 +1,67 @@
using System;
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
/// <summary>
/// Indicates which members of a <see cref="NotifyIconData"/> structure
/// were set, and thus contain valid data or provide additional information
/// to the ToolTip as to how it should display.
/// </summary>
[Flags]
public enum IconDataMembers
{
/// <summary>
/// The message ID is set.
/// </summary>
Message = 0x01,
/// <summary>
/// The notification icon is set.
/// </summary>
Icon = 0x02,
/// <summary>
/// The tooltip is set.
/// </summary>
Tip = 0x04,
/// <summary>
/// State information (<see cref="IconState"/>) is set. This
/// applies to both <see cref="NotifyIconData.IconState"/> and
/// <see cref="NotifyIconData.StateMask"/>.
/// </summary>
State = 0x08,
/// <summary>
/// The ballon ToolTip is set. Accordingly, the following
/// members are set: <see cref="NotifyIconData.BalloonText"/>,
/// <see cref="NotifyIconData.BalloonTitle"/>, <see cref="NotifyIconData.BalloonFlags"/>,
/// and <see cref="NotifyIconData.VersionOrTimeout"/>.
/// </summary>
Info = 0x10,
/// <summary>
/// Internal identifier is set. Reserved, thus commented out.
/// </summary>
//Guid = 0x20,
/// <summary>
/// Windows Vista (Shell32.dll version 6.0.6) and later. If the ToolTip
/// cannot be displayed immediately, discard it.<br/>
/// Use this flag for ToolTips that represent real-time information which
/// would be meaningless or misleading if displayed at a later time.
/// For example, a message that states "Your telephone is ringing."<br/>
/// This modifies and must be combined with the <see cref="Info"/> flag.
/// </summary>
Realtime = 0x40,
/// <summary>
/// Windows Vista (Shell32.dll version 6.0.6) and later.
/// Use the standard ToolTip. Normally, when uVersion is set
/// to NOTIFYICON_VERSION_4, the standard ToolTip is replaced
/// by the application-drawn pop-up user interface (UI).
/// If the application wants to show the standard tooltip
/// in that case, regardless of whether the on-hover UI is showing,
/// it can specify NIF_SHOWTIP to indicate the standard tooltip
/// should still be shown.<br/>
/// Note that the NIF_SHOWTIP flag is effective until the next call
/// to Shell_NotifyIcon.
/// </summary>
UseLegacyToolTips = 0x80
}
}

View File

@@ -0,0 +1,23 @@
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
/// <summary>
/// The state of the icon - can be set to
/// hide the icon.
/// </summary>
public enum IconState
{
/// <summary>
/// The icon is visible.
/// </summary>
Visible = 0x00,
/// <summary>
/// Hide the icon.
/// </summary>
Hidden = 0x01,
/// <summary>
/// The icon is shared - currently not supported, thus commented out.
/// </summary>
//Shared = 0x02
}
}

View File

@@ -0,0 +1,46 @@
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
/// <summary>
/// Event flags for clicked events.
/// </summary>
public enum MouseEvent
{
/// <summary>
/// The mouse was moved withing the
/// taskbar icon's area.
/// </summary>
MouseMove,
/// <summary>
/// The right mouse button was clicked.
/// </summary>
IconRightMouseDown,
/// <summary>
/// The left mouse button was clicked.
/// </summary>
IconLeftMouseDown,
/// <summary>
/// The right mouse button was released.
/// </summary>
IconRightMouseUp,
/// <summary>
/// The left mouse button was released.
/// </summary>
IconLeftMouseUp,
/// <summary>
/// The middle mouse button was clicked.
/// </summary>
IconMiddleMouseDown,
/// <summary>
/// The middle mouse button was released.
/// </summary>
IconMiddleMouseUp,
/// <summary>
/// The taskbar icon was double clicked.
/// </summary>
IconDoubleClick,
/// <summary>
/// The balloon tip was clicked.
/// </summary>
BalloonToolTipClicked
}
}

View File

@@ -0,0 +1,39 @@
using System;
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
/// <summary>
/// Main operations performed on the
/// <see cref="WinApi.Shell_NotifyIcon"/> function.
/// </summary>
public enum NotifyCommand
{
/// <summary>
/// The taskbar icon is being created.
/// </summary>
Add = 0x00,
/// <summary>
/// The settings of the taskbar icon are being updated.
/// </summary>
Modify = 0x01,
/// <summary>
/// The taskbar icon is deleted.
/// </summary>
Delete = 0x02,
/// <summary>
/// Focus is returned to the taskbar icon. Currently not in use.
/// </summary>
SetFocus = 0x03,
/// <summary>
/// Shell32.dll version 5.0 and later only. Instructs the taskbar
/// to behave according to the version number specified in the
/// uVersion member of the structure pointed to by lpdata.
/// This message allows you to specify whether you want the version
/// 5.0 behavior found on Microsoft Windows 2000 systems, or the
/// behavior found on earlier Shell versions. The default value for
/// uVersion is zero, indicating that the original Windows 95 notify
/// icon behavior should be used.
/// </summary>
SetVersion = 0x04
}
}

View File

@@ -0,0 +1,153 @@
using System;
using System.Drawing;
using System.Runtime.InteropServices;
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
/// <summary>
/// A struct that is submitted in order to configure
/// the taskbar icon. Provides various members that
/// can be configured partially, according to the
/// values of the <see cref="IconDataMembers"/>
/// that were defined.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct NotifyIconData
{
/// <summary>
/// Size of this structure, in bytes.
/// </summary>
public uint cbSize;
/// <summary>
/// Handle to the window that receives notification messages associated with an icon in the
/// taskbar status area. The Shell uses hWnd and uID to identify which icon to operate on
/// when Shell_NotifyIcon is invoked.
/// </summary>
public IntPtr WindowHandle;
/// <summary>
/// Application-defined identifier of the taskbar icon. The Shell uses hWnd and uID to identify
/// which icon to operate on when Shell_NotifyIcon is invoked. You can have multiple icons
/// associated with a single hWnd by assigning each a different uID. This feature, however
/// is currently not used.
/// </summary>
public uint TaskbarIconId;
/// <summary>
/// Flags that indicate which of the other members contain valid data. This member can be
/// a combination of the NIF_XXX constants.
/// </summary>
public IconDataMembers ValidMembers;
/// <summary>
/// Application-defined message identifier. The system uses this identifier to send
/// notifications to the window identified in hWnd.
/// </summary>
public uint CallbackMessageId;
/// <summary>
/// A handle to the icon that should be displayed. Just
/// <see cref="Icon.Handle"/>.
/// </summary>
public IntPtr IconHandle;
/// <summary>
/// String with the text for a standard ToolTip. It can have a maximum of 64 characters including
/// the terminating NULL. For Version 5.0 and later, szTip can have a maximum of
/// 128 characters, including the terminating NULL.
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)] public string ToolTipText;
/// <summary>
/// State of the icon. Remember to also set the <see cref="StateMask"/>.
/// </summary>
public IconState IconState;
/// <summary>
/// A value that specifies which bits of the state member are retrieved or modified.
/// For example, setting this member to <see cref="Interop.IconState.Hidden"/>
/// causes only the item's hidden
/// state to be retrieved.
/// </summary>
public IconState StateMask;
/// <summary>
/// String with the text for a balloon ToolTip. It can have a maximum of 255 characters.
/// To remove the ToolTip, set the NIF_INFO flag in uFlags and set szInfo to an empty string.
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)] public string BalloonText;
/// <summary>
/// Mainly used to set the version when <see cref="WinApi.Shell_NotifyIcon"/> is invoked
/// with <see cref="NotifyCommand.SetVersion"/>. However, for legacy operations,
/// the same member is also used to set timouts for balloon ToolTips.
/// </summary>
public uint VersionOrTimeout;
/// <summary>
/// String containing a title for a balloon ToolTip. This title appears in boldface
/// above the text. It can have a maximum of 63 characters.
/// </summary>
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)] public string BalloonTitle;
/// <summary>
/// Adds an icon to a balloon ToolTip, which is placed to the left of the title. If the
/// <see cref="BalloonTitle"/> member is zero-length, the icon is not shown.
/// </summary>
public BalloonFlags BalloonFlags;
/// <summary>
/// Windows XP (Shell32.dll version 6.0) and later.<br/>
/// - Windows 7 and later: A registered GUID that identifies the icon.
/// This value overrides uID and is the recommended method of identifying the icon.<br/>
/// - Windows XP through Windows Vista: Reserved.
/// </summary>
public Guid TaskbarIconGuid;
/// <summary>
/// Windows Vista (Shell32.dll version 6.0.6) and later. The handle of a customized
/// balloon icon provided by the application that should be used independently
/// of the tray icon. If this member is non-NULL and the <see cref="Interop.BalloonFlags.User"/>
/// flag is set, this icon is used as the balloon icon.<br/>
/// If this member is NULL, the legacy behavior is carried out.
/// </summary>
public IntPtr CustomBalloonIconHandle;
/// <summary>
/// Creates a default data structure that provides
/// a hidden taskbar icon without the icon being set.
/// </summary>
/// <param name="handle"></param>
/// <returns></returns>
public static NotifyIconData CreateDefault(IntPtr handle)
{
var data = new NotifyIconData();
data.cbSize = (uint) Marshal.SizeOf(data);
data.WindowHandle = handle;
data.TaskbarIconId = 0x0;
data.CallbackMessageId = WindowMessageSink.CallbackMessageId;
data.VersionOrTimeout = (uint) NotifyIconVersion.Win95;
data.IconHandle = IntPtr.Zero;
//hide initially
data.IconState = IconState.Hidden;
data.StateMask = IconState.Hidden;
//set flags
data.ValidMembers = IconDataMembers.Message
| IconDataMembers.Icon
| IconDataMembers.Tip;
//reset strings
data.ToolTipText = data.BalloonText = data.BalloonTitle = String.Empty;
return data;
}
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
/// <summary>
/// The notify icon version that is used. The higher
/// the version, the more capabilities are available.
/// </summary>
public enum NotifyIconVersion
{
/// <summary>
/// Default behavior (legacy Win95).
/// </summary>
Win95 = 0x0,
/// <summary>
/// Behavior representing Win2000 an higher.
/// </summary>
Win2000 = 0x3,
/// <summary>
/// Extended tooltip support, which is available
/// for Vista and later.
/// </summary>
Vista = 0x4
}
}

View File

@@ -0,0 +1,95 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
public struct Rect
{
public int left;
public int top;
public int right;
public int bottom;
public override string ToString()
{
return "(" + left + ", " + top + ") --> (" + right + ", " + bottom + ")";
}
}
public struct TaskbarInfo
{
public int cbSize;
public IntPtr WindowHandle;
public int uCallbackMessage;
public TaskbarPosition Position;
public Rect Rectangle;
public IntPtr lParam;
}
public enum TaskbarPosition
{
Left = 0,
Top,
Right,
Bottom
}
/// <summary>
/// Locates the position of the tray area.
/// </summary>
public class TrayLocator
{
public enum ABMsg
{
ABM_NEW = 0,
ABM_REMOVE = 1,
ABM_QUERYPOS = 2,
ABM_SETPOS = 3,
ABM_GETSTATE = 4,
ABM_GETTASKBARPOS = 5,
ABM_ACTIVATE = 6,
ABM_GETAUTOHIDEBAR = 7,
ABM_SETAUTOHIDEBAR = 8,
ABM_WINDOWPOSCHANGED = 9,
ABM_SETSTATE = 10
}
public enum ABNotify
{
ABN_STATECHANGE = 0,
ABN_POSCHANGED,
ABN_FULLSCREENAPP,
ABN_WINDOWARRANGE
}
[DllImport("shell32.dll", EntryPoint = "SHAppBarMessage", CharSet = CharSet.Ansi, SetLastError = true, ExactSpelling = true)]
public static extern int SHAppBarMessage(int dwMessage, ref TaskbarInfo pData);
/// <summary>
/// Determines the current location of the taskbar.
/// </summary>
/// <returns></returns>
public static TaskbarInfo GetTaskbarInformation()
{
TaskbarInfo tbInfo = new TaskbarInfo();
tbInfo.cbSize = Marshal.SizeOf(tbInfo);
//retrieve the bounding rectangle of the Windows taskbar.
SHAppBarMessage((int)ABMsg.ABM_GETTASKBARPOS, ref tbInfo);
return tbInfo;
}
}
}

View File

@@ -0,0 +1,80 @@
using System;
using System.Runtime.InteropServices;
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
/// <summary>
/// Win32 API imports.
/// </summary>
internal static class WinApi
{
/// <summary>
/// Creates, updates or deletes the taskbar icon.
/// </summary>
[DllImport("shell32.Dll")]
public static extern bool Shell_NotifyIcon(NotifyCommand cmd, [In]ref NotifyIconData data);
/// <summary>
/// Creates the helper window that receives messages from the taskar icon.
/// </summary>
[DllImport("USER32.DLL", EntryPoint = "CreateWindowExW", SetLastError = true)]
public static extern IntPtr CreateWindowEx(int dwExStyle, [MarshalAs(UnmanagedType.LPWStr)] string lpClassName,
[MarshalAs(UnmanagedType.LPWStr)] string lpWindowName, int dwStyle, int x, int y,
int nWidth, int nHeight, uint hWndParent, int hMenu, int hInstance,
int lpParam);
/// <summary>
/// Processes a default windows procedure.
/// </summary>
[DllImport("USER32.DLL")]
public static extern long DefWindowProc(IntPtr hWnd, uint msg, uint wparam, uint lparam);
/// <summary>
/// Registers the helper window class.
/// </summary>
[DllImport("USER32.DLL", EntryPoint = "RegisterClassW", SetLastError = true)]
public static extern short RegisterClass(ref WindowClass lpWndClass);
/// <summary>
/// Registers a listener for a window message.
/// </summary>
/// <param name="lpString"></param>
/// <returns></returns>
[DllImport("User32.Dll", EntryPoint = "RegisterWindowMessageW")]
public static extern uint RegisterWindowMessage([MarshalAs(UnmanagedType.LPWStr)] string lpString);
/// <summary>
/// Used to destroy the hidden helper window that receives messages from the
/// taskbar icon.
/// </summary>
/// <param name="hWnd"></param>
/// <returns></returns>
[DllImport("USER32.DLL", SetLastError = true)]
public static extern bool DestroyWindow(IntPtr hWnd);
/// <summary>
/// Gives focus to a given window.
/// </summary>
/// <param name="hWnd"></param>
/// <returns></returns>
[DllImport("USER32.DLL")]
public static extern bool SetForegroundWindow(IntPtr hWnd);
/// <summary>
/// Gets the maximum number of milliseconds that can elapse between a
/// first click and a second click for the OS to consider the
/// mouse action a double-click.
/// </summary>
/// <returns>The maximum amount of time, in milliseconds, that can
/// elapse between a first click and a second click for the OS to
/// consider the mouse action a double-click.</returns>
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static extern int GetDoubleClickTime();
}
}

View File

@@ -0,0 +1,31 @@
using System;
using System.Runtime.InteropServices;
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
/// <summary>
/// Callback delegate which is used by the Windows API to
/// submit window messages.
/// </summary>
public delegate long WindowProcedureHandler(IntPtr hwnd, uint uMsg, uint wparam, uint lparam);
/// <summary>
/// Win API WNDCLASS struct - represents a single window.
/// Used to receive window messages.
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct WindowClass
{
public uint style;
public WindowProcedureHandler lpfnWndProc;
public int cbClsExtra;
public int cbWndExtra;
public IntPtr hInstance;
public IntPtr hIcon;
public IntPtr hCursor;
public IntPtr hbrBackground;
[MarshalAs(UnmanagedType.LPWStr)] public string lpszMenuName;
[MarshalAs(UnmanagedType.LPWStr)] public string lpszClassName;
}
}

View File

@@ -0,0 +1,102 @@
using System;
using System.ComponentModel;
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
/// <summary>
/// Provides low level code that is used to receive
/// window messages without having a window that
/// prevents a WPF application from shutting down
/// properly.
/// </summary>
public partial class WindowMessageSink
{
/// <summary>
/// Window class ID.
/// </summary>
private string WindowId;
/// <summary>
/// Handle for the message window.
/// </summary
internal IntPtr MessageWindowHandle { get; private set; }
/// <summary>
/// The ID of the message that is being received if the
/// taskbar is (re)started.
/// </summary>
private uint taskbarRestartMessageId;
/// <summary>
/// A delegate that processes messages of the hidden
/// native window that receives window messages. Storing
/// this reference makes sure we don't loose our reference
/// to the message window.
/// </summary>
private WindowProcedureHandler messageHandler;
/// <summary>
/// Creates the helper message window that is used
/// to receive messages from the taskbar icon.
/// </summary>
private void CreateMessageWindow()
{
WindowId = "WPFTaskbarIcon_" + Guid.NewGuid().ToString();
//register window message handler
messageHandler = OnWindowMessageReceived;
// Create a simple window class which is reference through
//the messageHandler delegate
WindowClass wc;
wc.style = 0;
wc.lpfnWndProc = messageHandler;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = IntPtr.Zero;
wc.hIcon = IntPtr.Zero;
wc.hCursor = IntPtr.Zero;
wc.hbrBackground = IntPtr.Zero;
wc.lpszMenuName = "";
wc.lpszClassName = WindowId;
// Register the window class
WinApi.RegisterClass(ref wc);
// Get the message used to indicate the taskbar has been restarted
// This is used to re-add icons when the taskbar restarts
taskbarRestartMessageId = WinApi.RegisterWindowMessage("TaskbarCreated");
// Create the message window
MessageWindowHandle = WinApi.CreateWindowEx(0, WindowId, "", 0, 0, 0, 1, 1, 0, 0, 0, 0);
if (MessageWindowHandle == IntPtr.Zero)
{
throw new Win32Exception();
}
}
/// <summary>
/// Callback method that receives messages from the taskbar area.
/// </summary>
private long OnWindowMessageReceived(IntPtr hwnd, uint messageId, uint wparam, uint lparam)
{
if (messageId == taskbarRestartMessageId)
{
//recreate the icon if the taskbar was restarted
//TODO refresh icon
}
ProcessWindowMessage(messageId, wparam, lparam);
//handle mouse clicks...
// Pass the message to the default window procedure
return WinApi.DefWindowProc(hwnd, messageId, wparam, lparam);
}
}
}

View File

@@ -0,0 +1,255 @@
using System;
using System.Diagnostics;
namespace Hardcodet.Wpf.TaskbarNotification.Interop
{
/// <summary>
/// Receives messages from the taskbar icon through
/// window messages of an underlying helper window.
/// </summary>
public partial class WindowMessageSink : IDisposable
{
#region members
/// <summary>
/// The ID of messages that are received from the the
/// taskbar icon.
/// </summary>
public const int CallbackMessageId = 0x400;
/// <summary>
/// The version of the underlying icon. Defines how
/// incoming messages are interpreted.
/// </summary>
public NotifyIconVersion Version { get; set; }
#endregion
#region events
/// <summary>
/// The custom tooltip should be closed or hidden.
/// </summary>
public event Action<bool> ChangeToolTipStateRequest;
/// <summary>
/// Fired in case the user clicked or moved within
/// the taskbar icon area.
/// </summary>
public event Action<MouseEvent> MouseEventReceived;
/// <summary>
/// Fired if a balloon ToolTip was either displayed
/// or closed (indicated by the boolean flag).
/// </summary>
public event Action<bool> BallonToolTipChanged;
/// <summary>
/// Fired if the taskbar was created. Requires the taskbar
/// icon to be reset.
/// </summary>
public event Action TaskbarCreated;
#endregion
#region construction
/// <summary>
/// Creates a new message sink that receives message from
/// a given taskbar icon.
/// </summary>
/// <param name="version"></param>
public WindowMessageSink(NotifyIconVersion version)
{
Version = version;
CreateMessageWindow();
}
private WindowMessageSink()
{
}
/// <summary>
/// Creates a dummy instance that provides an empty
/// pointer rather than a real window handler.<br/>
/// Used at design time.
/// </summary>
/// <returns></returns>
internal static WindowMessageSink CreateEmpty()
{
return new WindowMessageSink
{
MessageWindowHandle = IntPtr.Zero,
Version = NotifyIconVersion.Vista
};
}
#endregion
#region Process Window Messages
/// <summary>
/// Processes incoming system messages.
/// </summary>
/// <param name="msg"></param>
/// <param name="wParam"></param>
/// <param name="lParam"></param>
/// <returns></returns>
private void ProcessWindowMessage(uint msg, uint wParam, uint lParam)
{
if (msg != CallbackMessageId) return;
switch (lParam)
{
case 0x200:
// Debug.WriteLine("MOVE");
MouseEventReceived(MouseEvent.MouseMove);
break;
case 0x201:
Debug.WriteLine("left down 1");
MouseEventReceived(MouseEvent.IconLeftMouseDown);
break;
case 0x202:
Debug.WriteLine("left up");
MouseEventReceived(MouseEvent.IconLeftMouseUp);
break;
case 0x203:
Debug.WriteLine("left click 2");
MouseEventReceived(MouseEvent.IconDoubleClick);
break;
case 0x204:
Debug.WriteLine("right click 1");
MouseEventReceived(MouseEvent.IconRightMouseDown);
break;
case 0x205:
Console.Out.WriteLine("right mouse up");
MouseEventReceived(MouseEvent.IconRightMouseUp);
break;
case 0x206:
//double click with right mouse button - do not trigger event
Debug.WriteLine("right click 2");
break;
case 0x207:
Debug.WriteLine("middle click 1");
MouseEventReceived(MouseEvent.IconMiddleMouseDown);
break;
case 520:
Debug.WriteLine("mouse up middle");
MouseEventReceived(MouseEvent.IconMiddleMouseUp);
break;
case 0x209:
//double click with middle mouse button - do not trigger event
Debug.WriteLine("middle click 2");
break;
case 0x402:
Debug.WriteLine("balloon shown");
BallonToolTipChanged(true);
break;
case 0x403:
case 0x404:
Debug.WriteLine("balloon close");
BallonToolTipChanged(false);
break;
case 0x405:
Debug.WriteLine("balloon clicked");
MouseEventReceived(MouseEvent.BalloonToolTipClicked);
break;
case 0x406:
Debug.WriteLine("show custom tooltip");
ChangeToolTipStateRequest(true);
break;
case 0x407:
Debug.WriteLine("close custom tooltip");
ChangeToolTipStateRequest(false);
break;
default:
Debug.WriteLine("Unhandled message ID: " + lParam);
break;
}
}
#endregion
#region Dispose
/// <summary>
/// Set to true as soon as <see cref="Dispose"/>
/// has been invoked.
/// </summary>
public bool IsDisposed { get; private set; }
/// <summary>
/// Disposes the object.
/// </summary>
/// <remarks>This method is not virtual by design. Derived classes
/// should override <see cref="Dispose(bool)"/>.
/// </remarks>
public void Dispose()
{
Dispose(true);
// This object will be cleaned up by the Dispose method.
// Therefore, you should call GC.SupressFinalize to
// take this object off the finalization queue
// and prevent finalization code for this object
// from executing a second time.
GC.SuppressFinalize(this);
}
/// <summary>
/// This destructor will run only if the <see cref="Dispose()"/>
/// method does not get called. This gives this base class the
/// opportunity to finalize.
/// <para>
/// Important: Do not provide destructors in types derived from
/// this class.
/// </para>
/// </summary>
~WindowMessageSink()
{
Dispose(false);
}
/// <summary>
/// Removes the windows hook that receives window
/// messages and closes the underlying helper window.
/// </summary>
private void Dispose(bool disposing)
{
//don't do anything if the component is already disposed
if (IsDisposed || !disposing) return;
IsDisposed = true;
WinApi.DestroyWindow(MessageWindowHandle);
messageHandler = null;
}
#endregion
}
}

View File

@@ -0,0 +1,108 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{7AC63864-7638-41C4-969C-D3197EF2BED9}</ProjectGuid>
<OutputType>library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Hardcodet.Wpf.TaskbarNotification</RootNamespace>
<AssemblyName>Hardcodet.Wpf.TaskbarNotification</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<TargetFrameworkSubset>Client</TargetFrameworkSubset>
</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>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<Compile Include="BalloonIcon.cs" />
<Compile Include="Interop\TrayLocator.cs" />
<Compile Include="Interop\WindowMessageSink.Handle.cs" />
<Compile Include="Interop\WindowClass.cs" />
<Compile Include="PopupActivationMode.cs" />
<Compile Include="RoutedEventHelper.cs" />
<Compile Include="TaskbarIcon.Interop.cs" />
<Compile Include="Interop\WinApi.cs" />
<Compile Include="Interop\MouseEvent.cs" />
<Compile Include="Interop\NotifyCommand.cs" />
<Compile Include="Interop\NotifyIconData.cs" />
<Compile Include="Interop\IconDataMembers.cs" />
<Compile Include="Interop\IconState.cs" />
<Compile Include="Interop\NotifyIconVersion.cs" />
<Compile Include="Interop\BalloonFlags.cs" />
<Compile Include="Interop\WindowMessageSink.cs" />
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<Compile Include="TaskbarIcon.cs" />
<Compile Include="TaskbarIcon.Declarations.cs" />
<Compile Include="Util.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<Resource Include="DefaultTrayIcon.ico" />
</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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,45 @@
namespace Hardcodet.Wpf.TaskbarNotification
{
/// <summary>
/// Defines flags that define when a popup
/// is being displyed.
/// </summary>
public enum PopupActivationMode
{
/// <summary>
/// The item is displayed if the user clicks the
/// tray icon with the left mouse button.
/// </summary>
LeftClick,
/// <summary>
/// The item is displayed if the user clicks the
/// tray icon with the right mouse button.
/// </summary>
RightClick,
/// <summary>
/// The item is displayed if the user double-clicks the
/// tray icon.
/// </summary>
DoubleClick,
/// <summary>
/// The item is displayed if the user clicks the
/// tray icon with the left or the right mouse button.
/// </summary>
LeftOrRightClick,
/// <summary>
/// The item is displayed if the user clicks the
/// tray icon with the left mouse button or if a
/// double-click is being performed.
/// </summary>
LeftOrDoubleClick,
/// <summary>
/// The item is displayed if the user clicks the
/// tray icon with the middle mouse button.
/// </summary>
MiddleClick,
/// <summary>
/// The item is displayed whenever a click occurs.
/// </summary>
All
}
}

View File

@@ -0,0 +1,59 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Markup;
// 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("NotifyIconWpf")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("NotifyIconWpf")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: XmlnsDefinition("http://www.hardcodet.net/taskbar", "Hardcodet.Wpf.TaskbarNotification")]
// 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)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// 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")]

View File

@@ -0,0 +1,70 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Hardcodet.Wpf.TaskbarNotification.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Hardcodet.Wpf.TaskbarNotification.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
internal static System.Drawing.Icon DefaultTrayIcon {
get {
object obj = ResourceManager.GetObject("DefaultTrayIcon", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
}
}

View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="DefaultTrayIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\defaulttrayicon.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Hardcodet.Wpf.TaskbarNotification.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,81 @@
using System;
using System.Windows;
namespace Hardcodet.Wpf.TaskbarNotification
{
/// <summary>
/// Helper class used by routed events of the
/// <see cref="TaskbarIcon"/> class.
/// </summary>
internal static class RoutedEventHelper
{
#region RoutedEvent Helper Methods
/// <summary>
/// A static helper method to raise a routed event on a target UIElement or ContentElement.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
/// <param name="args">RoutedEventArgs to use when raising the event</param>
internal static void RaiseEvent(DependencyObject target, RoutedEventArgs args)
{
if (target is UIElement)
{
(target as UIElement).RaiseEvent(args);
}
else if (target is ContentElement)
{
(target as ContentElement).RaiseEvent(args);
}
}
/// <summary>
/// A static helper method that adds a handler for a routed event
/// to a target UIElement or ContentElement.
/// </summary>
/// <param name="element">UIElement or ContentElement that listens to the event</param>
/// <param name="routedEvent">Event that will be handled</param>
/// <param name="handler">Event handler to be added</param>
internal static void AddHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
{
UIElement uie = element as UIElement;
if (uie != null)
{
uie.AddHandler(routedEvent, handler);
}
else
{
ContentElement ce = element as ContentElement;
if (ce != null)
{
ce.AddHandler(routedEvent, handler);
}
}
}
/// <summary>
/// A static helper method that removes a handler for a routed event
/// from a target UIElement or ContentElement.
/// </summary>
/// <param name="element">UIElement or ContentElement that listens to the event</param>
/// <param name="routedEvent">Event that will no longer be handled</param>
/// <param name="handler">Event handler to be removed</param>
internal static void RemoveHandler(DependencyObject element, RoutedEvent routedEvent, Delegate handler)
{
UIElement uie = element as UIElement;
if (uie != null)
{
uie.RemoveHandler(routedEvent, handler);
}
else
{
ContentElement ce = element as ContentElement;
if (ce != null)
{
ce.RemoveHandler(routedEvent, handler);
}
}
}
#endregion
}
}

View File

@@ -0,0 +1,868 @@
using System;
using System.Drawing;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using Hardcodet.Wpf.TaskbarNotification.Interop;
namespace Hardcodet.Wpf.TaskbarNotification
{
/// <summary>
/// Contains declarations of WPF dependency properties
/// and events.
/// </summary>
partial class TaskbarIcon
{
//DEPENDENCY PROPERTIES
#region ToolTipText dependency property
/// <summary>
/// A tooltip text that is being displayed if no custom <see cref="ToolTip"/>
/// was set or if custom tooltips are not supported.
/// </summary>
public static readonly DependencyProperty ToolTipTextProperty =
DependencyProperty.Register("ToolTipText",
typeof (string),
typeof (TaskbarIcon),
new FrameworkPropertyMetadata(String.Empty, ToolTipTextPropertyChanged));
/// <summary>
/// A property wrapper for the <see cref="ToolTipTextProperty"/>
/// dependency property:<br/>
/// A tooltip text that is being displayed if no custom <see cref="ToolTip"/>
/// was set or if custom tooltips are not supported.
/// </summary>
public string ToolTipText
{
get { return (string) GetValue(ToolTipTextProperty); }
set { SetValue(ToolTipTextProperty, value); }
}
/// <summary>
/// A static callback listener which is being invoked if the
/// <see cref="ToolTipTextProperty"/> dependency property has
/// been changed. Invokes the <see cref="OnToolTipTextPropertyChanged"/>
/// instance method of the changed instance.
/// </summary>
/// <param name="d">The currently processed owner of the property.</param>
/// <param name="e">Provides information about the updated property.</param>
private static void ToolTipTextPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TaskbarIcon owner = (TaskbarIcon) d;
owner.OnToolTipTextPropertyChanged(e);
}
/// <summary>
/// Handles changes of the <see cref="ToolTipTextProperty"/> dependency property. As
/// WPF internally uses the dependency property system and bypasses the
/// <see cref="ToolTipText"/> property wrapper, updates of the property's value
/// should be handled here.
/// </summary
/// <param name="e">Provides information about the updated property.</param>
private void OnToolTipTextPropertyChanged(DependencyPropertyChangedEventArgs e)
{
string newValue = (string) e.NewValue;
iconData.ToolTipText = newValue ?? String.Empty;
WriteToolTipSettings();
}
#endregion
#region ToolTip dependency property override
/// <summary>
/// A static callback listener which is being invoked if the
/// <see cref="FrameworkElement.ToolTipProperty"/> dependency property has
/// been changed. Invokes the <see cref="OnToolTipPropertyChanged"/>
/// instance method of the changed instance.
/// </summary>
/// <param name="d">The currently processed owner of the property.</param>
/// <param name="e">Provides information about the updated property.</param>
private static void ToolTipPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TaskbarIcon owner = (TaskbarIcon) d;
owner.OnToolTipPropertyChanged(e);
}
/// <summary>
/// Handles changes of the <see cref="FrameworkElement.ToolTipProperty"/> dependency property. As
/// WPF internally uses the dependency property system and bypasses the
/// <see cref="ToolTip"/> property wrapper, updates of the property's value
/// should be handled here.
/// </summary
/// <param name="e">Provides information about the updated property.</param>
private void OnToolTipPropertyChanged(DependencyPropertyChangedEventArgs e)
{
if (e.NewValue != null)
{
ToolTip tt = e.NewValue as ToolTip;
if (tt == null)
{
tt = new ToolTip();
tt.Content = e.NewValue;
ToolTip = tt;
return;
}
}
WriteToolTipSettings();
}
#endregion
#region Icon property / IconSource dependency property
private Icon icon;
/// <summary>
/// Gets or sets the icon to be displayed. This is not a
/// dependency property - if you want to assign the property
/// through XAML, please use the <see cref="IconSource"/>
/// dependency property.
/// </summary>
public Icon Icon
{
get { return icon; }
set
{
icon = value;
iconData.IconHandle = value == null ? IntPtr.Zero : icon.Handle;
Util.WriteIconData(ref iconData, NotifyCommand.Modify, IconDataMembers.Icon);
}
}
/// <summary>
/// Resolves an image source and updates the <see cref="Icon" /> property accordingly.
/// </summary>
public static readonly DependencyProperty IconSourceProperty =
DependencyProperty.Register("IconSource",
typeof (ImageSource),
typeof (TaskbarIcon),
new FrameworkPropertyMetadata(null, IconSourcePropertyChanged));
/// <summary>
/// A property wrapper for the <see cref="IconSourceProperty"/>
/// dependency property:<br/>
/// Resolves an image source and updates the <see cref="Icon" /> property accordingly.
/// </summary>
public ImageSource IconSource
{
get { return (ImageSource) GetValue(IconSourceProperty); }
set { SetValue(IconSourceProperty, value); }
}
/// <summary>
/// A static callback listener which is being invoked if the
/// <see cref="IconSourceProperty"/> dependency property has
/// been changed. Invokes the <see cref="OnIconSourcePropertyChanged"/>
/// instance method of the changed instance.
/// </summary>
/// <param name="d">The currently processed owner of the property.</param>
/// <param name="e">Provides information about the updated property.</param>
private static void IconSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TaskbarIcon owner = (TaskbarIcon) d;
owner.OnIconSourcePropertyChanged(e);
}
/// <summary>
/// Handles changes of the <see cref="IconSourceProperty"/> dependency property. As
/// WPF internally uses the dependency property system and bypasses the
/// <see cref="IconSource"/> property wrapper, updates of the property's value
/// should be handled here.
/// </summary
/// <param name="e">Provides information about the updated property.</param>
private void OnIconSourcePropertyChanged(DependencyPropertyChangedEventArgs e)
{
ImageSource newValue = (ImageSource) e.NewValue;
Icon = newValue.ToIcon();
}
#endregion
#region TaskbarIconPopup dependency property
/// <summary>
/// A custom popup that is displayed when the taskbar icon is clicked.
/// </summary>
public static readonly DependencyProperty TaskbarIconPopupProperty =
DependencyProperty.Register("TaskbarIconPopup",
typeof (Popup),
typeof (TaskbarIcon),
new FrameworkPropertyMetadata(null, TaskbarIconPopupPropertyChanged));
/// <summary>
/// A property wrapper for the <see cref="TaskbarIconPopupProperty"/>
/// dependency property:<br/>
/// A custom popup that is displayed when the taskbar icon is clicked.
/// </summary>
public Popup TaskbarIconPopup
{
get { return (Popup) GetValue(TaskbarIconPopupProperty); }
set { SetValue(TaskbarIconPopupProperty, value); }
}
/// <summary>
/// A static callback listener which is being invoked if the
/// <see cref="TaskbarIconPopupProperty"/> dependency property has
/// been changed. Invokes the <see cref="OnTaskbarIconPopupPropertyChanged"/>
/// instance method of the changed instance.
/// </summary>
/// <param name="d">The currently processed owner of the property.</param>
/// <param name="e">Provides information about the updated property.</param>
private static void TaskbarIconPopupPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TaskbarIcon owner = (TaskbarIcon) d;
owner.OnTaskbarIconPopupPropertyChanged(e);
}
/// <summary>
/// Handles changes of the <see cref="TaskbarIconPopupProperty"/> dependency property. As
/// WPF internally uses the dependency property system and bypasses the
/// <see cref="TaskbarIconPopup"/> property wrapper, updates of the property's value
/// should be handled here.
/// </summary
/// <param name="e">Provides information about the updated property.</param>
private void OnTaskbarIconPopupPropertyChanged(DependencyPropertyChangedEventArgs e)
{
Popup newValue = (Popup) e.NewValue;
}
#endregion
#region MenuActivation dependency property
/// <summary>
/// Defines what mouse events display the context menu.
/// Defaults to <see cref="PopupActivationMode.RightClick"/>.
/// </summary>
public static readonly DependencyProperty MenuActivationProperty =
DependencyProperty.Register("MenuActivation",
typeof (PopupActivationMode),
typeof (TaskbarIcon),
new FrameworkPropertyMetadata(PopupActivationMode.RightClick, MenuActivationPropertyChanged));
/// <summary>
/// A property wrapper for the <see cref="MenuActivationProperty"/>
/// dependency property:<br/>
/// Defines what mouse events display the context menu.
/// Defaults to <see cref="PopupActivationMode.RightClick"/>.
/// </summary>
public PopupActivationMode MenuActivation
{
get { return (PopupActivationMode) GetValue(MenuActivationProperty); }
set { SetValue(MenuActivationProperty, value); }
}
/// <summary>
/// A static callback listener which is being invoked if the
/// <see cref="MenuActivationProperty"/> dependency property has
/// been changed. Invokes the <see cref="OnMenuActivationPropertyChanged"/>
/// instance method of the changed instance.
/// </summary>
/// <param name="d">The currently processed owner of the property.</param>
/// <param name="e">Provides information about the updated property.</param>
private static void MenuActivationPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TaskbarIcon owner = (TaskbarIcon) d;
owner.OnMenuActivationPropertyChanged(e);
}
/// <summary>
/// Handles changes of the <see cref="MenuActivationProperty"/> dependency property. As
/// WPF internally uses the dependency property system and bypasses the
/// <see cref="MenuActivation"/> property wrapper, updates of the property's value
/// should be handled here.
/// </summary
/// <param name="e">Provides information about the updated property.</param>
private void OnMenuActivationPropertyChanged(DependencyPropertyChangedEventArgs e)
{
PopupActivationMode newValue = (PopupActivationMode) e.NewValue;
//TODO provide implementation
throw new NotImplementedException("Change event handler for dependency property MenuActivation not implemented.");
}
#endregion
#region PopupActivation dependency property
/// <summary>
/// Defines what mouse events trigger the <see cref="IconPopup" />.
/// Default is <see cref="PopupActivationMode.LeftClick" />.
/// </summary>
public static readonly DependencyProperty PopupActivationProperty =
DependencyProperty.Register("PopupActivation",
typeof (PopupActivationMode),
typeof (TaskbarIcon),
new FrameworkPropertyMetadata(PopupActivationMode.LeftClick, PopupActivationPropertyChanged));
/// <summary>
/// A property wrapper for the <see cref="PopupActivationProperty"/>
/// dependency property:<br/>
/// Defines what mouse events trigger the <see cref="IconPopup" />.
/// Default is <see cref="PopupActivationMode.LeftClick" />.
/// </summary>
public PopupActivationMode PopupActivation
{
get { return (PopupActivationMode) GetValue(PopupActivationProperty); }
set { SetValue(PopupActivationProperty, value); }
}
/// <summary>
/// A static callback listener which is being invoked if the
/// <see cref="PopupActivationProperty"/> dependency property has
/// been changed. Invokes the <see cref="OnPopupActivationPropertyChanged"/>
/// instance method of the changed instance.
/// </summary>
/// <param name="d">The currently processed owner of the property.</param>
/// <param name="e">Provides information about the updated property.</param>
private static void PopupActivationPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TaskbarIcon owner = (TaskbarIcon) d;
owner.OnPopupActivationPropertyChanged(e);
}
/// <summary>
/// Handles changes of the <see cref="PopupActivationProperty"/> dependency property. As
/// WPF internally uses the dependency property system and bypasses the
/// <see cref="PopupActivation"/> property wrapper, updates of the property's value
/// should be handled here.
/// </summary
/// <param name="e">Provides information about the updated property.</param>
private void OnPopupActivationPropertyChanged(DependencyPropertyChangedEventArgs e)
{
PopupActivationMode newValue = (PopupActivationMode) e.NewValue;
//TODO provide implementation
throw new NotImplementedException("Change event handler for dependency property PopupActivation not implemented.");
}
#endregion
#region Visibility dependency property override
/// <summary>
/// A static callback listener which is being invoked if the
/// <see cref="UIElement.VisibilityProperty"/> dependency property has
/// been changed. Invokes the <see cref="OnVisibilityPropertyChanged"/>
/// instance method of the changed instance.
/// </summary>
/// <param name="d">The currently processed owner of the property.</param>
/// <param name="e">Provides information about the updated property.</param>
private static void VisibilityPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TaskbarIcon owner = (TaskbarIcon) d;
owner.OnVisibilityPropertyChanged(e);
}
/// <summary>
/// Handles changes of the <see cref="UIElement.VisibilityProperty"/> dependency property. As
/// WPF internally uses the dependency property system and bypasses the
/// <see cref="Visibility"/> property wrapper, updates of the property's value
/// should be handled here.
/// </summary
/// <param name="e">Provides information about the updated property.</param>
private void OnVisibilityPropertyChanged(DependencyPropertyChangedEventArgs e)
{
Visibility newValue = (Visibility) e.NewValue;
//update
if (newValue == Visibility.Visible)
{
CreateTaskbarIcon();
}
else
{
RemoveTaskbarIcon();
}
}
#endregion
#region ContextMenu dependency property override
/// <summary>
/// A static callback listener which is being invoked if the
/// <see cref="FrameworkElement.ContextMenuProperty"/> dependency property has
/// been changed. Invokes the <see cref="OnContextMenuPropertyChanged"/>
/// instance method of the changed instance.
/// </summary>
/// <param name="d">The currently processed owner of the property.</param>
/// <param name="e">Provides information about the updated property.</param>
private static void ContextMenuPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
TaskbarIcon owner = (TaskbarIcon) d;
owner.OnContextMenuPropertyChanged(e);
}
/// <summary>
/// Handles changes of the <see cref="FrameworkElement.ContextMenuProperty"/> dependency property. As
/// WPF internally uses the dependency property system and bypasses the
/// <see cref="ContextMenu"/> property wrapper, updates of the property's value
/// should be handled here.
/// </summary
/// <param name="e">Provides information about the updated property.</param>
private void OnContextMenuPropertyChanged(DependencyPropertyChangedEventArgs e)
{
ContextMenu newValue = (ContextMenu) e.NewValue;
//TODO provide implementation
}
#endregion
//EVENTS
#region TaskbarIconLeftMouseDown
/// <summary>
/// TaskbarIconLeftMouseDown Routed Event
/// </summary>
public static readonly RoutedEvent TaskbarIconLeftMouseDownEvent = EventManager.RegisterRoutedEvent("TaskbarIconLeftMouseDown",
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
/// <summary>
/// Occurs when the user presses the left mouse button.
/// </summary>
public event RoutedEventHandler TaskbarIconLeftMouseDown
{
add { AddHandler(TaskbarIconLeftMouseDownEvent, value); }
remove { RemoveHandler(TaskbarIconLeftMouseDownEvent, value); }
}
/// <summary>
/// A helper method to raise the TaskbarIconLeftMouseDown event.
/// </summary>
protected RoutedEventArgs RaiseTaskbarIconLeftMouseDownEvent()
{
return RaiseTaskbarIconLeftMouseDownEvent(this);
}
/// <summary>
/// A static helper method to raise the TaskbarIconLeftMouseDown event on a target element.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
internal static RoutedEventArgs RaiseTaskbarIconLeftMouseDownEvent(DependencyObject target)
{
if (target == null) return null;
RoutedEventArgs args = new RoutedEventArgs();
args.RoutedEvent = TaskbarIconLeftMouseDownEvent;
RoutedEventHelper.RaiseEvent(target, args);
return args;
}
#endregion
#region TaskbarIconRightMouseDown
/// <summary>
/// TaskbarIconRightMouseDown Routed Event
/// </summary>
public static readonly RoutedEvent TaskbarIconRightMouseDownEvent = EventManager.RegisterRoutedEvent("TaskbarIconRightMouseDown",
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
/// <summary>
/// Occurs when the presses the right mouse button.
/// </summary>
public event RoutedEventHandler TaskbarIconRightMouseDown
{
add { AddHandler(TaskbarIconRightMouseDownEvent, value); }
remove { RemoveHandler(TaskbarIconRightMouseDownEvent, value); }
}
/// <summary>
/// A helper method to raise the TaskbarIconRightMouseDown event.
/// </summary>
protected RoutedEventArgs RaiseTaskbarIconRightMouseDownEvent()
{
return RaiseTaskbarIconRightMouseDownEvent(this);
}
/// <summary>
/// A static helper method to raise the TaskbarIconRightMouseDown event on a target element.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
internal static RoutedEventArgs RaiseTaskbarIconRightMouseDownEvent(DependencyObject target)
{
if (target == null) return null;
RoutedEventArgs args = new RoutedEventArgs();
args.RoutedEvent = TaskbarIconRightMouseDownEvent;
RoutedEventHelper.RaiseEvent(target, args);
return args;
}
#endregion
#region TaskbarIconLeftMouseUp
/// <summary>
/// TaskbarIconLeftMouseUp Routed Event
/// </summary>
public static readonly RoutedEvent TaskbarIconLeftMouseUpEvent = EventManager.RegisterRoutedEvent("TaskbarIconLeftMouseUp",
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
/// <summary>
/// Occurs when the user releases the left mouse button.
/// </summary>
public event RoutedEventHandler TaskbarIconLeftMouseUp
{
add { AddHandler(TaskbarIconLeftMouseUpEvent, value); }
remove { RemoveHandler(TaskbarIconLeftMouseUpEvent, value); }
}
/// <summary>
/// A helper method to raise the TaskbarIconLeftMouseUp event.
/// </summary>
protected RoutedEventArgs RaiseTaskbarIconLeftMouseUpEvent()
{
return RaiseTaskbarIconLeftMouseUpEvent(this);
}
/// <summary>
/// A static helper method to raise the TaskbarIconLeftMouseUp event on a target element.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
internal static RoutedEventArgs RaiseTaskbarIconLeftMouseUpEvent(DependencyObject target)
{
if (target == null) return null;
RoutedEventArgs args = new RoutedEventArgs();
args.RoutedEvent = TaskbarIconLeftMouseUpEvent;
RoutedEventHelper.RaiseEvent(target, args);
return args;
}
#endregion
#region TaskbarIconRightMouseUp
/// <summary>
/// TaskbarIconRightMouseUp Routed Event
/// </summary>
public static readonly RoutedEvent TaskbarIconRightMouseUpEvent = EventManager.RegisterRoutedEvent("TaskbarIconRightMouseUp",
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
/// <summary>
/// Occurs when the user releases the right mouse button.
/// </summary>
public event RoutedEventHandler TaskbarIconRightMouseUp
{
add { AddHandler(TaskbarIconRightMouseUpEvent, value); }
remove { RemoveHandler(TaskbarIconRightMouseUpEvent, value); }
}
/// <summary>
/// A helper method to raise the TaskbarIconRightMouseUp event.
/// </summary>
protected RoutedEventArgs RaiseTaskbarIconRightMouseUpEvent()
{
return RaiseTaskbarIconRightMouseUpEvent(this);
}
/// <summary>
/// A static helper method to raise the TaskbarIconRightMouseUp event on a target element.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
internal static RoutedEventArgs RaiseTaskbarIconRightMouseUpEvent(DependencyObject target)
{
if (target == null) return null;
RoutedEventArgs args = new RoutedEventArgs();
args.RoutedEvent = TaskbarIconRightMouseUpEvent;
RoutedEventHelper.RaiseEvent(target, args);
return args;
}
#endregion
#region TaskbarIconPopupOpen (and PreviewTaskbarIconPopupOpen)
/// <summary>
/// TaskbarIconPopupOpen Routed Event
/// </summary>
public static readonly RoutedEvent TaskbarIconPopupOpenEvent = EventManager.RegisterRoutedEvent("TaskbarIconPopupOpen",
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
/// <summary>
/// Bubbled event that occurs when the custom popup is being opened.
/// </summary>
public event RoutedEventHandler TaskbarIconPopupOpen
{
add { AddHandler(TaskbarIconPopupOpenEvent, value); }
remove { RemoveHandler(TaskbarIconPopupOpenEvent, value); }
}
/// <summary>
/// A helper method to raise the TaskbarIconPopupOpen event.
/// </summary>
protected RoutedEventArgs RaiseTaskbarIconPopupOpenEvent()
{
return RaiseTaskbarIconPopupOpenEvent(this);
}
/// <summary>
/// A static helper method to raise the TaskbarIconPopupOpen event on a target element.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
internal static RoutedEventArgs RaiseTaskbarIconPopupOpenEvent(DependencyObject target)
{
if (target == null) return null;
RoutedEventArgs args = new RoutedEventArgs();
args.RoutedEvent = TaskbarIconPopupOpenEvent;
RoutedEventHelper.RaiseEvent(target, args);
return args;
}
/// <summary>
/// PreviewTaskbarIconPopupOpen Routed Event
/// </summary>
public static readonly RoutedEvent PreviewTaskbarIconPopupOpenEvent = EventManager.RegisterRoutedEvent("PreviewTaskbarIconPopupOpen",
RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TaskbarIcon));
/// <summary>
/// Tunneled event that occurs when the custom popup is being opened.
/// </summary>
public event RoutedEventHandler PreviewTaskbarIconPopupOpen
{
add { AddHandler(PreviewTaskbarIconPopupOpenEvent, value); }
remove { RemoveHandler(PreviewTaskbarIconPopupOpenEvent, value); }
}
/// <summary>
/// A helper method to raise the PreviewTaskbarIconPopupOpen event.
/// </summary>
protected RoutedEventArgs RaisePreviewTaskbarIconPopupOpenEvent()
{
return RaisePreviewTaskbarIconPopupOpenEvent(this);
}
/// <summary>
/// A static helper method to raise the PreviewTaskbarIconPopupOpen event on a target element.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
internal static RoutedEventArgs RaisePreviewTaskbarIconPopupOpenEvent(DependencyObject target)
{
if (target == null) return null;
RoutedEventArgs args = new RoutedEventArgs();
args.RoutedEvent = PreviewTaskbarIconPopupOpenEvent;
RoutedEventHelper.RaiseEvent(target, args);
return args;
}
#endregion
#region TaskbarIconToolTipOpen (and PreviewTaskbarIconToolTipOpen)
/// <summary>
/// TaskbarIconToolTipOpen Routed Event
/// </summary>
public static readonly RoutedEvent TaskbarIconToolTipOpenEvent = EventManager.RegisterRoutedEvent("TaskbarIconToolTipOpen",
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
/// <summary>
/// Bubbled event that occurs when the custom ToolTip is being displayed.
/// </summary>
public event RoutedEventHandler TaskbarIconToolTipOpen
{
add { AddHandler(TaskbarIconToolTipOpenEvent, value); }
remove { RemoveHandler(TaskbarIconToolTipOpenEvent, value); }
}
/// <summary>
/// A helper method to raise the TaskbarIconToolTipOpen event.
/// </summary>
protected RoutedEventArgs RaiseTaskbarIconToolTipOpenEvent()
{
return RaiseTaskbarIconToolTipOpenEvent(this);
}
/// <summary>
/// A static helper method to raise the TaskbarIconToolTipOpen event on a target element.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
internal static RoutedEventArgs RaiseTaskbarIconToolTipOpenEvent(DependencyObject target)
{
if (target == null) return null;
RoutedEventArgs args = new RoutedEventArgs();
args.RoutedEvent = TaskbarIconToolTipOpenEvent;
RoutedEventHelper.RaiseEvent(target, args);
return args;
}
/// <summary>
/// PreviewTaskbarIconToolTipOpen Routed Event
/// </summary>
public static readonly RoutedEvent PreviewTaskbarIconToolTipOpenEvent = EventManager.RegisterRoutedEvent("PreviewTaskbarIconToolTipOpen",
RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TaskbarIcon));
/// <summary>
/// Tunneled event that occurs when the custom ToolTip is being displayed.
/// </summary>
public event RoutedEventHandler PreviewTaskbarIconToolTipOpen
{
add { AddHandler(PreviewTaskbarIconToolTipOpenEvent, value); }
remove { RemoveHandler(PreviewTaskbarIconToolTipOpenEvent, value); }
}
/// <summary>
/// A helper method to raise the PreviewTaskbarIconToolTipOpen event.
/// </summary>
protected RoutedEventArgs RaisePreviewTaskbarIconToolTipOpenEvent()
{
return RaisePreviewTaskbarIconToolTipOpenEvent(this);
}
/// <summary>
/// A static helper method to raise the PreviewTaskbarIconToolTipOpen event on a target element.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
internal static RoutedEventArgs RaisePreviewTaskbarIconToolTipOpenEvent(DependencyObject target)
{
if (target == null) return null;
RoutedEventArgs args = new RoutedEventArgs();
args.RoutedEvent = PreviewTaskbarIconToolTipOpenEvent;
RoutedEventHelper.RaiseEvent(target, args);
return args;
}
#endregion
#region TaskbarIconContextMenuOpen (and PreviewTaskbarIconContextMenuOpen)
/// <summary>
/// TaskbarIconContextMenuOpen Routed Event
/// </summary>
public static readonly RoutedEvent TaskbarIconContextMenuOpenEvent = EventManager.RegisterRoutedEvent("TaskbarIconContextMenuOpen",
RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(TaskbarIcon));
/// <summary>
/// Bubbled event that occurs when the context menu of the taskbar icon is being displayed.
/// </summary>
public event RoutedEventHandler TaskbarIconContextMenuOpen
{
add { AddHandler(TaskbarIconContextMenuOpenEvent, value); }
remove { RemoveHandler(TaskbarIconContextMenuOpenEvent, value); }
}
/// <summary>
/// A helper method to raise the TaskbarIconContextMenuOpen event.
/// </summary>
protected RoutedEventArgs RaiseTaskbarIconContextMenuOpenEvent()
{
return RaiseTaskbarIconContextMenuOpenEvent(this);
}
/// <summary>
/// A static helper method to raise the TaskbarIconContextMenuOpen event on a target element.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
internal static RoutedEventArgs RaiseTaskbarIconContextMenuOpenEvent(DependencyObject target)
{
if (target == null) return null;
RoutedEventArgs args = new RoutedEventArgs();
args.RoutedEvent = TaskbarIconContextMenuOpenEvent;
RoutedEventHelper.RaiseEvent(target, args);
return args;
}
/// <summary>
/// PreviewTaskbarIconContextMenuOpen Routed Event
/// </summary>
public static readonly RoutedEvent PreviewTaskbarIconContextMenuOpenEvent = EventManager.RegisterRoutedEvent("PreviewTaskbarIconContextMenuOpen",
RoutingStrategy.Tunnel, typeof(RoutedEventHandler), typeof(TaskbarIcon));
/// <summary>
/// Tunneled event that occurs when the context menu of the taskbar icon is being displayed.
/// </summary>
public event RoutedEventHandler PreviewTaskbarIconContextMenuOpen
{
add { AddHandler(PreviewTaskbarIconContextMenuOpenEvent, value); }
remove { RemoveHandler(PreviewTaskbarIconContextMenuOpenEvent, value); }
}
/// <summary>
/// A helper method to raise the PreviewTaskbarIconContextMenuOpen event.
/// </summary>
protected RoutedEventArgs RaisePreviewTaskbarIconContextMenuOpenEvent()
{
return RaisePreviewTaskbarIconContextMenuOpenEvent(this);
}
/// <summary>
/// A static helper method to raise the PreviewTaskbarIconContextMenuOpen event on a target element.
/// </summary>
/// <param name="target">UIElement or ContentElement on which to raise the event</param>
internal static RoutedEventArgs RaisePreviewTaskbarIconContextMenuOpenEvent(DependencyObject target)
{
if (target == null) return null;
RoutedEventArgs args = new RoutedEventArgs();
args.RoutedEvent = PreviewTaskbarIconContextMenuOpenEvent;
RoutedEventHelper.RaiseEvent(target, args);
return args;
}
#endregion
//CONSTRUCTOR DECLARATIONS
/// <summary>
/// Registers properties.
/// </summary>
static TaskbarIcon()
{
//register change listener for the Visibility property
PropertyMetadata md = new PropertyMetadata(Visibility.Visible, VisibilityPropertyChanged);
VisibilityProperty.OverrideMetadata(typeof(TaskbarIcon), md);
//register change listener for the ContextMenu property
md = new FrameworkPropertyMetadata(new PropertyChangedCallback(ContextMenuPropertyChanged));
ContextMenuProperty.OverrideMetadata(typeof (TaskbarIcon), md);
//register change listener for the ToolTip property
md = new FrameworkPropertyMetadata(new PropertyChangedCallback(ToolTipPropertyChanged));
ToolTipProperty.OverrideMetadata(typeof(TaskbarIcon), md);
}
}
}

View File

@@ -0,0 +1,250 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using Hardcodet.Wpf.TaskbarNotification.Interop;
namespace Hardcodet.Wpf.TaskbarNotification
{
partial class TaskbarIcon
{
/// <summary>
/// An action that is being invoked if the
/// <see cref="singleClickTimer"/> fires.
/// </summary>
private Action delayedTimerAction;
/// <summary>
/// A timer that is used to differentiate between single
/// and double clicks.
/// </summary>
private readonly Timer singleClickTimer;
#region SetVersion
/// <summary>
/// Sets the version flag for the <see cref="iconData"/>.
/// </summary>
private void SetVersion()
{
iconData.VersionOrTimeout = (uint) NotifyIconVersion.Vista;
bool status = WinApi.Shell_NotifyIcon(NotifyCommand.SetVersion, ref iconData);
if (!status)
{
iconData.VersionOrTimeout = (uint) NotifyIconVersion.Win2000;
status = Util.WriteIconData(ref iconData, NotifyCommand.SetVersion);
}
if (!status)
{
iconData.VersionOrTimeout = (uint)NotifyIconVersion.Win95;
status = Util.WriteIconData(ref iconData, NotifyCommand.SetVersion);
}
if (!status)
{
Debug.Fail("Could not set version");
}
}
#endregion
/// <summary>
/// Sets tooltip settings for the class.
/// </summary>
private void WriteToolTipSettings()
{
IconDataMembers flags = IconDataMembers.Tip;
iconData.ToolTipText = ToolTipText;
if (messageSink.Version == NotifyIconVersion.Vista)
{
if (String.IsNullOrEmpty(ToolTipText) && ToolTip != null)
{
//if we have not tooltip text but a custom tooltip, we
//need to set a dummy value
iconData.ToolTipText = "ToolTip";
}
else if (!String.IsNullOrEmpty(ToolTipText) && ToolTip == null)
{
//if a tooltip text was set but there is no custom tooltip,
//we need to fall back to legacy operations
flags |= IconDataMembers.UseLegacyToolTips;
}
}
//just write the the tooltip
Util.WriteIconData(ref iconData, NotifyCommand.Modify, flags);
}
#region Show / Hide Balloon ToolTip
/// <summary>
/// Displays a balloon tip with the specified title,
/// text, and icon in the taskbar for the specified time period.
/// </summary>
/// <param name="title">The title to display on the balloon tip.</param>
/// <param name="message">The text to display on the balloon tip.</param>
/// <param name="icon">Indicates the severity.</param>
public void ShowBalloonTip(string title, string message, BalloonIcon icon)
{
lock(this)
{
ShowBalloonTip(title, message, icon.GetBalloonFlag(), IntPtr.Zero);
}
}
/// <summary>
/// Displays a balloon tip with the specified title,
/// text, and a custom icon in the taskbar for the specified time period.
/// </summary>
/// <param name="title">The title to display on the balloon tip.</param>
/// <param name="message">The text to display on the balloon tip.</param>
/// <param name="customIcon">A custom icon.</param>
/// <exception cref="ArgumentNullException">If <paramref name="customIcon"/>
/// is a null reference.</exception>
public void ShowBalloonTip(string title, string message, Icon customIcon)
{
if (customIcon == null) throw new ArgumentNullException("customIcon");
lock(this)
{
ShowBalloonTip(title, message, BalloonFlags.User, customIcon.Handle);
}
}
/// <summary>
/// Invokes <see cref="WinApi.Shell_NotifyIcon"/> in order to display
/// a given balloon ToolTip.
/// </summary>
/// <param name="title">The title to display on the balloon tip.</param>
/// <param name="message">The text to display on the balloon tip.</param>
/// <param name="flags">Indicates what icon to use.</param>
/// <param name="balloonIconHandle">A handle to a custom icon, if any, or
/// <see cref="IntPtr.Zero"/>.</param>
private void ShowBalloonTip(string title, string message, BalloonFlags flags, IntPtr balloonIconHandle)
{
EnsureNotDisposed();
iconData.BalloonText = message;
iconData.BalloonTitle = title;
iconData.BalloonFlags = flags;
iconData.CustomBalloonIconHandle = balloonIconHandle;
Util.WriteIconData(ref iconData, NotifyCommand.Modify, IconDataMembers.Info);
}
/// <summary>
/// Hides a balloon ToolTip, if any is displayed.
/// </summary>
public void HideBalloonTip()
{
EnsureNotDisposed();
//reset balloon by just setting the info to an empty string
iconData.BalloonText = iconData.BalloonTitle = String.Empty;
Util.WriteIconData(ref iconData, NotifyCommand.Modify, IconDataMembers.Info);
}
#endregion
#region Single Click Timer event
/// <summary>
/// Performs a delayed action if the user requested an action
/// based on a single click of the left mouse.<br/>
/// This method is invoked by the <see cref="singleClickTimer"/>.
/// </summary>
private void DoSingleClickAction(object state)
{
if (IsDisposed) return;
//run action
Action action = delayedTimerAction;
if (action != null)
{
//cleanup action
delayedTimerAction = null;
//switch to UI thread
Application.Current.Dispatcher.Invoke(action);
}
}
#endregion
#region Show Tray Popup / Context Menu
/// <summary>
/// Displays the <see cref="TaskbarIconPopup"/> control if
/// it was set.
/// </summary>
private void ShowTrayPopup()
{
if (IsDisposed) return;
if (TaskbarIconPopup != null)
{
//raise preview event
var args = RaisePreviewTaskbarIconPopupOpenEvent();
if (args.Handled) return;
//open popup
TaskbarIconPopup.IsOpen = true;
//activate the message window to track deactivation - otherwise, the context menu
//does not close if the user clicks somewhere else
WinApi.SetForegroundWindow(messageSink.MessageWindowHandle);
//bubble event
RaiseTaskbarIconPopupOpenEvent();
}
}
/// <summary>
/// Displays the <see cref="ContextMenu"/> if
/// it was set.
/// </summary>
private void ShowContextMenu()
{
if (IsDisposed) return;
if (ContextMenu != null)
{
//raise preview event
var args = RaisePreviewTaskbarIconContextMenuOpenEvent();
if (args.Handled) return;
//CreateActivationWindow();
ContextMenu.IsOpen = true;
//activate the message window to track deactivation - otherwise, the context menu
//does not close if the user clicks somewhere else
WinApi.SetForegroundWindow(messageSink.MessageWindowHandle);
//bubble event
RaiseTaskbarIconContextMenuOpenEvent();
}
}
#endregion
}
}

View File

@@ -0,0 +1,379 @@
using System;
using System.ComponentModel;
using System.Threading;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using System.Windows.Media;
using Hardcodet.Wpf.TaskbarNotification.Interop;
using Rect=Hardcodet.Wpf.TaskbarNotification.Interop.Rect;
namespace Hardcodet.Wpf.TaskbarNotification
{
internal class MyClass
{
public void Test()
{
TaskbarIcon icon = new TaskbarIcon();
icon.Icon = Properties.Resources.DefaultTrayIcon;
Console.Out.WriteLine("DISPLAY NOW...");
Thread.CurrentThread.Join(1500);
//icon.ShowBalloonTip("some title", "hello world", Properties.Resources.DefaultTrayIcon);
//Console.Out.WriteLine("status = {0}", status);
Thread.CurrentThread.Join(5000);
}
public void Test2()
{
var tbInfo = TrayLocator.GetTaskbarInformation();
var w = new Window();
w.Background = Brushes.Red;
w.WindowStyle = WindowStyle.None;
Rect rect = tbInfo.Rectangle;
w.Width = Math.Max(20, rect.right - rect.left);
w.Height = Math.Max(20, rect.bottom - rect.top);
w.Left = rect.left;
w.Top = rect.top - 100;
w.ShowDialog();
}
}
/// <summary>
/// Represent a taskbar icon that sits in the system
/// tray.
/// </summary>
public partial class TaskbarIcon : FrameworkElement, IDisposable
{
/// <summary>
/// Represents the current icon data.
/// </summary>
private NotifyIconData iconData;
/// <summary>
/// Receives messages from the taskbar icon.
/// </summary>
private readonly WindowMessageSink messageSink;
/// <summary>
/// Indicates whether the taskbar icon has been created or not.
/// </summary>
public bool IsTaskbarIconCreated { get; set; }
/// <summary>
/// Indicates whether custom tooltips are supported.
/// </summary>
public bool SupportsCustomToolTips
{
get { return messageSink.Version == NotifyIconVersion.Vista; }
}
/// <summary>
/// Inits the taskbar icon and registers a message listener
/// in order to receive events from the taskbar area.
/// </summary>
public TaskbarIcon()
{
//do nothing if in design mode
if (Util.IsDesignMode)
{
messageSink = WindowMessageSink.CreateEmpty();
}
else
{
//create message sink that receives window messages
messageSink = new WindowMessageSink(NotifyIconVersion.Win95);
}
//init icon data structure
iconData = NotifyIconData.CreateDefault(messageSink.MessageWindowHandle);
//create the taskbar icon
CreateTaskbarIcon();
//register event listeners
messageSink.MouseEventReceived += OnMouseEvent;
messageSink.TaskbarCreated += OnTaskbarCreated;
messageSink.ChangeToolTipStateRequest += OnToolTipChange;
messageSink.BallonToolTipChanged += OnBalloonToolTipChanged;
//init single click timer
singleClickTimer = new Timer(DoSingleClickAction);
//register listener in order to get notified when the application closes
if (Application.Current != null) Application.Current.Exit += OnExit;
}
/// <summary>
/// Processes mouse events, which are bubbled
/// through the class' routed events, trigger
/// certain actions (e.g. show a popup), or
/// both.
/// </summary>
/// <param name="me">Event flag.</param>
private void OnMouseEvent(MouseEvent me)
{
if (IsDisposed) return;
switch(me)
{
case MouseEvent.MouseMove:
break;
case MouseEvent.IconRightMouseDown:
RaiseTaskbarIconRightMouseDownEvent();
break;
case MouseEvent.IconLeftMouseDown:
RaiseTaskbarIconLeftMouseDownEvent();
break;
case MouseEvent.IconRightMouseUp:
RaiseTaskbarIconRightMouseUpEvent();
break;
case MouseEvent.IconLeftMouseUp:
RaiseTaskbarIconLeftMouseUpEvent();
break;
case MouseEvent.IconMiddleMouseDown:
break;
case MouseEvent.IconMiddleMouseUp:
break;
case MouseEvent.IconDoubleClick:
//cancel single click timer
singleClickTimer.Change(Timeout.Infinite, Timeout.Infinite);
break;
case MouseEvent.BalloonToolTipClicked:
break;
default:
throw new ArgumentOutOfRangeException("me", "Missing handler for mouse event flag: " + me);
}
//show popup, if requested
if (me.IsMatch(PopupActivation))
{
if (me == MouseEvent.IconLeftMouseUp)
{
//show popup once we are sure it's not a double click
delayedTimerAction = ShowTrayPopup;
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
}
else
{
//show popup immediately
ShowTrayPopup();
}
}
//show context menu, if requested
if (me.IsMatch(MenuActivation))
{
if (me == MouseEvent.IconLeftMouseUp)
{
//show context menu once we are sure it's not a double click
delayedTimerAction = ShowContextMenu;
singleClickTimer.Change(WinApi.GetDoubleClickTime(), Timeout.Infinite);
}
else
{
//show context menu immediately
ShowContextMenu();
}
}
}
private void OnToolTipChange(bool visible)
{
//if we have a custom tooltip, show it now
if (ToolTip == null) return;
ToolTip tt = (ToolTip)ToolTip;
tt.IsOpen = visible;
}
private void OnBalloonToolTipChanged(bool visible)
{
//TODO just raise event
}
/// <summary>
/// Recreates the taskbar icon if the whole taskbar was
/// recreated (e.g. because Explorer was shut down).
/// </summary>
private void OnTaskbarCreated()
{
IsTaskbarIconCreated = false;
CreateTaskbarIcon();
}
#region create / remove taskbar icon
/// <summary>
/// Creates the taskbar icon. This message is invoked during initialization,
/// if the taskbar is restarted, and whenever the icon is displayed.
/// </summary>
private void CreateTaskbarIcon()
{
lock (this)
{
if (!IsTaskbarIconCreated)
{
const IconDataMembers members = IconDataMembers.Message
| IconDataMembers.Icon
| IconDataMembers.Tip;
//write initial configuration
var status = Util.WriteIconData(ref iconData, NotifyCommand.Add, members);
if (!status)
{
throw new Win32Exception("Could not create icon data");
}
//set to most recent version
SetVersion();
messageSink.Version = (NotifyIconVersion) iconData.VersionOrTimeout;
IsTaskbarIconCreated = true;
}
}
}
/// <summary>
/// Closes the taskbar icon if required.
/// </summary>
private void RemoveTaskbarIcon()
{
lock (this)
{
if (IsTaskbarIconCreated)
{
Util.WriteIconData(ref iconData, NotifyCommand.Delete, IconDataMembers.Message);
IsTaskbarIconCreated = false;
}
}
}
#endregion
#region Dispose / Exit
/// <summary>
/// Set to true as soon as <see cref="Dispose"/>
/// has been invoked.
/// </summary>
public bool IsDisposed { get; private set; }
/// <summary>
/// Checks if the object has been disposed and
/// raises a <see cref="ObjectDisposedException"/> in case
/// the <see cref="IsDisposed"/> flag is true.
/// </summary>
private void EnsureNotDisposed()
{
if (IsDisposed) throw new ObjectDisposedException(Name ?? GetType().FullName);
}
/// <summary>
/// Disposes the class if the application exits.
/// </summary>
private void OnExit(object sender, EventArgs e)
{
Dispose();
}
/// <summary>
/// This destructor will run only if the <see cref="Dispose()"/>
/// method does not get called. This gives this base class the
/// opportunity to finalize.
/// <para>
/// Important: Do not provide destructors in types derived from
/// this class.
/// </para>
/// </summary>
~TaskbarIcon()
{
Dispose(false);
}
/// <summary>
/// Disposes the object.
/// </summary>
/// <remarks>This method is not virtual by design. Derived classes
/// should override <see cref="Dispose(bool)"/>.
/// </remarks>
public void Dispose()
{
Dispose(true);
// This object will be cleaned up by the Dispose method.
// Therefore, you should call GC.SupressFinalize to
// take this object off the finalization queue
// and prevent finalization code for this object
// from executing a second time.
GC.SuppressFinalize(this);
}
/// <summary>
/// Closes the tray and releases all resources.
/// </summary>
/// <summary>
/// <c>Dispose(bool disposing)</c> executes in two distinct scenarios.
/// If disposing equals <c>true</c>, the method has been called directly
/// or indirectly by a user's code. Managed and unmanaged resources
/// can be disposed.
/// </summary>
/// <param name="disposing">If disposing equals <c>false</c>, the method
/// has been called by the runtime from inside the finalizer and you
/// should not reference other objects. Only unmanaged resources can
/// be disposed.</param>
/// <remarks>Check the <see cref="IsDisposed"/> property to determine whether
/// the method has already been called.</remarks>
private void Dispose(bool disposing)
{
//don't do anything if the component is already disposed
if (IsDisposed || !disposing) return;
lock (this)
{
IsDisposed = true;
//deregister application event listener
Application.Current.Exit -= OnExit;
//stop timer
singleClickTimer.Dispose();
//dispose message sink
messageSink.Dispose();
RemoveTaskbarIcon();
}
}
#endregion
}
}

View File

@@ -0,0 +1,225 @@
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows;
using System.Windows.Media;
using System.Windows.Resources;
using Hardcodet.Wpf.TaskbarNotification.Interop;
namespace Hardcodet.Wpf.TaskbarNotification
{
/// <summary>
/// Util and extension methods.
/// </summary>
internal static class Util
{
public static readonly object SyncRoot = new object();
#region IsDesignMode
private static readonly bool isDesignMode;
/// <summary>
/// Checks whether the application is currently in design mode.
/// </summary>
public static bool IsDesignMode
{
get { return isDesignMode; }
}
#endregion
#region construction
static Util()
{
isDesignMode =
(bool)DependencyPropertyDescriptor.FromProperty(DesignerProperties.IsInDesignModeProperty, typeof(FrameworkElement))
.Metadata.DefaultValue;
}
#endregion
#region CreateHelperWindow
/// <summary>
/// Creates an transparent window without dimension that
/// can be used to temporarily obtain focus and/or
/// be used as a window message sink.
/// </summary>
/// <returns>Empty window.</returns>
public static Window CreateHelperWindow()
{
return new Window
{
Width = 0,
Height = 0,
ShowInTaskbar = false,
WindowStyle = WindowStyle.None,
AllowsTransparency = true,
Opacity = 0
};
}
#endregion
#region WriteIconData
/// <summary>
/// Updates the taskbar icons with data provided by a given
/// <see cref="NotifyIconData"/> instance.
/// </summary>
/// <param name="data"></param>
/// <param name="command"></param>
/// <returns></returns>
public static bool WriteIconData(ref NotifyIconData data, NotifyCommand command)
{
return WriteIconData(ref data, command, data.ValidMembers);
}
/// <summary>
/// Updates the taskbar icons with data provided by a given
/// <see cref="NotifyIconData"/> instance.
/// </summary>
/// <param name="data"></param>
/// <param name="command"></param>
/// <param name="flags"></param>
/// <returns></returns>
public static bool WriteIconData(ref NotifyIconData data, NotifyCommand command, IconDataMembers flags)
{
//do nothing if in design mode
if (IsDesignMode) return true;
data.ValidMembers = flags;
lock (SyncRoot)
{
return WinApi.Shell_NotifyIcon(command, ref data);
}
}
#endregion
#region GetBalloonFlag
/// <summary>
/// Gets a <see cref="BalloonFlags"/> enum value that
/// matches a given <see cref="BalloonIcon"/>.
/// </summary>
public static BalloonFlags GetBalloonFlag(this BalloonIcon icon)
{
switch (icon)
{
case BalloonIcon.None:
return BalloonFlags.None;
case BalloonIcon.Info:
return BalloonFlags.Info;
case BalloonIcon.Warning:
return BalloonFlags.Warning;
case BalloonIcon.Error:
return BalloonFlags.Error;
default:
throw new ArgumentOutOfRangeException("icon");
}
}
#endregion
#region ImageSource to Icon
/// <summary>
/// Reads a given image resource into a WinForms icon.
/// </summary>
/// <param name="imageSource">Image source pointing to
/// an icon file (*.ico).</param>
/// <returns>An icon object that can be used with the
/// taskbar area.</returns>
public static Icon ToIcon(this ImageSource imageSource)
{
if (imageSource == null) return null;
Uri uri = new Uri(imageSource.ToString());
StreamResourceInfo streamInfo = Application.GetResourceStream(uri);
if (streamInfo == null)
{
string msg = "The supplied image source '{0}' could not be resolved.";
msg = String.Format(msg, imageSource);
throw new ArgumentException(msg);
}
return new Icon(streamInfo.Stream);
}
#endregion
#region evaluate listings
/// <summary>
/// Checks a list of candidates for equality to a given
/// reference value.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="value">The evaluated value.</param>
/// <param name="candidates">A liste of possible values that are
/// regarded valid.</param>
/// <returns>True if one of the submitted <paramref name="candidates"/>
/// matches the evaluated value. If the <paramref name="candidates"/>
/// parameter itself is null, too, the method returns false as well,
/// which allows to check with null values, too.</returns>
/// <exception cref="ArgumentNullException">If <paramref name="candidates"/>
/// is a null reference.</exception>
public static bool Is<T>(this T value, params T[] candidates)
{
if (candidates == null) return false;
foreach (var t in candidates)
{
if (value.Equals(t)) return true;
}
return false;
}
#endregion
#region match MouseEvent to PopupActivation
/// <summary>
/// Checks if a given <see cref="PopupActivationMode"/> is a match for
/// an effectively pressed mouse button.
/// </summary>
public static bool IsMatch(this MouseEvent me, PopupActivationMode activationMode)
{
switch (activationMode)
{
case PopupActivationMode.LeftClick:
return me == MouseEvent.IconLeftMouseUp;
case PopupActivationMode.RightClick:
return me == MouseEvent.IconRightMouseUp;
case PopupActivationMode.LeftOrRightClick:
return me.Is(MouseEvent.IconLeftMouseUp, MouseEvent.IconRightMouseUp);
case PopupActivationMode.LeftOrDoubleClick:
return me.Is(MouseEvent.IconLeftMouseUp, MouseEvent.IconDoubleClick);
case PopupActivationMode.DoubleClick:
return me.Is(MouseEvent.IconDoubleClick);
case PopupActivationMode.MiddleClick:
return me == MouseEvent.IconMiddleMouseUp;
case PopupActivationMode.All:
return true;
default:
throw new ArgumentOutOfRangeException("activationMode");
}
}
#endregion
}
}

View File

@@ -0,0 +1,8 @@
<Application x:Class="Sample_Project.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="Window1.xaml">
<Application.Resources>
</Application.Resources>
</Application>

View File

@@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Windows;
namespace Sample_Project
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

View File

@@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 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("Sample Project")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("Sample Project")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2009")]
[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)]
//In order to begin building localizable applications, set
//<UICulture>CultureYouAreCodingWith</UICulture> in your .csproj file
//inside a <PropertyGroup>. For example, if you are using US english
//in your source files, set the <UICulture> to en-US. Then uncomment
//the NeutralResourceLanguage attribute below. Update the "en-US" in
//the line below to match the UICulture setting in the project file.
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
//(used if a resource is not found in the page,
// or application resource dictionaries)
ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
//(used if a resource is not found in the page,
// app, or any theme specific resource dictionaries)
)]
// 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")]

View File

@@ -0,0 +1,84 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Sample_Project.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "2.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Sample_Project.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
internal static System.Drawing.Icon Bulb {
get {
object obj = ResourceManager.GetObject("Bulb", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
internal static System.Drawing.Icon Computers {
get {
object obj = ResourceManager.GetObject("Computers", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
internal static System.Drawing.Icon NetDrives {
get {
object obj = ResourceManager.GetObject("NetDrives", resourceCulture);
return ((System.Drawing.Icon)(obj));
}
}
}
}

View File

@@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="Bulb" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\icons\bulb.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="Computers" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\icons\computers.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="NetDrives" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\icons\netdrives.ico;System.Drawing.Icon, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Sample_Project.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "9.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

View File

@@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

View File

@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{71C74F29-F1C2-49C5-969F-C25AC4CDFCCC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Sample_Project</RootNamespace>
<AssemblyName>Sample Project</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
</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>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Drawing" />
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Page Include="Window1.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="Window1.xaml.cs">
<DependentUpon>Window1.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\NotifyIconWpf\NotifyIconWpf.csproj">
<Project>{7AC63864-7638-41C4-969C-D3197EF2BED9}</Project>
<Name>NotifyIconWpf</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\NetDrives.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\Bulb.ico" />
</ItemGroup>
<ItemGroup>
<Resource Include="Icons\Computers.ico" />
</ItemGroup>
<ItemGroup>
<Folder Include="Samples\" />
</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.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@@ -0,0 +1,147 @@
<Window
x:Class="Sample_Project.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:tb="http://www.hardcodet.net/taskbar"
Title="Window1" Height="480" Width="579">
<Window.Resources>
<Storyboard x:Key="OnTaskbarIconLeftMouseUp1">
<BooleanAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="popup" Storyboard.TargetProperty="(Popup.IsOpen)">
<DiscreteBooleanKeyFrame KeyTime="00:00:00" Value="True"/>
<DiscreteBooleanKeyFrame KeyTime="00:00:02" Value="False"/>
</BooleanAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.X)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="74"/>
<SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="26"/>
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[3].(TranslateTransform.Y)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="106"/>
<SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="151"/>
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="0"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="popup" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.1"/>
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="1"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.47"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:01.5000000" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:02" Value="0.685"/>
</DoubleAnimationUsingKeyFrames>
<DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(UIElement.Opacity)">
<SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/>
<SplineDoubleKeyFrame KeyTime="00:00:01" Value="0.515"/>
</DoubleAnimationUsingKeyFrames>
</Storyboard>
</Window.Resources>
<Window.Triggers>
<EventTrigger RoutedEvent="tb:TaskbarIcon.TaskbarIconLeftMouseUp" SourceName="tb">
<BeginStoryboard Storyboard="{StaticResource OnTaskbarIconLeftMouseUp1}"/>
</EventTrigger>
</Window.Triggers>
<Grid>
<Grid.Resources>
<Border
x:Key="yb"
Background="Yellow">
<Button
Width="200"
Height="200"
Content="CONTENT" />
</Border>
<ToolTip x:Key="borderToolTip">
<Border
Background="Red"
Opacity="0.75">
<TextBlock
Text="hello world" />
</Border>
</ToolTip>
</Grid.Resources>
<tb:TaskbarIcon
x:Name="tb"
ToolTip="{StaticResource yb}" Height="23" VerticalAlignment="Top"
>
<tb:TaskbarIcon.TaskbarIconPopup>
<Popup StaysOpen="False">
<Border
Width="200"
Height="200"
Background="Orange">
<TextBlock
Text="POPUP!" />
</Border>
</Popup>
</tb:TaskbarIcon.TaskbarIconPopup>
<tb:TaskbarIcon.ContextMenu>
<ContextMenu>
<MenuItem
Header="Open" />
<MenuItem
Header="Quite" />
</ContextMenu>
</tb:TaskbarIcon.ContextMenu>
<!-- <tb:TaskbarIcon.ToolTip>-->
<!-- <Border Background="Yellow">-->
<!-- <TextBlock-->
<!-- Text="PopupToolTip" />-->
<!-- </Border>-->
<!-- </tb:TaskbarIcon.ToolTip>-->
</tb:TaskbarIcon>
<Button
x:Name="btn"
Click="OnClick"
Content="Click me"
Height="24"
Margin="12,33,66,0"
VerticalAlignment="Top" />
<Button
Height="23"
HorizontalAlignment="Right"
Margin="0,91,64,0"
Name="button1"
VerticalAlignment="Top"
Width="75">Button</Button>
<TextBox
Text="{Binding ElementName=tb, Path=ToolTipText}"
Height="23"
Margin="13,91,0,0"
Name="textBox1"
VerticalAlignment="Top"
HorizontalAlignment="Left"
Width="120" />
<Popup x:Name="popup">
<Grid Width="180" Height="227">
<Border CornerRadius="10,10,10,10" x:Name="border">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFF4B569" Offset="0"/>
<GradientStop Color="#FFFFFFFF" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
</Border>
<Ellipse Fill="#FFC13E3E" Stroke="#FF000000" VerticalAlignment="Top" Height="58" Margin="51,19,75,0" x:Name="ellipse" RenderTransformOrigin="0.5,0.5">
<Ellipse.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="1" ScaleY="1"/>
<SkewTransform AngleX="0" AngleY="0"/>
<RotateTransform Angle="0"/>
<TranslateTransform X="0" Y="0"/>
</TransformGroup>
</Ellipse.RenderTransform>
</Ellipse>
</Grid>
</Popup>
</Grid>
</Window>

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace Sample_Project
{
/// <summary>
/// Interaction logic for Window1.xaml
/// </summary>
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
//set icon in code - setting the IconSource in XAML
//works just fine but breaks the VS designer
tb.Icon = Properties.Resources.Computers;
}
private void OnClick(object sender, RoutedEventArgs e)
{
if (tb.Visibility == System.Windows.Visibility.Visible)
{
tb.Visibility = System.Windows.Visibility.Collapsed;
}
else
{
tb.Visibility = Visibility.Visible;
}
}
}
}