-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathProgram.cs
More file actions
73 lines (65 loc) · 2.88 KB
/
Copy pathProgram.cs
File metadata and controls
73 lines (65 loc) · 2.88 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
using System;
using System.IO;
using System.Windows.Forms;
namespace IncomingConnectionOverlay;
internal static class Program
{
/// <summary>
/// 入口。
/// 默认:全屏透明覆盖层(置顶、点击穿透),运行后播放一次 Incoming Connection 动画并自动退出。
/// --preview:以普通窗口模式运行,便于调试动画(可拖动、可缩放、ESC 退出)。
/// --snapshot <path>:渲染一帧(t=3.0s)到指定 png 后退出,用于无头自验证绘制内容。
/// --watch:驻留后台监视入站连接,检测到疑似端口扫描(nmap 等)时自动触发一次覆盖层动画。
/// </summary>
[STAThread]
private static void Main(string[] args)
{
bool preview = Array.Exists(args, a => a.Equals("--preview", StringComparison.OrdinalIgnoreCase));
int snapIdx = Array.FindIndex(args, a => a.Equals("--snapshot", StringComparison.OrdinalIgnoreCase));
string snapshotPath = snapIdx >= 0 && snapIdx + 1 < args.Length ? args[snapIdx + 1] : null;
bool watch = Array.Exists(args, a => a.Equals("--watch", StringComparison.OrdinalIgnoreCase));
// 日志为会话级:每次启动清空上次的 overlay.log(删除失败静默,不影响运行)
try
{
if (File.Exists(OverlayForm.LogPath))
{
File.Delete(OverlayForm.LogPath);
}
}
catch
{
}
// DPI awareness 由 app.manifest 声明(PerMonitorV2),net48 无 Application.SetHighDpiMode
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
if (watch)
{
// 驻留监视:被端口扫描就弹一次覆盖层(见 ScanWatcher.cs)
Application.Run(new ScanWatcher.WatchForm());
return;
}
if (snapshotPath != null)
{
// 可选第三参:快照时间点(默认 3.0s)
float snapT = 3.0f;
if (snapIdx + 2 < args.Length && float.TryParse(args[snapIdx + 2], out float pt))
{
snapT = pt;
}
using var form = new OverlayForm(preview: false, autostart: false);
form.SaveSnapshot(snapshotPath, snapT);
Console.WriteLine($"snapshot saved: {snapshotPath} (t={snapT})");
return;
}
// --dumpsound <path>:把合成的激活音效 wav 写盘(调试用)
int dumpIdx = Array.FindIndex(args, a => a.Equals("--dumpsound", StringComparison.OrdinalIgnoreCase));
if (dumpIdx >= 0 && dumpIdx + 1 < args.Length)
{
using var assets = Assets.Load();
assets.DumpActivateSound(args[dumpIdx + 1]);
Console.WriteLine($"sound dumped: {args[dumpIdx + 1]}");
return;
}
Application.Run(new OverlayForm(preview));
}
}