/
MauiProgram.cs
86 lines (71 loc) · 2.35 KB
/
MauiProgram.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using Microsoft.Maui;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Hosting;
using Microsoft.Maui.Hosting;
namespace Maui.Controls.Sample
{
public static class MauiProgram
{
public static MauiApp CreateMauiApp() =>
MauiApp
.CreateBuilder()
.UseMauiMaps()
.UseMauiApp<App>()
.Build();
}
class App : Application
{
public const string AppName = "CompatibilityGalleryControls";
public const string DefaultMainPageId = "ControlGalleryMainPage";
public App()
{
SetMainPage(CreateDefaultMainPage());
}
public static bool PreloadTestCasesIssuesList { get; set; } = true;
public void SetMainPage(Page rootPage)
{
MainPage = rootPage;
}
public Page CreateDefaultMainPage()
{
return new CoreNavigationPage();
}
protected override void OnAppLinkRequestReceived(Uri uri)
{
base.OnAppLinkRequestReceived(uri);
}
#if WINDOWS || MACCATALYST
protected override Window CreateWindow(IActivationState activationState)
{
var window = base.CreateWindow(activationState);
// For desktop use a fixed window size, so that screenshots are deterministic,
// matching (as much as possible) between dev machines and CI. Currently
// our Windows CI machines run at 1024x768 resolution and the window size can't
// be larger than screen size. We'll investigate increasing CI screen
// resolution in the future so we can have a bigger window, but for now
// this size works.
const int desktopWindowWidth = 1024;
const int desktopWindowHeight = 768;
#if WINDOWS
window.Width = desktopWindowWidth;
window.Height = desktopWindowHeight;
var info = Microsoft.Maui.Devices.DeviceDisplay.MainDisplayInfo;
int screenWidth = (int)(info.Width / info.Density);
int screenHeight = (int)(info.Height / info.Density);
// Center the window on the screen, to ensure no part of it goes off screen in CI
window.X = (screenWidth - desktopWindowWidth) / 2;
window.Y = (screenHeight - desktopWindowHeight) / 2;
#elif MACCATALYST
// Setting max and min is currently needed to force the size on Catalyst;
// just setting width/height has no effect on Catalyst
window.MaximumWidth = desktopWindowWidth;
window.MinimumWidth = desktopWindowWidth;
window.MaximumHeight = desktopWindowHeight;
window.MinimumHeight = desktopWindowHeight;
#endif
return window;
}
#endif
}
}