-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add SystemBackdrop API for GetStoreAppInstaller
Add SystemBackdrop API for GetStoreAppInstaller
- Loading branch information
1 parent
cdfa008
commit a3fb81d
Showing
47 changed files
with
6,266 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using System; | ||
using Windows.System; | ||
using Windows.UI.Composition.Desktop; | ||
using Windows.UI.Xaml; | ||
using WindowsTools.WindowsAPI.ComTypes; | ||
|
||
namespace GetStoreAppInstaller.Helpers.Backdrop | ||
{ | ||
/// <summary> | ||
/// 背景色辅助类 | ||
/// </summary> | ||
public static class BackdropHelper | ||
{ | ||
/// <summary> | ||
/// 初始化 DesktopWindowTarget(表示作为合成目标的窗口) | ||
/// </summary> | ||
public static DesktopWindowTarget InitializeDesktopWindowTarget(IntPtr handle, bool isTopMost) | ||
{ | ||
if (handle == nint.Zero) | ||
{ | ||
throw new NullReferenceException("窗口句柄无效"); | ||
} | ||
|
||
IntPtr desktopWindowTargetPtr = IntPtr.Zero; | ||
if (DispatcherQueue.GetForCurrentThread() is not null) | ||
{ | ||
ICompositorDesktopInterop interop = Window.Current.Compositor as object as ICompositorDesktopInterop; | ||
interop.CreateDesktopWindowTarget(handle, isTopMost, out desktopWindowTargetPtr); | ||
} | ||
|
||
return desktopWindowTargetPtr != IntPtr.Zero ? DesktopWindowTarget.FromAbi(desktopWindowTargetPtr) : null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
using GetStoreAppInstaller.WindowsAPI.ComTypes; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Windows.Foundation; | ||
using Windows.Graphics.Effects; | ||
|
||
namespace GetStoreAppInstaller.UI.Backdrop | ||
{ | ||
[Guid("81C5B77B-13F8-4CDD-AD20-C890547AC65D")] | ||
public sealed partial class BlendEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop | ||
{ | ||
private readonly IPropertyValueStatics propertyValue = PropertyValue.As<IPropertyValueStatics>(); | ||
|
||
public BlendEffectMode Mode { get; set; } = BlendEffectMode.Multiply; | ||
|
||
public string Name { get; set; } = string.Empty; | ||
|
||
public IGraphicsEffectSource Background { get; set; } | ||
|
||
public IGraphicsEffectSource Foreground { get; set; } | ||
|
||
public int GetEffectId(out Guid id) | ||
{ | ||
id = typeof(BlendEffect).GUID; | ||
return 0; | ||
} | ||
|
||
public int GetNamedPropertyMapping(IntPtr name, out uint index, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping) | ||
{ | ||
switch (Marshal.PtrToStringUni(name)) | ||
{ | ||
case nameof(Mode): | ||
{ | ||
index = 0; | ||
mapping = GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT; | ||
break; | ||
} | ||
default: | ||
{ | ||
index = 0xFF; | ||
mapping = (GRAPHICS_EFFECT_PROPERTY_MAPPING)0xFF; | ||
break; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
public int GetProperty(uint index, out IntPtr source) | ||
{ | ||
if (index is 0) | ||
{ | ||
propertyValue.CreateUInt32((uint)Mode, out IntPtr ptr); | ||
if (ptr != IntPtr.Zero) | ||
{ | ||
source = ptr; | ||
return 0; | ||
} | ||
} | ||
|
||
source = IntPtr.Zero; | ||
return -2147483637; | ||
} | ||
|
||
public int GetPropertyCount(out uint count) | ||
{ | ||
count = 1; | ||
return 0; | ||
} | ||
|
||
public int GetSource(uint index, out IGraphicsEffectSource source) | ||
{ | ||
if (index is 0) | ||
{ | ||
source = Background; | ||
return 0; | ||
} | ||
else if (index is 1) | ||
{ | ||
source = Foreground; | ||
return 0; | ||
} | ||
else | ||
{ | ||
source = null; | ||
return 2147483637; | ||
} | ||
} | ||
|
||
public int GetSourceCount(out uint count) | ||
{ | ||
count = 2; | ||
return 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
namespace GetStoreAppInstaller.UI.Backdrop | ||
{ | ||
public enum BlendEffectMode | ||
{ | ||
Multiply = 0, | ||
Screen = 1, | ||
Darken = 2, | ||
Lighten = 3, | ||
Dissolve = 4, | ||
ColorBurn = 5, | ||
LinearBurn = 6, | ||
DarkerColor = 7, | ||
LighterColor = 8, | ||
ColorDodge = 9, | ||
LinearDodge = 10, | ||
Overlay = 11, | ||
SoftLight = 12, | ||
HardLight = 13, | ||
VividLight = 14, | ||
LinearLight = 15, | ||
PinLight = 16, | ||
HardMix = 17, | ||
Difference = 18, | ||
Exclusion = 19, | ||
Hue = 20, | ||
Saturation = 21, | ||
Color = 22, | ||
Luminosity = 23, | ||
Subtract = 24, | ||
Division = 25 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
using GetStoreAppInstaller.WindowsAPI.ComTypes; | ||
using System; | ||
using System.Runtime.InteropServices; | ||
using Windows.Foundation; | ||
using Windows.Graphics.Effects; | ||
|
||
namespace GetStoreAppInstaller.UI.Backdrop | ||
{ | ||
[Guid("2A2D49C0-4ACF-43C7-8C6A-7C4A27874D27")] | ||
public sealed partial class BorderEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop | ||
{ | ||
private readonly IPropertyValueStatics propertyValue = PropertyValue.As<IPropertyValueStatics>(); | ||
|
||
public string Name { get; set; } = string.Empty; | ||
|
||
public CanvasEdgeBehavior ExtendX { get; set; } = CanvasEdgeBehavior.Clamp; | ||
|
||
public CanvasEdgeBehavior ExtendY { get; set; } = CanvasEdgeBehavior.Clamp; | ||
|
||
public IGraphicsEffectSource Source { get; set; } | ||
|
||
public int GetEffectId(out Guid id) | ||
{ | ||
id = typeof(BorderEffect).GUID; | ||
return 0; | ||
} | ||
|
||
public int GetNamedPropertyMapping(IntPtr name, out uint index, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping) | ||
{ | ||
switch (Marshal.PtrToStringUni(name)) | ||
{ | ||
case nameof(ExtendX): | ||
{ | ||
index = 0; | ||
mapping = GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT; | ||
break; | ||
} | ||
case nameof(ExtendY): | ||
{ | ||
index = 1; | ||
mapping = GRAPHICS_EFFECT_PROPERTY_MAPPING.GRAPHICS_EFFECT_PROPERTY_MAPPING_DIRECT; | ||
break; | ||
} | ||
default: | ||
{ | ||
index = 0xFF; | ||
mapping = (GRAPHICS_EFFECT_PROPERTY_MAPPING)0xFF; | ||
break; | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
public int GetProperty(uint index, out IntPtr source) | ||
{ | ||
if (index is 0) | ||
{ | ||
propertyValue.CreateUInt32((uint)ExtendX, out IntPtr ptr); | ||
|
||
if (ptr != IntPtr.Zero) | ||
{ | ||
source = ptr; | ||
return 0; | ||
} | ||
} | ||
else if (index is 1) | ||
{ | ||
propertyValue.CreateUInt32((uint)ExtendY, out IntPtr ptr); | ||
|
||
if (ptr != IntPtr.Zero) | ||
{ | ||
source = ptr; | ||
return 0; | ||
} | ||
} | ||
|
||
source = IntPtr.Zero; | ||
return -2147483637; | ||
} | ||
|
||
public int GetPropertyCount(out uint count) | ||
{ | ||
count = 2; | ||
return 0; | ||
} | ||
|
||
public int GetSource(uint index, out IGraphicsEffectSource source) | ||
{ | ||
if (index is 0) | ||
{ | ||
source = Source; | ||
return 0; | ||
} | ||
else | ||
{ | ||
source = null; | ||
return 2147483637; | ||
} | ||
} | ||
|
||
public int GetSourceCount(out uint count) | ||
{ | ||
count = 1; | ||
return 0; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
namespace GetStoreAppInstaller.UI.Backdrop | ||
{ | ||
public enum CanvasComposite | ||
{ | ||
SourceOver = 0, | ||
DestinationOver = 1, | ||
SourceIn = 2, | ||
DestinationIn = 3, | ||
SourceOut = 4, | ||
DestinationOut = 5, | ||
SourceAtop = 6, | ||
DestinationAtop = 7, | ||
Xor = 8, | ||
Add = 9, | ||
Copy = 10, | ||
BoundedCopy = 11, | ||
MaskInvert = 12 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace GetStoreAppInstaller.UI.Backdrop | ||
{ | ||
public enum CanvasEdgeBehavior | ||
{ | ||
Clamp = 0, | ||
Wrap = 1, | ||
Mirror = 2 | ||
} | ||
} |
Oops, something went wrong.