-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
89 lines (83 loc) · 3.8 KB
/
Program.cs
File metadata and controls
89 lines (83 loc) · 3.8 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
using Photino.NET;
using System.Drawing;
using System.Text;
using EMI;
using EMI.Assets;
using EMI.Frontend;
using SharpCompress.Compressors.ZStandard.Unsafe;
using System.Runtime.CompilerServices;
namespace EMI.UI
{
//NOTE: To hide the console window, go to the project properties and change the Output Type to Windows Application.
// Or edit the .csproj file and change the <OutputType> tag from "WinExe" to "Exe".
internal class Program
{
private static readonly CancellationTokenSource _cts = new();
[STAThread]
static void Main(string[] args)
{
// Window title declared here for visibility
string windowTitle = "Eisbears Modpack Installer 1";
// Creating a new PhotinoWindow instance with the fluent API
var window = new PhotinoWindow()
.SetTitle(windowTitle)
// Resize to a percentage of the main monitor work area
.SetUseOsDefaultSize(false)
.SetSize(new Size(1024, 800))
// Center window in the middle of the screen
.Center()
// Users can resize windows by default.
// Let's make this one fixed instead.
.SetResizable(false)
.RegisterWebMessageReceivedHandler((object? sender, string message) =>
{
if (sender == null) return;
if (message == "ui-ready")
{
var win = (PhotinoWindow)sender!;
Frontend.LoadFrontend.LoadAll(win);
}
if (message == "continue")
{
_ = ModpackInstaller.DownloadModpack((PhotinoWindow)sender!, _cts.Token);
}
if (message == "cancel" || message == "close")
{
_cts.Cancel();
}
if (message == "close")
{
Environment.Exit(0);
}
})
//.RegisterCustomSchemeHandler("app", (object sender, string scheme, string url, out string contentType) =>
//{
// contentType = "text/javascript";
// return new MemoryStream(Encoding.UTF8.GetBytes(@"
// (() =>{
// window.setTimeout(() => {
// alert(`🎉 Dynamically inserted JavaScript.`);
// }, 1000);
// })();
// "));
//})
//// Most event handlers can be registered after the
//// PhotinoWindow was instantiated by calling a registration
//// method like the following RegisterWebMessageReceivedHandler.
//// This could be added in the PhotinoWindowOptions if preferred.
//.RegisterWebMessageReceivedHandler((object sender, string message) =>
//{
// var window = (PhotinoWindow)sender;
// // The message argument is coming in from sendMessage.
// // "window.external.sendMessage(message: string)"
// string response = $"Received message: \"{message}\"";
// // Send a message back the to JavaScript event handler.
// // "window.external.receiveMessage(callback: Function)"
// window.SendWebMessage(response);
//})
.Load("wwwroot/aigen.html"); // Can be used with relative path strings or "new URI()" instance to load a website.
// Code here:
window.WaitForClose(); // Starts the application event loop
}
}
}