Moved all PInvokes to a lower class without any relianceon WPF, NotificationIconHelper, TaskbarHelper, SystemPersonalisationHelper are WPF window no more
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user