Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 13 additions & 20 deletions MileXamlControlsDemoNetCore/UI/Backdrop/BlendEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,32 @@
using MileXamlControlsDemoNetCore.WindowsAPI.ComTypes;
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using Windows.Graphics.Effects;
using WinRT;

namespace MileXamlControlsDemoNetCore.UI.Backdrop
{
[Guid("81C5B77B-13F8-4CDD-AD20-C890547AC65D")]
[GeneratedComClass, Guid("81C5B77B-13F8-4CDD-AD20-C890547AC65D")]
public sealed partial class BlendEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop
{
public D2D1_BUFFER_PRECISION BufferPrecision { get; set; }

public bool CacheOutput { get; set; }

public BlendEffectMode Mode { get; set; } = BlendEffectMode.Multiply;

public string Name { get; set; } = string.Empty;

public IGraphicsEffectSource Background { get; set; }

public IGraphicsEffectSource Foreground { get; set; }

private string _name = string.Empty;

public string Name
{
get { return _name; }

set { _name = value; }
}

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)
public int GetNamedPropertyMapping(string name, out uint index, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping)
{
switch (Marshal.PtrToStringUni(name))
switch (name)
{
case nameof(Mode):
{
Expand All @@ -51,6 +42,7 @@ public int GetNamedPropertyMapping(IntPtr name, out uint index, out GRAPHICS_EFF
break;
}
}

return 0;
}

Expand All @@ -65,6 +57,7 @@ public int GetProperty(uint index, out IntPtr source)
return 0;
}
}

source = IntPtr.Zero;
return -2147483637;
}
Expand All @@ -75,21 +68,21 @@ public int GetPropertyCount(out uint count)
return 0;
}

public int GetSource(uint index, out IGraphicsEffectSource source)
public int GetSource(uint index, out IntPtr source)
{
if (index is 0)
{
source = Background;
source = MarshalInterface<IGraphicsEffectSource>.FromManaged(Background);
return 0;
}
else if (index is 1)
{
source = Foreground;
source = MarshalInterface<IGraphicsEffectSource>.FromManaged(Foreground);
return 0;
}
else
{
source = null;
source = IntPtr.Zero;
return 2147483637;
}
}
Expand Down
31 changes: 12 additions & 19 deletions MileXamlControlsDemoNetCore/UI/Backdrop/BorderEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,32 @@
using MileXamlControlsDemoNetCore.WindowsAPI.ComTypes;
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using Windows.Graphics.Effects;
using WinRT;

namespace MileXamlControlsDemoNetCore.UI.Backdrop
{
[Guid("2A2D49C0-4ACF-43C7-8C6A-7C4A27874D27")]
public partial class BorderEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop
[GeneratedComClass, Guid("2A2D49C0-4ACF-43C7-8C6A-7C4A27874D27")]
public sealed partial class BorderEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop
{
public D2D1_BUFFER_PRECISION BufferPrecision { get; set; }

public bool CacheOutput { get; set; }
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; }

private string _name = string.Empty;

public string Name
{
get { return _name; }

set { _name = value; }
}

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)
public int GetNamedPropertyMapping(string name, out uint index, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping)
{
switch (Marshal.PtrToStringUni(name))
switch (name)
{
case nameof(ExtendX):
{
Expand All @@ -57,6 +48,7 @@ public int GetNamedPropertyMapping(IntPtr name, out uint index, out GRAPHICS_EFF
break;
}
}

return 0;
}

Expand All @@ -82,6 +74,7 @@ public int GetProperty(uint index, out IntPtr source)
return 0;
}
}

source = IntPtr.Zero;
return -2147483637;
}
Expand All @@ -92,16 +85,16 @@ public int GetPropertyCount(out uint count)
return 0;
}

public int GetSource(uint index, out IGraphicsEffectSource source)
public int GetSource(uint index, out IntPtr source)
{
if (index is 0)
{
source = Source;
source = MarshalInterface<IGraphicsEffectSource>.FromManaged(Source);
return 0;
}
else
{
source = null;
source = IntPtr.Zero;
return 2147483637;
}
}
Expand Down
32 changes: 7 additions & 25 deletions MileXamlControlsDemoNetCore/UI/Backdrop/ColorSourceEffect.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,29 @@
using MileXamlControlsDemoNetCore.Helpers;
using MileXamlControlsDemoNetCore.WindowsAPI.ComTypes;
using System;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using Windows.Graphics.Effects;
using Windows.UI;

