-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
62 lines (51 loc) · 2.01 KB
/
Program.cs
File metadata and controls
62 lines (51 loc) · 2.01 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
using RightMgr.Services;
using RightMgr.Views;
namespace RightMgr;
public static class Program
{
[STAThread]
public static void Main(string[] args)
{
Environment.SetEnvironmentVariable("MICROSOFT_WINDOWSAPPRUNTIME_BASE_DIRECTORY", AppContext.BaseDirectory);
if (args.Any(x => x.Equals("--print-all", StringComparison.OrdinalIgnoreCase)))
{
PrintAll();
return;
}
var app = new App();
app.InitializeComponent();
app.Run(new MainWindow(ParseThemeMode(args) ?? AppConfigService.LoadThemeMode() ?? AppThemeMode.System));
}
private static AppThemeMode? ParseThemeMode(string[] args)
{
for (var i = 0; i < args.Length; i++)
{
var arg = args[i];
if (arg.Equals("--light", StringComparison.OrdinalIgnoreCase))
return AppThemeMode.Light;
if (arg.Equals("--dark", StringComparison.OrdinalIgnoreCase))
return AppThemeMode.Dark;
if (arg.Equals("--system", StringComparison.OrdinalIgnoreCase))
return AppThemeMode.System;
string? value = null;
if (arg.StartsWith("--theme=", StringComparison.OrdinalIgnoreCase))
value = arg["--theme=".Length..];
else if (arg.Equals("--theme", StringComparison.OrdinalIgnoreCase) && i + 1 < args.Length)
value = args[++i];
if (value == null)
continue;
return AppConfigService.ParseThemeMode(value);
}
return null;
}
private static void PrintAll()
{
var items = ContextMenuRegistryScanner.ScanAll();
var text = ContextMenuRegistryScanner.FormatAll(items);
var output = Path.Combine(Environment.CurrentDirectory, "RightMgr-print-all.txt");
File.WriteAllText(output, text);
Console.WriteLine($"RightMgr scanned {items.Count} context menu entries.");
Console.WriteLine($"Output: {output}");
Console.WriteLine(text);
}
}