基于WebView2实现的Win11桌面框架,利用插件自定义
Moli
2026-05-02 ae7304f4ee418d517275c2ad3ead1e9ef1888510
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
using System.Windows;
using Moli.Desktop.Configuration;
using Moli.Desktop.Interop;
 
namespace Moli.Desktop.Tests.Interop;
 
public sealed class FakeWin32InteropService : IWin32InteropService
{
    public bool ClickThroughEnabled { get; private set; }
    public bool ToolWindowEnabled { get; private set; }
    public bool NoActivateEnabled { get; private set; }
    public byte Opacity { get; private set; } = 255;
    public DesktopLayerMode? LayerMode { get; private set; }
 
    public IntPtr GetWindowHandle(Window window) => new(42);
 
    public void SetClickThrough(IntPtr hwnd, bool enabled) => ClickThroughEnabled = enabled;
 
    public void SetToolWindow(IntPtr hwnd, bool enabled) => ToolWindowEnabled = enabled;
 
    public void SetNoActivate(IntPtr hwnd, bool enabled) => NoActivateEnabled = enabled;
 
    public void SetLayered(IntPtr hwnd, bool enabled, byte opacity) => Opacity = enabled ? opacity : (byte)255;
 
    public void MoveToDesktopLayer(IntPtr hwnd, DesktopLayerMode mode, MonitorInfo monitor) => LayerMode = mode;
 
    public void SetBottomMost(IntPtr hwnd) => LayerMode = DesktopLayerMode.BottomMost;
 
    public IReadOnlyList<MonitorInfo> GetMonitors() =>
    [
        new MonitorInfo
        {
            Id = new Moli.Desktop.Layout.MonitorId("primary"),
            Bounds = new Moli.Desktop.Layout.RectD(0, 0, 1920, 1080),
            WorkArea = new Moli.Desktop.Layout.RectD(0, 0, 1920, 1040),
            IsPrimary = true
        }
    ];
}