Moved all PInvokes to a lower class without any relianceon WPF, NotificationIconHelper, TaskbarHelper, SystemPersonalisationHelper are WPF window no more
This commit is contained in:
@@ -17,10 +17,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\NotificationFlyout.Uwp.UI.Controls\NotificationFlyout.Uwp.UI.Controls.csproj" />
|
|
||||||
<ProjectReference Include="..\..\src\NotificationFlyout.Uwp.UI\NotificationFlyout.Uwp.UI.csproj" />
|
|
||||||
<ProjectReference Include="..\..\src\NotificationFlyout.Wpf.UI.Controls\NotificationFlyout.Wpf.UI.Controls.csproj" />
|
<ProjectReference Include="..\..\src\NotificationFlyout.Wpf.UI.Controls\NotificationFlyout.Wpf.UI.Controls.csproj" />
|
||||||
<ProjectReference Include="..\..\src\NotificationFlyout.Wpf.UI\NotificationFlyout.Wpf.UI.csproj" />
|
|
||||||
<ProjectReference Include="..\NotificationFlyoutSample\NotificationFlyoutSample.csproj" />
|
<ProjectReference Include="..\NotificationFlyoutSample\NotificationFlyoutSample.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -12,13 +12,13 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
global.json = global.json
|
global.json = global.json
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Uwp.UI.Controls", "..\src\NotificationFlyout.Uwp.UI.Controls\NotificationFlyout.Uwp.UI.Controls.csproj", "{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Shared.UI", "..\src\NotificationFlyout.Shared.UI\NotificationFlyout.Shared.UI.csproj", "{5A47C726-FA50-4A16-B639-DEC79B9D365B}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Wpf.UI", "..\src\NotificationFlyout.Wpf.UI\NotificationFlyout.Wpf.UI.csproj", "{49BCC188-22D2-468B-89EA-99C810BE790E}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Uwp.UI.Controls", "..\src\NotificationFlyout.Uwp.UI.Controls\NotificationFlyout.Uwp.UI.Controls.csproj", "{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Wpf.UI.Controls", "..\src\NotificationFlyout.Wpf.UI.Controls\NotificationFlyout.Wpf.UI.Controls.csproj", "{094A2030-C430-490B-AB26-205385A0D4BF}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Wpf.UI", "..\src\NotificationFlyout.Wpf.UI\NotificationFlyout.Wpf.UI.csproj", "{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Uwp.UI", "..\src\NotificationFlyout.Uwp.UI\NotificationFlyout.Uwp.UI.csproj", "{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Wpf.UI.Controls", "..\src\NotificationFlyout.Wpf.UI.Controls\NotificationFlyout.Wpf.UI.Controls.csproj", "{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -81,86 +81,86 @@ Global
|
|||||||
{2057ADE0-C61E-45EE-BB7E-A469FE4D4C41}.Release|x86.ActiveCfg = Release|x86
|
{2057ADE0-C61E-45EE-BB7E-A469FE4D4C41}.Release|x86.ActiveCfg = Release|x86
|
||||||
{2057ADE0-C61E-45EE-BB7E-A469FE4D4C41}.Release|x86.Build.0 = Release|x86
|
{2057ADE0-C61E-45EE-BB7E-A469FE4D4C41}.Release|x86.Build.0 = Release|x86
|
||||||
{2057ADE0-C61E-45EE-BB7E-A469FE4D4C41}.Release|x86.Deploy.0 = Release|x86
|
{2057ADE0-C61E-45EE-BB7E-A469FE4D4C41}.Release|x86.Deploy.0 = Release|x86
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Debug|Any CPU.ActiveCfg = Debug|x64
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Debug|Any CPU.Build.0 = Debug|x64
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Debug|ARM.Build.0 = Debug|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Debug|ARM64.Build.0 = Debug|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Debug|x64.ActiveCfg = Debug|x64
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Debug|x64.Build.0 = Debug|x64
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Debug|x64.Build.0 = Debug|x64
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Debug|x86.Build.0 = Debug|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Release|ARM.ActiveCfg = Release|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Release|ARM.Build.0 = Release|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Release|ARM.Build.0 = Release|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Release|ARM64.ActiveCfg = Release|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Release|ARM64.Build.0 = Release|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Release|ARM64.Build.0 = Release|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Release|x64.ActiveCfg = Release|x64
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Release|x64.Build.0 = Release|x64
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Release|x86.ActiveCfg = Release|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{95F851E4-87A5-4BB7-953E-C0FE3B306F0E}.Release|x86.Build.0 = Release|Any CPU
|
{5A47C726-FA50-4A16-B639-DEC79B9D365B}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Debug|Any CPU.ActiveCfg = Debug|x64
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Debug|Any CPU.Build.0 = Debug|x64
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Debug|ARM.Build.0 = Debug|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Debug|ARM64.Build.0 = Debug|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Debug|x64.ActiveCfg = Debug|x64
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Debug|x64.Build.0 = Debug|x64
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Debug|x64.Build.0 = Debug|x64
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Debug|x86.Build.0 = Debug|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Release|Any CPU.Build.0 = Release|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Release|ARM.ActiveCfg = Release|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Release|ARM.Build.0 = Release|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Release|ARM.Build.0 = Release|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Release|ARM64.ActiveCfg = Release|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Release|ARM64.Build.0 = Release|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Release|ARM64.Build.0 = Release|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Release|x64.ActiveCfg = Release|x64
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Release|x64.ActiveCfg = Release|x64
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Release|x64.Build.0 = Release|x64
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Release|x64.Build.0 = Release|x64
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Release|x86.ActiveCfg = Release|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{49BCC188-22D2-468B-89EA-99C810BE790E}.Release|x86.Build.0 = Release|Any CPU
|
{197A7AC8-6F6B-48D4-A95B-9AE9E2008817}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Debug|Any CPU.ActiveCfg = Debug|x64
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Debug|Any CPU.Build.0 = Debug|x64
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Debug|ARM.Build.0 = Debug|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Debug|ARM64.Build.0 = Debug|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Debug|x64.ActiveCfg = Debug|x64
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Debug|x64.Build.0 = Debug|x64
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Debug|x64.Build.0 = Debug|x64
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Debug|x86.Build.0 = Debug|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|Any CPU.Build.0 = Release|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|ARM.ActiveCfg = Release|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|ARM.Build.0 = Release|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Release|ARM.Build.0 = Release|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|ARM64.ActiveCfg = Release|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|ARM64.Build.0 = Release|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Release|ARM64.Build.0 = Release|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|x64.ActiveCfg = Release|x64
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Release|x64.ActiveCfg = Release|x64
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|x64.Build.0 = Release|x64
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Release|x64.Build.0 = Release|x64
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|x86.ActiveCfg = Release|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{094A2030-C430-490B-AB26-205385A0D4BF}.Release|x86.Build.0 = Release|Any CPU
|
{3222D603-00E9-4C00-BDA3-B2F33AFDE4BB}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|ARM.Build.0 = Debug|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|ARM64.Build.0 = Debug|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|x64.ActiveCfg = Debug|x64
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Debug|x64.ActiveCfg = Debug|x64
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|x64.Build.0 = Debug|x64
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Debug|x64.Build.0 = Debug|x64
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Debug|x86.Build.0 = Debug|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Release|Any CPU.Build.0 = Release|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Release|ARM.ActiveCfg = Release|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Release|ARM.Build.0 = Release|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Release|ARM.Build.0 = Release|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Release|ARM64.ActiveCfg = Release|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Release|ARM64.Build.0 = Release|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Release|ARM64.Build.0 = Release|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Release|x64.ActiveCfg = Release|x64
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Release|x64.ActiveCfg = Release|x64
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Release|x64.Build.0 = Release|x64
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Release|x64.Build.0 = Release|x64
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Release|x86.ActiveCfg = Release|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}.Release|x86.Build.0 = Release|Any CPU
|
{DEEF73AF-26B6-46BE-B824-0FDF0EE671F3}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -173,12 +173,12 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\src\NotificationFlyout.Uwp.UI.Controls\NotificationFlyout.Uwp.UI.Controls.csproj">
|
<ProjectReference Include="..\..\src\NotificationFlyout.Uwp.UI.Controls\NotificationFlyout.Uwp.UI.Controls.csproj">
|
||||||
<Project>{95f851e4-87a5-4bb7-953e-c0fe3b306f0e}</Project>
|
<Project>{197a7ac8-6f6b-48d4-a95b-9ae9e2008817}</Project>
|
||||||
<Name>NotificationFlyout.Uwp.UI.Controls</Name>
|
<Name>NotificationFlyout.Uwp.UI.Controls</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
<ProjectReference Include="..\..\src\NotificationFlyout.Uwp.UI\NotificationFlyout.Uwp.UI.csproj">
|
<ProjectReference Include="..\..\src\NotificationFlyout.Shared.UI\NotificationFlyout.Shared.UI.csproj">
|
||||||
<Project>{AFCE4980-A641-4BBB-A745-F0D4E54A0D86}</Project>
|
<Project>{197a7ac8-6f6b-48d4-a95b-9ae9e2008817}</Project>
|
||||||
<Name>NotificationFlyout.Uwp.UI</Name>
|
<Name>NotificationFlyout.Shared.UI</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
<PropertyGroup Condition=" '$(VisualStudioVersion)' == '' or '$(VisualStudioVersion)' < '14.0' ">
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.Windows.Sdk;
|
using Microsoft.Windows.Sdk;
|
||||||
|
|
||||||
namespace NotificationFlyout.Uwp.UI.Extensions
|
namespace NotificationFlyout.Shared.UI.Extensions
|
||||||
{
|
{
|
||||||
internal class ExecutionMode
|
internal class ExecutionMode
|
||||||
{
|
{
|
||||||
+2
-1
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Windows.Sdk;
|
using Microsoft.Windows.Sdk;
|
||||||
|
using NotificationFlyout.Shared.UI.Extensions;
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -6,7 +7,7 @@ using System.Threading.Tasks;
|
|||||||
using Windows.UI.Xaml.Media;
|
using Windows.UI.Xaml.Media;
|
||||||
using Windows.UI.Xaml.Media.Imaging;
|
using Windows.UI.Xaml.Media.Imaging;
|
||||||
|
|
||||||
namespace NotificationFlyout.Uwp.UI.Extensions
|
namespace NotificationFlyout.Shared.UI.Extensions
|
||||||
{
|
{
|
||||||
public static class ImageSourceExtensions
|
public static class ImageSourceExtensions
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Extensions
|
||||||
|
{
|
||||||
|
public static class OperatingSystemExtensions
|
||||||
|
{
|
||||||
|
public static bool IsGreaterThan(this OperatingSystem operatingSystem, OperatingSystemVersion version) => operatingSystem.Version.Build > (int)version;
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
namespace NotificationFlyout.Shared.UI.Extensions
|
||||||
{
|
{
|
||||||
public enum OperatingSystemVersion : int
|
public enum OperatingSystemVersion : int
|
||||||
{
|
{
|
||||||
+2
-3
@@ -1,14 +1,13 @@
|
|||||||
using Microsoft.Windows.Sdk;
|
using Microsoft.Windows.Sdk;
|
||||||
using System.Windows;
|
using Windows.Foundation;
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Extensions
|
namespace NotificationFlyout.Shared.UI.Extensions
|
||||||
{
|
{
|
||||||
internal static class RECTExtensions
|
internal static class RECTExtensions
|
||||||
{
|
{
|
||||||
internal static Rect ToRect(this RECT rect)
|
internal static Rect ToRect(this RECT rect)
|
||||||
{
|
{
|
||||||
if (rect.right - rect.left < 0 || rect.bottom - rect.top < 0) return new Rect(rect.left, rect.top, 0, 0);
|
if (rect.right - rect.left < 0 || rect.bottom - rect.top < 0) return new Rect(rect.left, rect.top, 0, 0);
|
||||||
|
|
||||||
return new Rect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
|
return new Rect(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Extensions
|
namespace NotificationFlyout.Shared.UI.Extensions
|
||||||
{
|
{
|
||||||
public static class RegistryKeyExtensions
|
public static class RegistryKeyExtensions
|
||||||
{
|
{
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using Microsoft.Windows.Sdk;
|
using Microsoft.Windows.Sdk;
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
{
|
{
|
||||||
internal class CursorHelper
|
internal class CursorHelper
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,81 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
public partial class NotificationIconHelper
|
||||||
|
{
|
||||||
|
private enum NotifyIconBalloonType
|
||||||
|
{
|
||||||
|
None = 0x00,
|
||||||
|
Info = 0x01,
|
||||||
|
Warning = 0x02,
|
||||||
|
Error = 0x03,
|
||||||
|
User = 0x04,
|
||||||
|
NoSound = 0x10,
|
||||||
|
LargeIcon = 0x20,
|
||||||
|
RespectQuietTime = 0x80
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum NotifyIconCommand : uint
|
||||||
|
{
|
||||||
|
Add = 0x0,
|
||||||
|
Delete = 0x2,
|
||||||
|
Modify = 0x1,
|
||||||
|
SetVersion = 0x4
|
||||||
|
}
|
||||||
|
|
||||||
|
[Flags]
|
||||||
|
private enum NotifyIconDataMember : uint
|
||||||
|
{
|
||||||
|
Message = 0x01,
|
||||||
|
Icon = 0x02,
|
||||||
|
Tip = 0x04,
|
||||||
|
State = 0x08,
|
||||||
|
Info = 0x10,
|
||||||
|
Realtime = 0x40,
|
||||||
|
UseLegacyToolTips = 0x80
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum NotifyIconState : uint
|
||||||
|
{
|
||||||
|
Visible = 0x00,
|
||||||
|
Hidden = 0x01
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
private static extern IntPtr DefWindowProcW(IntPtr handle, uint msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("shell32.dll", SetLastError = true)]
|
||||||
|
private static extern int Shell_NotifyIcon(NotifyIconCommand notifyCommand, ref NotifyIconData notifyIconData);
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||||
|
private struct NotifyIconData
|
||||||
|
{
|
||||||
|
public uint cbSize;
|
||||||
|
public IntPtr WindowHandle;
|
||||||
|
public uint TaskbarIconId;
|
||||||
|
public NotifyIconDataMember ValidMembers;
|
||||||
|
public uint CallbackMessageId;
|
||||||
|
public IntPtr IconHandle;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
||||||
|
public string ToolTipText;
|
||||||
|
|
||||||
|
public NotifyIconState IconState;
|
||||||
|
public NotifyIconState StateMask;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
||||||
|
public string BalloonText;
|
||||||
|
|
||||||
|
public uint VersionOrTimeout;
|
||||||
|
|
||||||
|
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
|
||||||
|
public string BalloonTitle;
|
||||||
|
|
||||||
|
public NotifyIconBalloonType BalloonFlags;
|
||||||
|
public Guid TaskbarIconGuid;
|
||||||
|
public IntPtr CustomBalloonIconHandle;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,110 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
public partial class NotificationIconHelper : IDisposable, IWndProcHandler
|
||||||
|
{
|
||||||
|
private const int CallbackMessage = 0x400;
|
||||||
|
private const uint IconVersion = 0x4;
|
||||||
|
|
||||||
|
private readonly object _lock = new();
|
||||||
|
private bool _isDisposed;
|
||||||
|
private NotifyIconData _notifyIconData;
|
||||||
|
|
||||||
|
private NotificationIconHelper()
|
||||||
|
{
|
||||||
|
WndProcHandlerSubscriber.Current.Subscribe(this);
|
||||||
|
CreateNotificationIcon();
|
||||||
|
}
|
||||||
|
|
||||||
|
~NotificationIconHelper()
|
||||||
|
{
|
||||||
|
Dispose(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public event EventHandler<NotificationIconInvokedEventArgs> IconInvoked;
|
||||||
|
|
||||||
|
public static NotificationIconHelper Create() => new();
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Dispose(true);
|
||||||
|
GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Handle(uint message, IntPtr wParam, IntPtr lParam)
|
||||||
|
{
|
||||||
|
if (message == CallbackMessage)
|
||||||
|
{
|
||||||
|
switch ((uint)lParam)
|
||||||
|
{
|
||||||
|
case (uint)WndProcMessages.WM_LBUTTONUP:
|
||||||
|
InvokeIconInvoked(PointerButton.Left);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (uint)WndProcMessages.WM_MBUTTONUP:
|
||||||
|
InvokeIconInvoked(PointerButton.Middle);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case (uint)WndProcMessages.WM_RBUTTONUP:
|
||||||
|
InvokeIconInvoked(PointerButton.Right);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetIcon(IntPtr iconHandle)
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
_notifyIconData.IconHandle = iconHandle;
|
||||||
|
WriteNotifyIconData(NotifyIconCommand.Modify, NotifyIconDataMember.Icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateNotificationIcon()
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
_notifyIconData = new NotifyIconData();
|
||||||
|
|
||||||
|
_notifyIconData.cbSize = (uint)Marshal.SizeOf(_notifyIconData);
|
||||||
|
_notifyIconData.WindowHandle = WndProcListener.Current.Handle;
|
||||||
|
_notifyIconData.TaskbarIconId = 0x0;
|
||||||
|
_notifyIconData.CallbackMessageId = CallbackMessage;
|
||||||
|
_notifyIconData.VersionOrTimeout = IconVersion;
|
||||||
|
|
||||||
|
_notifyIconData.IconHandle = IntPtr.Zero;
|
||||||
|
|
||||||
|
_notifyIconData.IconState = NotifyIconState.Hidden;
|
||||||
|
_notifyIconData.StateMask = NotifyIconState.Hidden;
|
||||||
|
|
||||||
|
WriteNotifyIconData(NotifyIconCommand.Add, NotifyIconDataMember.Message | NotifyIconDataMember.Icon | NotifyIconDataMember.Tip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (_isDisposed || !disposing) return;
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
_isDisposed = true;
|
||||||
|
RemoveNotificationIcon();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InvokeIconInvoked(PointerButton pointerButton) => IconInvoked?.Invoke(this, new NotificationIconInvokedEventArgs(pointerButton));
|
||||||
|
|
||||||
|
private void RemoveNotificationIcon() => WriteNotifyIconData(NotifyIconCommand.Delete, NotifyIconDataMember.Message);
|
||||||
|
|
||||||
|
private void WriteNotifyIconData(NotifyIconCommand command, NotifyIconDataMember flags)
|
||||||
|
{
|
||||||
|
_notifyIconData.ValidMembers = flags;
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
Shell_NotifyIcon(command, ref _notifyIconData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
public class NotificationIconInvokedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
internal NotificationIconInvokedEventArgs(PointerButton pointerButton) => PointerButton = pointerButton;
|
||||||
|
|
||||||
|
public PointerButton PointerButton { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
public enum PointerButton
|
||||||
|
{
|
||||||
|
Left = 0,
|
||||||
|
Middle = 1,
|
||||||
|
Right = 2,
|
||||||
|
XButton1 = 3,
|
||||||
|
XButton2 = 4
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-3
@@ -1,10 +1,9 @@
|
|||||||
using Microsoft.Windows.Sdk;
|
using Microsoft.Windows.Sdk;
|
||||||
using NotificationFlyout.Wpf.UI.Helpers;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using Windows.Foundation;
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
{
|
{
|
||||||
public class Screen
|
public class Screen
|
||||||
{
|
{
|
||||||
+2
-13
@@ -1,9 +1,8 @@
|
|||||||
using Microsoft.Windows.Sdk;
|
using Microsoft.Windows.Sdk;
|
||||||
using System.Reflection;
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Windows;
|
using Windows.Foundation;
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
{
|
{
|
||||||
public static class SystemInformationHelper
|
public static class SystemInformationHelper
|
||||||
{
|
{
|
||||||
@@ -14,16 +13,6 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
public static Rect VirtualScreen => GetVirtualScreen();
|
public static Rect VirtualScreen => GetVirtualScreen();
|
||||||
public static Rect WorkingArea => GetWorkingArea();
|
public static Rect WorkingArea => GetWorkingArea();
|
||||||
|
|
||||||
public static int GetCurrentDpi()
|
|
||||||
{
|
|
||||||
return (int)typeof(SystemParameters).GetProperty("Dpi", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static double GetCurrentDpiScaleFactor()
|
|
||||||
{
|
|
||||||
return (double)GetCurrentDpi() / 96;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Rect GetVirtualScreen()
|
private static Rect GetVirtualScreen()
|
||||||
{
|
{
|
||||||
var size = new Size(PInvoke.GetSystemMetrics(SM_CXSCREEN), PInvoke.GetSystemMetrics(SM_CYSCREEN));
|
var size = new Size(PInvoke.GetSystemMetrics(SM_CXSCREEN), PInvoke.GetSystemMetrics(SM_CYSCREEN));
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
{
|
{
|
||||||
public class SystemPersonalisationChangedEventArgs : EventArgs
|
public class SystemPersonalisationChangedEventArgs : EventArgs
|
||||||
{
|
{
|
||||||
+8
-20
@@ -1,24 +1,20 @@
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using NotificationFlyout.Wpf.UI.Extensions;
|
using NotificationFlyout.Shared.UI.Extensions;
|
||||||
using System;
|
using System;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Interop;
|
|
||||||
using Windows.UI.ViewManagement;
|
using Windows.UI.ViewManagement;
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
{
|
{
|
||||||
public class SystemPersonalisationHelper
|
public class SystemPersonalisationHelper : IWndProcHandler
|
||||||
{
|
{
|
||||||
private readonly UISettings _settings = new();
|
private readonly UISettings _settings = new();
|
||||||
private readonly string PersonalizeKey = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
|
private readonly string PersonalizeKey = @"Software\Microsoft\Windows\CurrentVersion\Themes\Personalize";
|
||||||
private SystemTheme _currentTheme;
|
private SystemTheme _currentTheme;
|
||||||
private bool _isColorPrevalence;
|
private bool _isColorPrevalence;
|
||||||
|
|
||||||
private SystemPersonalisationHelper(Window window)
|
private SystemPersonalisationHelper()
|
||||||
{
|
{
|
||||||
var source = HwndSource.FromHwnd(window.GetHandle());
|
WndProcHandlerSubscriber.Current.Subscribe(this);
|
||||||
source.AddHook(new HwndSourceHook(WndProc));
|
|
||||||
|
|
||||||
_currentTheme = GetTheme();
|
_currentTheme = GetTheme();
|
||||||
_isColorPrevalence = GetIsColorPrevalence();
|
_isColorPrevalence = GetIsColorPrevalence();
|
||||||
@@ -29,13 +25,7 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
public bool IsColorPrevalence => GetIsColorPrevalence();
|
public bool IsColorPrevalence => GetIsColorPrevalence();
|
||||||
public SystemTheme Theme => GetTheme();
|
public SystemTheme Theme => GetTheme();
|
||||||
|
|
||||||
public static SystemPersonalisationHelper Create(Window window)
|
public static SystemPersonalisationHelper Create() => new();
|
||||||
{
|
|
||||||
return new SystemPersonalisationHelper(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
|
||||||
private static extern IntPtr DefWindowProcW(IntPtr handle, uint msg, IntPtr wParam, IntPtr lParam);
|
|
||||||
|
|
||||||
private bool GetIsColorPrevalence()
|
private bool GetIsColorPrevalence()
|
||||||
{
|
{
|
||||||
@@ -64,14 +54,12 @@ namespace NotificationFlyout.Wpf.UI.Helpers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
public void Handle(uint message, IntPtr wParam, IntPtr lParam)
|
||||||
{
|
{
|
||||||
if (msg == (int)WndProcMessages.WM_SETTINGCHANGE)
|
if (message == (int)WndProcMessages.WM_SETTINGCHANGE)
|
||||||
{
|
{
|
||||||
RaiseThemeChangedEvent();
|
RaiseThemeChangedEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
return DefWindowProcW(hwnd, (uint)msg, wParam, (lParam));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
{
|
{
|
||||||
public enum SystemTheme
|
public enum SystemTheme
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
using Microsoft.Windows.Sdk;
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
public partial class TaskbarHelper
|
||||||
|
{
|
||||||
|
private const string ShellTrayHandleName = "Shell_TrayWnd";
|
||||||
|
private const int SPI_SETWORKAREA = 0x002F;
|
||||||
|
private readonly uint WM_TASKBARCREATED = PInvoke.RegisterWindowMessage("TaskbarCreated");
|
||||||
|
|
||||||
|
private enum AppBarEdge : uint
|
||||||
|
{
|
||||||
|
Left = 0,
|
||||||
|
Top = 1,
|
||||||
|
Right = 2,
|
||||||
|
Bottom = 3
|
||||||
|
}
|
||||||
|
|
||||||
|
private enum AppBarMessage : uint
|
||||||
|
{
|
||||||
|
New = 0x00000000,
|
||||||
|
Remove = 0x00000001,
|
||||||
|
QueryPos = 0x00000002,
|
||||||
|
SetPos = 0x00000003,
|
||||||
|
GetState = 0x00000004,
|
||||||
|
GetTaskbarPos = 0x00000005,
|
||||||
|
Activate = 0x00000006,
|
||||||
|
GetAutoHideBar = 0x00000007,
|
||||||
|
SetAutoHideBar = 0x00000008,
|
||||||
|
WindowPosChanged = 0x00000009,
|
||||||
|
SetState = 0x0000000A,
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
private static extern IntPtr DefWindowProcW(IntPtr handle, uint msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
private static IntPtr GetSystemTrayHandle() => WindowHelper.GetHandle(ShellTrayHandleName);
|
||||||
|
|
||||||
|
[DllImport("shell32.dll", SetLastError = true)]
|
||||||
|
private static extern IntPtr SHAppBarMessage(AppBarMessage dwMessage, ref AppBarData pData);
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct AppBarData
|
||||||
|
{
|
||||||
|
public uint cbSize;
|
||||||
|
public IntPtr hWnd;
|
||||||
|
public uint uCallbackMessage;
|
||||||
|
public AppBarEdge uEdge;
|
||||||
|
public RECT rect;
|
||||||
|
public int lParam;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
using NotificationFlyout.Shared.UI.Extensions;
|
||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
public partial class TaskbarHelper : IWndProcHandler
|
||||||
|
{
|
||||||
|
private TaskbarHelper() => WndProcHandlerSubscriber.Current.Subscribe(this);
|
||||||
|
|
||||||
|
public event EventHandler TaskbarChanged;
|
||||||
|
|
||||||
|
public static TaskbarHelper Create() => new();
|
||||||
|
|
||||||
|
public TaskbarState GetCurrentState()
|
||||||
|
{
|
||||||
|
var handle = GetSystemTrayHandle();
|
||||||
|
var state = new TaskbarState
|
||||||
|
{
|
||||||
|
Screen = Screen.FromHandle(handle)
|
||||||
|
};
|
||||||
|
|
||||||
|
var appBarData = GetAppBarData(handle);
|
||||||
|
GetAppBarPosition(ref appBarData);
|
||||||
|
|
||||||
|
state.Rect = appBarData.rect.ToRect();
|
||||||
|
state.Position = (TaskbarPosition)appBarData.uEdge;
|
||||||
|
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Handle(uint message, IntPtr wParam, IntPtr lParam)
|
||||||
|
{
|
||||||
|
if (message == WM_TASKBARCREATED || message == (int)WndProcMessages.WM_SETTINGCHANGE && (int)wParam == SPI_SETWORKAREA)
|
||||||
|
{
|
||||||
|
TaskbarChanged?.Invoke(this, EventArgs.Empty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private AppBarData GetAppBarData(IntPtr handle)
|
||||||
|
{
|
||||||
|
return new AppBarData
|
||||||
|
{
|
||||||
|
cbSize = (uint)Marshal.SizeOf(typeof(AppBarData)),
|
||||||
|
hWnd = handle
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
private void GetAppBarPosition(ref AppBarData appBarData) => SHAppBarMessage(AppBarMessage.GetTaskbarPos, ref appBarData);
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace NotificationFlyout.Wpf.UI
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
{
|
{
|
||||||
public enum TaskbarPosition
|
public enum TaskbarPosition
|
||||||
{
|
{
|
||||||
+2
-2
@@ -1,6 +1,6 @@
|
|||||||
using System.Windows;
|
using Windows.Foundation;
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
{
|
{
|
||||||
public struct TaskbarState
|
public struct TaskbarState
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using Microsoft.Windows.Sdk;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
public class WindowHelper
|
||||||
|
{
|
||||||
|
public static IntPtr GetHandle(string windowName) => PInvoke.FindWindow(windowName, null);
|
||||||
|
|
||||||
|
public static uint GetDpi(IntPtr handle) => PInvoke.GetDpiForWindow((HWND)handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
using System;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
internal partial class WndProcHelper
|
||||||
|
{
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
private static extern IntPtr CreateWindowExW(uint dwExStyle, [MarshalAs(UnmanagedType.LPWStr)] string lpClassName, [MarshalAs(UnmanagedType.LPWStr)] string lpWindowName, uint dwStyle, int x, int y, int nWidth, int nHeight, IntPtr hWndParent, IntPtr hMenu, IntPtr hInstance, IntPtr lpParam);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
private static extern IntPtr DefWindowProcW(IntPtr handle, uint msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
private static extern bool DestroyWindow(IntPtr handle);
|
||||||
|
|
||||||
|
[DllImport("user32.dll", SetLastError = true)]
|
||||||
|
private static extern ushort RegisterClassW([In] ref WNDCLASSW lpWndClass);
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct WNDCLASSW
|
||||||
|
{
|
||||||
|
public uint style;
|
||||||
|
public WndProcHandler 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
internal partial class WndProcHelper : IDisposable
|
||||||
|
{
|
||||||
|
private WndProcHandler _handler;
|
||||||
|
|
||||||
|
private WndProcHelper() => CreateWndProcWindow();
|
||||||
|
|
||||||
|
private delegate IntPtr WndProcHandler(IntPtr hwnd, uint uMsg, IntPtr wparam, IntPtr lparam);
|
||||||
|
|
||||||
|
public event EventHandler<WndProcHelperMessageEventArgs> WndProcMessage;
|
||||||
|
|
||||||
|
public IntPtr Handle { get; private set; }
|
||||||
|
|
||||||
|
public static WndProcHelper Create() => new();
|
||||||
|
|
||||||
|
public void Dispose() => DestroyWindow(Handle);
|
||||||
|
|
||||||
|
private void CreateWndProcWindow()
|
||||||
|
{
|
||||||
|
var windowName = Guid.NewGuid().ToString();
|
||||||
|
_handler = WndProc;
|
||||||
|
|
||||||
|
WNDCLASSW wndProcWindow;
|
||||||
|
|
||||||
|
wndProcWindow.style = 0;
|
||||||
|
wndProcWindow.lpfnWndProc = _handler;
|
||||||
|
wndProcWindow.cbClsExtra = 0;
|
||||||
|
wndProcWindow.cbWndExtra = 0;
|
||||||
|
wndProcWindow.hInstance = IntPtr.Zero;
|
||||||
|
wndProcWindow.hIcon = IntPtr.Zero;
|
||||||
|
wndProcWindow.hCursor = IntPtr.Zero;
|
||||||
|
wndProcWindow.hbrBackground = IntPtr.Zero;
|
||||||
|
wndProcWindow.lpszMenuName = "";
|
||||||
|
wndProcWindow.lpszClassName = windowName;
|
||||||
|
|
||||||
|
RegisterClassW(ref wndProcWindow);
|
||||||
|
|
||||||
|
Handle = CreateWindowExW(0, windowName, "", 0, 0, 0, 1, 1, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
|
||||||
|
private IntPtr WndProc(IntPtr handle, uint message, IntPtr wParam, IntPtr lParam)
|
||||||
|
{
|
||||||
|
WndProcMessage?.Invoke(this, new WndProcHelperMessageEventArgs(message, wParam, lParam));
|
||||||
|
return DefWindowProcW(handle, message, wParam, lParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
internal class WndProcHelperMessageEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public WndProcHelperMessageEventArgs(uint message, IntPtr wParam, IntPtr lParam)
|
||||||
|
{
|
||||||
|
Message = message;
|
||||||
|
WParam = wParam;
|
||||||
|
LParam = lParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IntPtr LParam { get; private set; }
|
||||||
|
public uint Message { get; private set; }
|
||||||
|
public IntPtr WParam { get; private set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
{
|
{
|
||||||
internal enum WndProcMessages
|
internal enum WndProcMessages
|
||||||
{
|
{
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"$schema": "D:\\git\\CsWin32\\src\\Microsoft.Windows.CsWin32\\settings.schema.json",
|
||||||
|
"emitSingleFile": true
|
||||||
|
}
|
||||||
+6
-5
@@ -1,13 +1,14 @@
|
|||||||
Shell_NotifyIcon
|
Shell_NotifyIcon
|
||||||
GetSystemMetricsForDpi
|
|
||||||
DefWindowProcW
|
DefWindowProcW
|
||||||
GetSystemMetrics
|
|
||||||
MonitorFromWindow
|
MonitorFromWindow
|
||||||
RegisterWindowMessage
|
RegisterWindowMessage
|
||||||
SHAppBarMessage
|
SHAppBarMessage
|
||||||
SetWindowPos
|
|
||||||
GetWindowLong
|
GetWindowLong
|
||||||
SetWindowLong
|
|
||||||
GetDpiForWindow
|
GetDpiForWindow
|
||||||
FindWindow
|
FindWindow
|
||||||
GetPhysicalCursorPos
|
GetPhysicalCursorPos
|
||||||
|
GetSystemMetricsForDpi
|
||||||
|
GetCurrentPackageFullName
|
||||||
|
GetSystemMetrics
|
||||||
|
SetWindowLong
|
||||||
|
SetWindowPos
|
||||||
+9
-23
@@ -1,38 +1,24 @@
|
|||||||
<Project Sdk="MSBuild.Sdk.Extras">
|
<Project Sdk="MSBuild.Sdk.Extras">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFrameworks>uap10.0.19041</TargetFrameworks>
|
<TargetFrameworks>netcoreapp3.1;uap10.0.19041</TargetFrameworks>
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
|
||||||
<EnableTypeInfoReflection>false</EnableTypeInfoReflection>
|
|
||||||
<EnableXBindDiagnostics>false</EnableXBindDiagnostics>
|
|
||||||
<LangVersion>9.0</LangVersion>
|
<LangVersion>9.0</LangVersion>
|
||||||
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<Company>TheXamlGuy</Company>
|
<Company>TheXamlGuy</Company>
|
||||||
<Authors>TheXamlGuy</Authors>
|
<Authors>TheXamlGuy</Authors>
|
||||||
<Product>NotificationFlyout</Product>
|
<Product>NotificationFlyout</Product>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.0</Version>
|
||||||
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Remove="NotificationFlyout\**" />
|
|
||||||
<EmbeddedResource Remove="NotificationFlyout\**" />
|
|
||||||
<None Remove="NotificationFlyout\**" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<None Remove="NativeMethods.txt" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<AdditionalFiles Include="NativeMethods.txt" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" Condition="'$(TargetFramework)' == 'netcoreapp3.1'" />
|
||||||
|
<PackageReference Include="Microsoft.Win32.Registry" Version="6.0.0-preview.1.21102.12" />
|
||||||
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.1.319-beta">
|
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.1.319-beta">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="System.Drawing.Common" Version="5.0.1" />
|
<PackageReference Include="System.Drawing.Common" Version="6.0.0-preview.1.21102.12" />
|
||||||
|
<PackageReference Include="System.Memory" Version="4.5.4" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
</Project>
|
||||||
</Project>
|
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
|
[assembly: InternalsVisibleTo("NotificationFlyout.Wpf.UI")]
|
||||||
|
[assembly: InternalsVisibleTo("NotificationFlyout.Wpf.UI.Extensions")]
|
||||||
|
[assembly: InternalsVisibleTo("NotificationFlyout.Wpf.UI.Controls")]
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
public interface IWndProcHandler
|
||||||
|
{
|
||||||
|
void Handle(uint message, IntPtr wParam, IntPtr lParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
internal interface IWndProcHandlerCollection : IList<WndProcHandlerReference>
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
public interface IWndProcHandlerSubscriber
|
||||||
|
{
|
||||||
|
void Subscribe<TWndProcHandler>(TWndProcHandler handler) where TWndProcHandler : IWndProcHandler;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
internal class WndProcHandlerCollection : List<WndProcHandlerReference>, IWndProcHandlerCollection
|
||||||
|
{
|
||||||
|
private static readonly Lazy<WndProcHandlerCollection> _current = new(() => new WndProcHandlerCollection());
|
||||||
|
public static WndProcHandlerCollection Current => _current.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
internal class WndProcHandlerReference
|
||||||
|
{
|
||||||
|
private readonly WeakReference _reference;
|
||||||
|
|
||||||
|
public WndProcHandlerReference(object handler) => _reference = new WeakReference(handler);
|
||||||
|
|
||||||
|
public bool IsDead => _reference.Target == null;
|
||||||
|
|
||||||
|
public void Handle(uint message, IntPtr wParam, IntPtr lParam)
|
||||||
|
{
|
||||||
|
if (_reference.Target == null) return;
|
||||||
|
|
||||||
|
var target = _reference.Target;
|
||||||
|
if (target is IWndProcHandler handler)
|
||||||
|
{
|
||||||
|
handler.Handle(message, wParam, lParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Matches(object instance) => _reference.Target == instance;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
public class WndProcHandlerSubscriber : IWndProcHandlerSubscriber
|
||||||
|
{
|
||||||
|
private static readonly Lazy<WndProcHandlerSubscriber> _current = new(() => new WndProcHandlerSubscriber());
|
||||||
|
public static WndProcHandlerSubscriber Current => _current.Value;
|
||||||
|
|
||||||
|
public void Subscribe<TWndProcHandler>(TWndProcHandler handler) where TWndProcHandler : IWndProcHandler
|
||||||
|
{
|
||||||
|
var handlers = WndProcHandlerCollection.Current;
|
||||||
|
lock (handlers)
|
||||||
|
{
|
||||||
|
if (handlers.Any(x => x.Matches(handler))) return;
|
||||||
|
handlers.Add(new WndProcHandlerReference(handler));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace NotificationFlyout.Shared.UI.Helpers
|
||||||
|
{
|
||||||
|
public class WndProcListener
|
||||||
|
{
|
||||||
|
private static readonly Lazy<WndProcListener> _current = new(() => new WndProcListener());
|
||||||
|
|
||||||
|
private readonly WndProcHelper _wndProcHelper;
|
||||||
|
|
||||||
|
private WndProcListener() => _wndProcHelper = WndProcHelper.Create();
|
||||||
|
|
||||||
|
public static WndProcListener Current => _current.Value;
|
||||||
|
|
||||||
|
public IntPtr Handle => _wndProcHelper.Handle;
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
_wndProcHelper.WndProcMessage -= OnWndProcMessage;
|
||||||
|
_wndProcHelper.WndProcMessage += OnWndProcMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnWndProcMessage(object sender, WndProcHelperMessageEventArgs args)
|
||||||
|
{
|
||||||
|
WndProcHandlerReference[] handlers;
|
||||||
|
var subscribers = WndProcHandlerCollection.Current;
|
||||||
|
|
||||||
|
lock (subscribers)
|
||||||
|
{
|
||||||
|
handlers = subscribers.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var handler in handlers)
|
||||||
|
{
|
||||||
|
handler.Handle(args.Message, args.WParam, args.LParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
var deadHandlers = handlers.Where(x => x.IsDead).ToList();
|
||||||
|
if (deadHandlers.Count > 0)
|
||||||
|
{
|
||||||
|
lock (subscribers)
|
||||||
|
{
|
||||||
|
foreach (var deadHandler in deadHandlers) subscribers.Remove(deadHandler);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,7 +10,8 @@
|
|||||||
<Company>TheXamlGuy</Company>
|
<Company>TheXamlGuy</Company>
|
||||||
<Authors>TheXamlGuy</Authors>
|
<Authors>TheXamlGuy</Authors>
|
||||||
<Product>NotificationFlyout</Product>
|
<Product>NotificationFlyout</Product>
|
||||||
<Version>1.0.0</Version> </PropertyGroup>
|
<Version>1.0.0</Version>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Page Include="NotificationFlyout\NotificationFlyoutContextMenuFlyoutHost.xaml">
|
<Page Include="NotificationFlyout\NotificationFlyoutContextMenuFlyoutHost.xaml">
|
||||||
@@ -29,10 +30,10 @@
|
|||||||
<SubType>Designer</SubType>
|
<SubType>Designer</SubType>
|
||||||
<Generator>MSBuild:Compile</Generator>
|
<Generator>MSBuild:Compile</Generator>
|
||||||
</Page>
|
</Page>
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\NotificationFlyout.Uwp.UI\NotificationFlyout.Uwp.UI.csproj" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\NotificationFlyout.Shared.UI\NotificationFlyout.Shared.UI.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -46,6 +46,11 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
|||||||
flyout.Hide();
|
flyout.Hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void UpdateThemeVisualState()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public void SetFlyoutPlacement(string placement)
|
public void SetFlyoutPlacement(string placement)
|
||||||
{
|
{
|
||||||
if (!_isLoaded)
|
if (!_isLoaded)
|
||||||
@@ -98,8 +103,12 @@ namespace NotificationFlyout.Uwp.UI.Controls
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private NotificationFlyoutPresenter _flyoutPresenter;
|
||||||
|
|
||||||
protected override void OnApplyTemplate()
|
protected override void OnApplyTemplate()
|
||||||
{
|
{
|
||||||
|
_flyoutPresenter = GetTemplateChild("FlyoutPresenter") as NotificationFlyoutPresenter;
|
||||||
|
|
||||||
_flyout = GetTemplateChild("Flyout") as Flyout;
|
_flyout = GetTemplateChild("Flyout") as Flyout;
|
||||||
if (_flyout != null)
|
if (_flyout != null)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -63,7 +63,7 @@
|
|||||||
FromVerticalOffset="0" />
|
FromVerticalOffset="0" />
|
||||||
</TransitionCollection>
|
</TransitionCollection>
|
||||||
</Grid.Transitions>
|
</Grid.Transitions>
|
||||||
<controls:NotificationFlyoutPresenter Content="{TemplateBinding Content}" Style="{TemplateBinding FlyoutPresenterStyle}" />
|
<controls:NotificationFlyoutPresenter x:Name="FlyoutPresenter" Content="{TemplateBinding Content}" Style="{TemplateBinding FlyoutPresenterStyle}" />
|
||||||
</Grid>
|
</Grid>
|
||||||
</Flyout>
|
</Flyout>
|
||||||
</FlyoutBase.AttachedFlyout>
|
</FlyoutBase.AttachedFlyout>
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
GetSystemMetricsForDpi
|
|
||||||
GetCurrentPackageFullName
|
|
||||||
@@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\NotificationFlyout.Uwp.UI.Controls\NotificationFlyout.Uwp.UI.Controls.csproj" />
|
<ProjectReference Include="..\NotificationFlyout.Uwp.UI.Controls\NotificationFlyout.Uwp.UI.Controls.csproj" />
|
||||||
<ProjectReference Include="..\NotificationFlyout.Uwp.UI\NotificationFlyout.Uwp.UI.csproj" />
|
|
||||||
<ProjectReference Include="..\NotificationFlyout.Wpf.UI\NotificationFlyout.Wpf.UI.csproj" />
|
<ProjectReference Include="..\NotificationFlyout.Wpf.UI\NotificationFlyout.Wpf.UI.csproj" />
|
||||||
|
<ProjectReference Include="..\NotificationFlyout.Shared.UI\NotificationFlyout.Shared.UI.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
+4
-1
@@ -1,4 +1,5 @@
|
|||||||
using NotificationFlyout.Uwp.UI;
|
using NotificationFlyout.Shared.UI.Helpers;
|
||||||
|
using NotificationFlyout.Uwp.UI;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Markup;
|
using System.Windows.Markup;
|
||||||
|
|
||||||
@@ -20,6 +21,8 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
_application = this;
|
_application = this;
|
||||||
Uwp.UI.Controls.NotificationFlyout.SetApplication(this);
|
Uwp.UI.Controls.NotificationFlyout.SetApplication(this);
|
||||||
|
|
||||||
|
WndProcListener.Current.Start();
|
||||||
|
|
||||||
PrepareFlyoutHost();
|
PrepareFlyoutHost();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
using NotificationFlyout.Uwp.UI.Controls;
|
using NotificationFlyout.Uwp.UI.Controls;
|
||||||
|
using NotificationFlyout.Shared.UI.Helpers;
|
||||||
using NotificationFlyout.Wpf.UI.Extensions;
|
using NotificationFlyout.Wpf.UI.Extensions;
|
||||||
using NotificationFlyout.Wpf.UI.Helpers;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Controls
|
namespace NotificationFlyout.Wpf.UI.Controls
|
||||||
|
|||||||
+22
-10
@@ -1,9 +1,8 @@
|
|||||||
using NotificationFlyout.Uwp.UI.Controls;
|
using NotificationFlyout.Shared.UI.Extensions;
|
||||||
using NotificationFlyout.Uwp.UI.Extensions;
|
using NotificationFlyout.Shared.UI.Helpers;
|
||||||
|
using NotificationFlyout.Uwp.UI.Controls;
|
||||||
using NotificationFlyout.Wpf.UI.Extensions;
|
using NotificationFlyout.Wpf.UI.Extensions;
|
||||||
using NotificationFlyout.Wpf.UI.Helpers;
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using Windows.UI.Xaml.Controls.Primitives;
|
using Windows.UI.Xaml.Controls.Primitives;
|
||||||
@@ -92,12 +91,12 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
|
|
||||||
private void OnIconInvoked(object sender, NotificationIconInvokedEventArgs args)
|
private void OnIconInvoked(object sender, NotificationIconInvokedEventArgs args)
|
||||||
{
|
{
|
||||||
if (args.MouseButton == MouseButton.Left)
|
if (args.PointerButton == PointerButton.Left)
|
||||||
{
|
{
|
||||||
ShowFlyout();
|
ShowFlyout();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.MouseButton == MouseButton.Right)
|
if (args.PointerButton == PointerButton.Right)
|
||||||
{
|
{
|
||||||
ShowContextMenuFlyout();
|
ShowContextMenuFlyout();
|
||||||
}
|
}
|
||||||
@@ -107,7 +106,20 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
|
|
||||||
private void OnTaskbarChanged(object sender, EventArgs args) => UpdateWindow();
|
private void OnTaskbarChanged(object sender, EventArgs args) => UpdateWindow();
|
||||||
|
|
||||||
private void OnThemeChanged(object sender, SystemPersonalisationChangedEventArgs args) => UpdateIcons();
|
private void OnThemeChanged(object sender, SystemPersonalisationChangedEventArgs args)
|
||||||
|
{
|
||||||
|
UpdateFlyoutTheme(args.IsColorPrevalence);
|
||||||
|
UpdateIcons();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpdateFlyoutTheme(bool isColorPrevalence)
|
||||||
|
{
|
||||||
|
var content = GetHostContent();
|
||||||
|
if (content != null)
|
||||||
|
{
|
||||||
|
// content.UpdateFlyoutTheme(isColorPrevalence);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void PrepareContextMenu()
|
private void PrepareContextMenu()
|
||||||
{
|
{
|
||||||
@@ -131,10 +143,10 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
|
|
||||||
private void PrepareNotificationIcon()
|
private void PrepareNotificationIcon()
|
||||||
{
|
{
|
||||||
_notificationIconHelper = NotificationIconHelper.Create(this);
|
_notificationIconHelper = NotificationIconHelper.Create();
|
||||||
_notificationIconHelper.IconInvoked += OnIconInvoked;
|
_notificationIconHelper.IconInvoked += OnIconInvoked;
|
||||||
|
|
||||||
_systemPersonalisationHelper = SystemPersonalisationHelper.Create(this);
|
_systemPersonalisationHelper = SystemPersonalisationHelper.Create();
|
||||||
_systemPersonalisationHelper.ThemeChanged += OnThemeChanged;
|
_systemPersonalisationHelper.ThemeChanged += OnThemeChanged;
|
||||||
|
|
||||||
UpdateIcons();
|
UpdateIcons();
|
||||||
@@ -142,7 +154,7 @@ namespace NotificationFlyout.Wpf.UI.Controls
|
|||||||
|
|
||||||
private void PrepareTaskbar()
|
private void PrepareTaskbar()
|
||||||
{
|
{
|
||||||
_taskbarHelper = TaskbarHelper.Create(this);
|
_taskbarHelper = TaskbarHelper.Create();
|
||||||
_taskbarHelper.TaskbarChanged += OnTaskbarChanged;
|
_taskbarHelper.TaskbarChanged += OnTaskbarChanged;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
using Microsoft.Windows.Sdk;
|
using System;
|
||||||
using System;
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
@@ -8,17 +7,17 @@ namespace NotificationFlyout.Wpf.UI.Extensions
|
|||||||
{
|
{
|
||||||
public static class ImageSourceExtensions
|
public static class ImageSourceExtensions
|
||||||
{
|
{
|
||||||
public static Icon ConvertToIcon(this ImageSource imageSource, uint dpi)
|
//public static Icon ConvertToIcon(this ImageSource imageSource, uint dpi)
|
||||||
{
|
//{
|
||||||
if (imageSource == null) return null;
|
// if (imageSource == null) return null;
|
||||||
|
|
||||||
var uri = new Uri(imageSource.ToString(), UriKind.RelativeOrAbsolute);
|
// var uri = new Uri(imageSource.ToString(), UriKind.RelativeOrAbsolute);
|
||||||
|
|
||||||
var streamResource = Application.GetResourceStream(uri);
|
// var streamResource = Application.GetResourceStream(uri);
|
||||||
if (streamResource == null) throw new ArgumentException(nameof(streamResource));
|
// if (streamResource == null) throw new ArgumentException(nameof(streamResource));
|
||||||
|
|
||||||
return new Icon(streamResource.Stream, new System.Drawing.Size(PInvoke.GetSystemMetricsForDpi((int)SystemMetricFlag.SM_CXICON, dpi), PInvoke.GetSystemMetricsForDpi((int)SystemMetricFlag.SM_CYICON, dpi)));
|
// return new Icon(streamResource.Stream, new System.Drawing.Size(PInvoke.GetSystemMetricsForDpi((int)SystemMetricFlag.SM_CXICON, dpi), PInvoke.GetSystemMetricsForDpi((int)SystemMetricFlag.SM_CYICON, dpi)));
|
||||||
}
|
//}
|
||||||
|
|
||||||
private enum SystemMetricFlag : int
|
private enum SystemMetricFlag : int
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,13 +0,0 @@
|
|||||||
using NotificationFlyout.Wpf.UI.Helpers;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Extensions
|
|
||||||
{
|
|
||||||
public static class OperatingSystemExtensions
|
|
||||||
{
|
|
||||||
public static bool IsGreaterThan(this OperatingSystem operatingSystem, OperatingSystemVersion version)
|
|
||||||
{
|
|
||||||
return operatingSystem.Version.Build > (int)version;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,201 +0,0 @@
|
|||||||
using NotificationFlyout.Wpf.UI.Extensions;
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Input;
|
|
||||||
using System.Windows.Interop;
|
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
|
||||||
{
|
|
||||||
public class NotificationIconHelper : IDisposable
|
|
||||||
{
|
|
||||||
private const int CallbackMessage = 0x400;
|
|
||||||
private const uint IconVersion = 0x4;
|
|
||||||
|
|
||||||
private readonly object _lock = new();
|
|
||||||
private readonly IntPtr _windowHandle;
|
|
||||||
private bool _isDisposed;
|
|
||||||
private NotifyIconData _notifyIconData;
|
|
||||||
|
|
||||||
private NotificationIconHelper(Window window)
|
|
||||||
{
|
|
||||||
_windowHandle = window.GetHandle();
|
|
||||||
|
|
||||||
HwndSource source = HwndSource.FromHwnd(_windowHandle);
|
|
||||||
source.AddHook(new HwndSourceHook(WndProc));
|
|
||||||
|
|
||||||
CreateNotificationIcon();
|
|
||||||
}
|
|
||||||
|
|
||||||
~NotificationIconHelper()
|
|
||||||
{
|
|
||||||
Dispose(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
public event EventHandler<NotificationIconInvokedEventArgs> IconInvoked;
|
|
||||||
|
|
||||||
private enum NotifyIconBalloonType
|
|
||||||
{
|
|
||||||
None = 0x00,
|
|
||||||
Info = 0x01,
|
|
||||||
Warning = 0x02,
|
|
||||||
Error = 0x03,
|
|
||||||
User = 0x04,
|
|
||||||
NoSound = 0x10,
|
|
||||||
LargeIcon = 0x20,
|
|
||||||
RespectQuietTime = 0x80
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum NotifyIconCommand : uint
|
|
||||||
{
|
|
||||||
Add = 0x0,
|
|
||||||
Delete = 0x2,
|
|
||||||
Modify = 0x1,
|
|
||||||
SetVersion = 0x4
|
|
||||||
}
|
|
||||||
|
|
||||||
[Flags]
|
|
||||||
private enum NotifyIconDataMember : uint
|
|
||||||
{
|
|
||||||
Message = 0x01,
|
|
||||||
Icon = 0x02,
|
|
||||||
Tip = 0x04,
|
|
||||||
State = 0x08,
|
|
||||||
Info = 0x10,
|
|
||||||
Realtime = 0x40,
|
|
||||||
UseLegacyToolTips = 0x80
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum NotifyIconState : uint
|
|
||||||
{
|
|
||||||
Visible = 0x00,
|
|
||||||
Hidden = 0x01
|
|
||||||
}
|
|
||||||
|
|
||||||
public static NotificationIconHelper Create(Window window)
|
|
||||||
{
|
|
||||||
return new NotificationIconHelper(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose()
|
|
||||||
{
|
|
||||||
Dispose(true);
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetIcon(IntPtr iconHandle)
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
_notifyIconData.IconHandle = iconHandle;
|
|
||||||
WriteNotifyIconData(NotifyIconCommand.Modify, NotifyIconDataMember.Icon);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
|
||||||
private static extern IntPtr DefWindowProcW(IntPtr handle, uint msg, IntPtr wParam, IntPtr lParam);
|
|
||||||
|
|
||||||
[DllImport("shell32.dll", SetLastError = true)]
|
|
||||||
private static extern int Shell_NotifyIcon(NotifyIconCommand notifyCommand, ref NotifyIconData notifyIconData);
|
|
||||||
|
|
||||||
private void CreateNotificationIcon()
|
|
||||||
{
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
_notifyIconData = new NotifyIconData();
|
|
||||||
|
|
||||||
_notifyIconData.cbSize = (uint)Marshal.SizeOf(_notifyIconData);
|
|
||||||
_notifyIconData.WindowHandle = _windowHandle;
|
|
||||||
_notifyIconData.TaskbarIconId = 0x0;
|
|
||||||
_notifyIconData.CallbackMessageId = CallbackMessage;
|
|
||||||
_notifyIconData.VersionOrTimeout = IconVersion;
|
|
||||||
|
|
||||||
_notifyIconData.IconHandle = IntPtr.Zero;
|
|
||||||
|
|
||||||
_notifyIconData.IconState = NotifyIconState.Hidden;
|
|
||||||
_notifyIconData.StateMask = NotifyIconState.Hidden;
|
|
||||||
|
|
||||||
WriteNotifyIconData(NotifyIconCommand.Add, NotifyIconDataMember.Message | NotifyIconDataMember.Icon | NotifyIconDataMember.Tip);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Dispose(bool disposing)
|
|
||||||
{
|
|
||||||
if (_isDisposed || !disposing) return;
|
|
||||||
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
_isDisposed = true;
|
|
||||||
RemoveNotificationIcon();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void InvokeIconInvoked(MouseButton mouseButton)
|
|
||||||
{
|
|
||||||
IconInvoked?.Invoke(this, new NotificationIconInvokedEventArgs { MouseButton = mouseButton });
|
|
||||||
}
|
|
||||||
|
|
||||||
private void RemoveNotificationIcon() => WriteNotifyIconData(NotifyIconCommand.Delete, NotifyIconDataMember.Message);
|
|
||||||
|
|
||||||
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
|
||||||
{
|
|
||||||
if (msg == CallbackMessage)
|
|
||||||
{
|
|
||||||
switch ((uint)lParam)
|
|
||||||
{
|
|
||||||
case (uint)WndProcMessages.WM_LBUTTONUP:
|
|
||||||
InvokeIconInvoked(MouseButton.Left);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (uint)WndProcMessages.WM_MBUTTONUP:
|
|
||||||
InvokeIconInvoked(MouseButton.Middle);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case (uint)WndProcMessages.WM_RBUTTONUP:
|
|
||||||
InvokeIconInvoked(MouseButton.Right);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return DefWindowProcW(hwnd, (uint)msg, wParam, (lParam));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void WriteNotifyIconData(NotifyIconCommand command, NotifyIconDataMember flags)
|
|
||||||
{
|
|
||||||
_notifyIconData.ValidMembers = flags;
|
|
||||||
lock (_lock)
|
|
||||||
{
|
|
||||||
Shell_NotifyIcon(command, ref _notifyIconData);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
|
||||||
private struct NotifyIconData
|
|
||||||
{
|
|
||||||
public uint cbSize;
|
|
||||||
public IntPtr WindowHandle;
|
|
||||||
public uint TaskbarIconId;
|
|
||||||
public NotifyIconDataMember ValidMembers;
|
|
||||||
public uint CallbackMessageId;
|
|
||||||
public IntPtr IconHandle;
|
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 128)]
|
|
||||||
public string ToolTipText;
|
|
||||||
|
|
||||||
public NotifyIconState IconState;
|
|
||||||
public NotifyIconState StateMask;
|
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 256)]
|
|
||||||
public string BalloonText;
|
|
||||||
|
|
||||||
public uint VersionOrTimeout;
|
|
||||||
|
|
||||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 64)]
|
|
||||||
public string BalloonTitle;
|
|
||||||
|
|
||||||
public NotifyIconBalloonType BalloonFlags;
|
|
||||||
public Guid TaskbarIconGuid;
|
|
||||||
public IntPtr CustomBalloonIconHandle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Windows.Input;
|
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
|
||||||
{
|
|
||||||
public class NotificationIconInvokedEventArgs : EventArgs
|
|
||||||
{
|
|
||||||
public MouseButton MouseButton { get; internal set; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,118 +0,0 @@
|
|||||||
using Microsoft.Windows.Sdk;
|
|
||||||
using NotificationFlyout.Wpf.UI.Extensions;
|
|
||||||
using System;
|
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Windows;
|
|
||||||
using System.Windows.Interop;
|
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
|
||||||
{
|
|
||||||
public class TaskbarHelper
|
|
||||||
{
|
|
||||||
private const string ShellTrayHandleName = "Shell_TrayWnd";
|
|
||||||
private const int SPI_SETWORKAREA = 0x002F;
|
|
||||||
|
|
||||||
private readonly uint WM_TASKBARCREATED = PInvoke.RegisterWindowMessage("TaskbarCreated");
|
|
||||||
|
|
||||||
private TaskbarHelper(Window window)
|
|
||||||
{
|
|
||||||
var handle = window.GetHandle();
|
|
||||||
|
|
||||||
var source = HwndSource.FromHwnd(handle);
|
|
||||||
source.AddHook(new HwndSourceHook(WndProc));
|
|
||||||
}
|
|
||||||
|
|
||||||
public event EventHandler TaskbarChanged;
|
|
||||||
|
|
||||||
private enum AppBarEdge : uint
|
|
||||||
{
|
|
||||||
Left = 0,
|
|
||||||
Top = 1,
|
|
||||||
Right = 2,
|
|
||||||
Bottom = 3
|
|
||||||
}
|
|
||||||
|
|
||||||
private enum AppBarMessage : uint
|
|
||||||
{
|
|
||||||
New = 0x00000000,
|
|
||||||
Remove = 0x00000001,
|
|
||||||
QueryPos = 0x00000002,
|
|
||||||
SetPos = 0x00000003,
|
|
||||||
GetState = 0x00000004,
|
|
||||||
GetTaskbarPos = 0x00000005,
|
|
||||||
Activate = 0x00000006,
|
|
||||||
GetAutoHideBar = 0x00000007,
|
|
||||||
SetAutoHideBar = 0x00000008,
|
|
||||||
WindowPosChanged = 0x00000009,
|
|
||||||
SetState = 0x0000000A,
|
|
||||||
}
|
|
||||||
|
|
||||||
public static TaskbarHelper Create(Window window)
|
|
||||||
{
|
|
||||||
return new TaskbarHelper(window);
|
|
||||||
}
|
|
||||||
|
|
||||||
public TaskbarState GetCurrentState()
|
|
||||||
{
|
|
||||||
var handle = GetSystemTrayHandle();
|
|
||||||
var state = new TaskbarState
|
|
||||||
{
|
|
||||||
Screen = Screen.FromHandle(handle)
|
|
||||||
};
|
|
||||||
|
|
||||||
var appBarData = GetAppBarData(handle);
|
|
||||||
GetAppBarPosition(ref appBarData);
|
|
||||||
|
|
||||||
state.Rect = appBarData.rect.ToRect();
|
|
||||||
state.Position = (TaskbarPosition)appBarData.uEdge;
|
|
||||||
|
|
||||||
return state;
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("user32.dll", SetLastError = true)]
|
|
||||||
private static extern IntPtr DefWindowProcW(IntPtr handle, uint msg, IntPtr wParam, IntPtr lParam);
|
|
||||||
|
|
||||||
private static IntPtr GetSystemTrayHandle()
|
|
||||||
{
|
|
||||||
return WindowHelper.GetHandle(ShellTrayHandleName);
|
|
||||||
}
|
|
||||||
|
|
||||||
[DllImport("shell32.dll", SetLastError = true)]
|
|
||||||
private static extern IntPtr SHAppBarMessage(AppBarMessage dwMessage, ref AppBarData pData);
|
|
||||||
|
|
||||||
private AppBarData GetAppBarData(IntPtr handle)
|
|
||||||
{
|
|
||||||
return new AppBarData
|
|
||||||
{
|
|
||||||
cbSize = (uint)Marshal.SizeOf(typeof(AppBarData)),
|
|
||||||
hWnd = handle
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void GetAppBarPosition(ref AppBarData appBarData)
|
|
||||||
{
|
|
||||||
SHAppBarMessage(AppBarMessage.GetTaskbarPos, ref appBarData);
|
|
||||||
}
|
|
||||||
|
|
||||||
private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
|
|
||||||
{
|
|
||||||
if (msg == WM_TASKBARCREATED || msg == (int)WndProcMessages.WM_SETTINGCHANGE && (int)wParam == SPI_SETWORKAREA)
|
|
||||||
{
|
|
||||||
TaskbarChanged?.Invoke(this, EventArgs.Empty);
|
|
||||||
}
|
|
||||||
|
|
||||||
return DefWindowProcW(hwnd, (uint)msg, wParam, (lParam));
|
|
||||||
}
|
|
||||||
|
|
||||||
[StructLayout(LayoutKind.Sequential)]
|
|
||||||
private struct AppBarData
|
|
||||||
{
|
|
||||||
public uint cbSize;
|
|
||||||
public IntPtr hWnd;
|
|
||||||
public uint uCallbackMessage;
|
|
||||||
public AppBarEdge uEdge;
|
|
||||||
public RECT rect;
|
|
||||||
public int lParam;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
using Microsoft.Windows.Sdk;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace NotificationFlyout.Wpf.UI.Helpers
|
|
||||||
{
|
|
||||||
public class WindowHelper
|
|
||||||
{
|
|
||||||
public static IntPtr GetHandle(string windowName)
|
|
||||||
{
|
|
||||||
return PInvoke.FindWindow(windowName, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static uint GetDpi(IntPtr handle)
|
|
||||||
{
|
|
||||||
return PInvoke.GetDpiForWindow((HWND)handle);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"$schema": "D:\\git\\CsWin32\\src\\Microsoft.Windows.CsWin32\\settings.schema.json",
|
||||||
|
"emitSingleFile": true
|
||||||
|
}
|
||||||
@@ -12,12 +12,15 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Windows.CsWin32" Version="0.1.319-beta">
|
<None Remove="NativeMethods.json" />
|
||||||
<PrivateAssets>all</PrivateAssets>
|
</ItemGroup>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
|
||||||
</PackageReference>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.19041.1" />
|
<AdditionalFiles Include="NativeMethods.json" />
|
||||||
<PackageReference Include="System.Drawing.Common" Version="5.0.1" />
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\NotificationFlyout.Shared.UI\NotificationFlyout.Shared.UI.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
+21
-21
@@ -14,7 +14,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
|
|||||||
global.json = global.json
|
global.json = global.json
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Uwp.UI", "NotificationFlyout.Uwp.UI\NotificationFlyout.Uwp.UI.csproj", "{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotificationFlyout.Shared.UI", "NotificationFlyout.Shared.UI\NotificationFlyout.Shared.UI.csproj", "{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -90,26 +90,26 @@ Global
|
|||||||
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x64.Build.0 = Release|x64
|
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x64.Build.0 = Release|x64
|
||||||
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x86.ActiveCfg = Release|Any CPU
|
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x86.Build.0 = Release|Any CPU
|
{29430194-7EDE-4C33-AF59-CE121F48F66E}.Release|x86.Build.0 = Release|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|Any CPU.ActiveCfg = Debug|x64
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|Any CPU.Build.0 = Debug|x64
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Debug|ARM.ActiveCfg = Debug|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|ARM.Build.0 = Debug|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Debug|ARM.Build.0 = Debug|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Debug|ARM64.ActiveCfg = Debug|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|ARM64.Build.0 = Debug|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Debug|ARM64.Build.0 = Debug|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|x64.ActiveCfg = Debug|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|x64.Build.0 = Debug|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|x86.ActiveCfg = Debug|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Debug|x86.Build.0 = Debug|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Debug|x86.Build.0 = Debug|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|Any CPU.Build.0 = Release|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|ARM.ActiveCfg = Release|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Release|ARM.ActiveCfg = Release|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|ARM.Build.0 = Release|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Release|ARM.Build.0 = Release|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|ARM64.ActiveCfg = Release|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Release|ARM64.ActiveCfg = Release|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|ARM64.Build.0 = Release|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Release|ARM64.Build.0 = Release|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|x64.ActiveCfg = Release|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|x64.Build.0 = Release|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Release|x64.Build.0 = Release|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|x86.ActiveCfg = Release|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Release|x86.ActiveCfg = Release|Any CPU
|
||||||
{3FE0D7F7-1173-4989-BE6C-AD28FE0D4AC9}.Release|x86.Build.0 = Release|Any CPU
|
{B88D3299-5C7D-4ED1-A508-F72637DEFE1E}.Release|x86.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
Reference in New Issue
Block a user