-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMauiProgram.cs
More file actions
114 lines (100 loc) · 4.1 KB
/
MauiProgram.cs
File metadata and controls
114 lines (100 loc) · 4.1 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
/*
* Copyright (c) 2025 CodeSoupCafe LLC
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
using CommunityToolkit.Maui;
using CommunityToolkit.Maui.Storage;
using Microsoft.Maui.LifecycleEvents;
using LunaDraw.Logic.Utils;
using LunaDraw.Logic.Models;
using LunaDraw.Logic.ViewModels;
using LunaDraw.Pages;
using Microsoft.Extensions.Logging;
using ReactiveUI;
using SkiaSharp.Views.Maui.Controls.Hosting;
using Splat;
#if WINDOWS
using Microsoft.UI.Xaml.Media;
#endif
namespace LunaDraw;
public static class MauiProgram
{
public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
// Initialize Splat and ReactiveUI
Locator.CurrentMutable.InitializeSplat();
Locator.CurrentMutable.InitializeReactiveUI();
builder
.UseMauiApp<App>()
.UseSkiaSharp()
.UseMauiCommunityToolkit()
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
})
.ConfigureLifecycleEvents(events =>
{
#if WINDOWS
events.AddWindows(wndLifeCycleBuilder =>
{
wndLifeCycleBuilder.OnWindowCreated(window =>
{
window.SystemBackdrop = new DesktopAcrylicBackdrop();
if (Preferences.Get(AppPreference.IsTransparentBackgroundEnabled.ToString(), false))
{
PlatformHelper.EnableTrueTransparency(180); // Fully transparent
}
});
});
#endif
});
// Register Core State Managers
builder.Services.AddSingleton<IMessageBus>(new MessageBus());
builder.Services.AddSingleton<NavigationModel>();
builder.Services.AddSingleton<SelectionObserver>();
builder.Services.AddSingleton<ILayerFacade, LayerFacade>();
// Register Logic Services
builder.Services.AddSingleton<ICanvasInputHandler, CanvasInputHandler>();
builder.Services.AddSingleton<ClipboardMemento>();
builder.Services.AddSingleton<IBitmapCache, LunaDraw.Logic.Utils.BitmapCache>();
builder.Services.AddSingleton<IPreferencesFacade, PreferencesFacade>();
builder.Services.AddSingleton<IFileSaver>(FileSaver.Default);
builder.Services.AddSingleton<IDrawingStorageMomento, DrawingStorageMomento>();
builder.Services.AddSingleton<LunaDraw.Logic.Services.IThumbnailCacheFacade, LunaDraw.Logic.Services.ThumbnailCacheFacade>();
builder.Services.AddSingleton<IDrawingThumbnailFacade, DrawingThumbnailFacade>();
// Register ViewModels
builder.Services.AddSingleton<LayerPanelViewModel>();
builder.Services.AddSingleton<SelectionViewModel>();
builder.Services.AddSingleton<HistoryViewModel>();
builder.Services.AddSingleton<GalleryViewModel>();
builder.Services.AddTransient<DrawingGalleryPopupViewModel>();
builder.Services.AddTransient<MainViewModel>();
builder.Services.AddSingleton<ToolbarViewModel>();
// Register Pages
builder.Services.AddTransient<MainPage>();
#if DEBUG
builder.Logging.AddDebug();
#endif
return builder.Build();
}
}