-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
WindowHandler.cs
68 lines (62 loc) · 2.02 KB
/
WindowHandler.cs
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using Microsoft.Extensions.DependencyInjection;
#if __IOS__ || MACCATALYST
using PlatformView = UIKit.UIWindow;
#elif MONOANDROID
using PlatformView = Android.App.Activity;
#elif WINDOWS
using PlatformView = Microsoft.UI.Xaml.Window;
#elif TIZEN
using PlatformView = Tizen.NUI.Window;
#endif
namespace Microsoft.Maui.Handlers
{
public partial class WindowHandler : IWindowHandler
{
public static IPropertyMapper<IWindow, IWindowHandler> Mapper = new PropertyMapper<IWindow, IWindowHandler>(ElementHandler.ElementMapper)
{
[nameof(IWindow.Title)] = MapTitle,
[nameof(IWindow.Content)] = MapContent,
[nameof(IWindow.X)] = MapX,
[nameof(IWindow.Y)] = MapY,
[nameof(IWindow.Width)] = MapWidth,
[nameof(IWindow.Height)] = MapHeight,
#if WINDOWS || MACCATALYST
[nameof(IWindow.MaximumWidth)] = MapMaximumWidth,
[nameof(IWindow.MaximumHeight)] = MapMaximumHeight,
[nameof(IWindow.MinimumWidth)] = MapMinimumWidth,
[nameof(IWindow.MinimumHeight)] = MapMinimumHeight,
#endif
#if ANDROID || WINDOWS || TIZEN
[nameof(IToolbarElement.Toolbar)] = MapToolbar,
#endif
#if WINDOWS || IOS
[nameof(IMenuBarElement.MenuBar)] = MapMenuBar,
#endif
#if WINDOWS
[nameof(IWindow.FlowDirection)] = MapFlowDirection,
[nameof(IWindow.TitleBarDragRectangles)] = MapTitleBarDragRectangles
#endif
};
public static CommandMapper<IWindow, IWindowHandler> CommandMapper = new(ElementCommandMapper)
{
[nameof(IWindow.RequestDisplayDensity)] = MapRequestDisplayDensity,
};
public WindowHandler()
: base(Mapper, CommandMapper)
{
}
public WindowHandler(IPropertyMapper? mapper)
: base(mapper ?? Mapper, CommandMapper)
{
}
public WindowHandler(IPropertyMapper? mapper, CommandMapper? commandMapper)
: base(mapper ?? Mapper, commandMapper ?? CommandMapper)
{
}
#if !(NETSTANDARD || !PLATFORM)
protected override PlatformView CreatePlatformElement() =>
MauiContext?.Services.GetService<PlatformView>() ?? throw new InvalidOperationException($"MauiContext did not have a valid window.");
#endif
}
}