forked from Yupmoh/Ryn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
113 lines (106 loc) · 4.13 KB
/
Copy pathProgram.cs
File metadata and controls
113 lines (106 loc) · 4.13 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
using HelloWindow;
using Ryn.Core;
using Ryn.Ipc;
var html = """
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Ryn Demo</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
background: #0f0f0f; color: #e0e0e0;
display: flex; flex-direction: column; align-items: center;
justify-content: center; height: 100vh; gap: 24px;
}
h1 { font-size: 2em; color: #7c3aed; }
.card {
background: #1a1a2e; border: 1px solid #2a2a4a; border-radius: 12px;
padding: 24px; width: 400px;
}
.card h2 { font-size: 1.1em; color: #a78bfa; margin-bottom: 12px; }
input, button {
padding: 8px 16px; border-radius: 8px; border: 1px solid #3a3a5a;
background: #252540; color: #e0e0e0; font-size: 14px;
}
button {
background: #7c3aed; border: none; cursor: pointer; font-weight: 600;
}
button:hover { background: #6d28d9; }
.row { display: flex; gap: 8px; margin-bottom: 12px; }
.result {
background: #0d0d1a; border-radius: 8px; padding: 12px;
font-family: monospace; min-height: 40px; margin-top: 8px;
border: 1px solid #2a2a4a;
}
.label { font-size: 12px; color: #888; margin-bottom: 4px; }
</style>
</head>
<body>
<h1>Ryn IPC Demo</h1>
<div class="card">
<h2>Greet Command</h2>
<div class="row">
<input id="name" type="text" placeholder="Your name" value="World" />
<button onclick="doGreet()">Greet</button>
</div>
<div class="label">Result:</div>
<div class="result" id="greetResult">Click Greet to call C#</div>
</div>
<div class="card">
<h2>Add Command</h2>
<div class="row">
<input id="a" type="number" value="17" style="width:80px" />
<span style="color:#888;align-self:center">+</span>
<input id="b" type="number" value="25" style="width:80px" />
<button onclick="doAdd()">Add</button>
</div>
<div class="label">Result:</div>
<div class="result" id="addResult">Click Add to call C#</div>
</div>
<div class="card">
<h2>Get Time Command</h2>
<div class="row">
<button onclick="doTime()">Get Server Time</button>
</div>
<div class="label">Result:</div>
<div class="result" id="timeResult">Click to get C# DateTime.Now</div>
</div>
<script>
async function doGreet() {
var name = document.getElementById('name').value;
var result = await window.__ryn.invoke('app.greet', { name: name });
document.getElementById('greetResult').textContent = result;
}
async function doAdd() {
var a = parseInt(document.getElementById('a').value);
var b = parseInt(document.getElementById('b').value);
var result = await window.__ryn.invoke('app.add', { a: a, b: b });
document.getElementById('addResult').textContent = a + ' + ' + b + ' = ' + result;
}
async function doTime() {
var result = await window.__ryn.invoke('app.getTime', {});
document.getElementById('timeResult').textContent = result;
}
</script>
</body>
</html>
""";
var app = RynApplication.CreateBuilder()
.ConfigureOptions(opts =>
{
opts.Title = "Ryn IPC Demo";
opts.Width = 500;
opts.Height = 700;
opts.Html = html;
opts.DevTools = true;
})
.ConfigureServices(services =>
{
services.AddRynCommands();
services.AddDemoCommands();
})
.Build();
await app.RunAsync();