namespace MileXamlControlsDemoNetCore.UI.Backdrop
{
[Guid("61C23C20-AE69-4D8E-94CF-50078DF638F2")]
[GeneratedComClass, Guid("61C23C20-AE69-4D8E-94CF-50078DF638F2")]
public sealed partial class ColorSourceEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop
{
public D2D1_BUFFER_PRECISION BufferPrecision { get; set; }

public bool CacheOutput { get; set; }
public string Name { get; set; } = string.Empty;

public Color Color { get; set; } = Color.FromArgb(255, 255, 255, 255);

private string _name = string.Empty;

public string Name
{
get { return _name; }

set { _name = value; }
}

public Vector4 ColorHdr
{
get { return new(Color.R * 255.0f, Color.G * 255.0f, Color.B * 255.0f, Color.A * 255.0f); }

set { Color = Color.FromArgb((byte)(value.W / 255.0f), (byte)(value.X / 255.0f), (byte)(value.Y / 255.0f), (byte)(value.Z / 255.0f)); }
}

public int GetEffectId(out Guid id)
{
id = typeof(ColorSourceEffect).GUID;
return 0;
}

public int GetNamedPropertyMapping(IntPtr name, out uint index, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping)
public int GetNamedPropertyMapping(string name, out uint index, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping)
{
switch (Marshal.PtrToStringUni(name))
switch (name)
{
case nameof(Color):
{
Expand Down Expand Up @@ -82,9 +64,9 @@ public int GetPropertyCount(out uint count)
return 0;
}

public int GetSource(uint index, out IGraphicsEffectSource source)
public int GetSource(uint index, out IntPtr source)
{
source = default;
source = IntPtr.Zero;
return 0;
}

Expand Down
29 changes: 10 additions & 19 deletions MileXamlControlsDemoNetCore/UI/Backdrop/CompositeEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,19 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using Windows.Graphics.Effects;
using WinRT;

namespace MileXamlControlsDemoNetCore.UI.Backdrop
{
[Guid("48FC9F51-F6AC-48F1-8B58-3B28AC46F76D")]
public partial class CompositeEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop
[GeneratedComClass, Guid("48FC9F51-F6AC-48F1-8B58-3B28AC46F76D")]
public sealed partial class CompositeEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop
{
public D2D1_BUFFER_PRECISION BufferPrecision { get; set; }

public bool CacheOutput { get; set; }
public string Name { get; set; } = string.Empty;

public CanvasComposite Mode { get; set; } = CanvasComposite.SourceOver;

private string _name = string.Empty;

public string Name
{
get { return _name; }

set { _name = value; }
}

public List<IGraphicsEffectSource> Sources { get; set; } = [];

public int GetEffectId(out Guid id)
Expand All @@ -33,9 +24,9 @@ public int GetEffectId(out Guid id)
return 0;
}

public int GetNamedPropertyMapping(IntPtr name, out uint index, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping)
public int GetNamedPropertyMapping(string name, out uint index, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping)
{
switch (Marshal.PtrToStringUni(name))
switch (name)
{
case nameof(Mode):
{
Expand Down Expand Up @@ -77,16 +68,16 @@ public int GetPropertyCount(out uint count)
return 0;
}

public int GetSource(uint index, out IGraphicsEffectSource source)
public int GetSource(uint index, out IntPtr source)
{
if (index < Sources.Count)
{
source = Sources[(int)index];
source = MarshalInterface<IGraphicsEffectSource>.FromManaged(Sources[(int)index]);
return 0;
}
else
{
source = null;
source = IntPtr.Zero;
return 2147483637;
}
}
Expand Down
29 changes: 10 additions & 19 deletions MileXamlControlsDemoNetCore/UI/Backdrop/CrossFadeEffect.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,32 @@
using MileXamlControlsDemoNetCore.WindowsAPI.ComTypes;
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.Marshalling;
using Windows.Graphics.Effects;
using WinRT;

namespace MileXamlControlsDemoNetCore.UI.Backdrop
{
[Guid("12F575E8-4DB1-485F-9A84-03A07DD3829F")]
[GeneratedComClass, Guid("12F575E8-4DB1-485F-9A84-03A07DD3829F")]
public sealed partial class CrossFadeEffect : IGraphicsEffect, IGraphicsEffectSource, IGraphicsEffectD2D1Interop
{
public D2D1_BUFFER_PRECISION BufferPrecision { get; set; }

public bool CacheOutput { get; set; }
public string Name { get; set; } = string.Empty;

public float CrossFade { get; set; } = 0.5f;

public IGraphicsEffectSource Source1 { get; set; }

public IGraphicsEffectSource Source2 { get; set; }

private string _name = string.Empty;

public string Name
{
get { return _name; }

set { _name = value; }
}

public int GetEffectId(out Guid id)
{
id = typeof(CrossFadeEffect).GUID;
return 0;
}

public int GetNamedPropertyMapping(IntPtr name, out uint index, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping)
public int GetNamedPropertyMapping(string name, out uint index, out GRAPHICS_EFFECT_PROPERTY_MAPPING mapping)
{
switch (Marshal.PtrToStringUni(name))
switch (name)
{
case nameof(CrossFade):
{
Expand Down Expand Up @@ -77,21 +68,21 @@ public int GetPropertyCount(out uint count)
return 0;
}

public int GetSource(uint index, out IGraphicsEffectSource source)
public int GetSource(uint index, out IntPtr source)
{
if (index is 0)
{
source = Source1;
source = MarshalInterface<IGraphicsEffectSource>.FromManaged(Source1);
return 0;
}
else if (index is 1)
{
source = Source2;
source = MarshalInterface<IGraphicsEffectSource>.FromManaged(Source2);
return 0;
}
else
{
source = null;
source = IntPtr.Zero;
return 2147483637;
}
}
Expand Down
Loading