| Name | Message | Date |
|---|---|---|
| 📄 OutGridTree.cs | 1 month ago | |
| 📄 OutGridTree.csproj | 1 month ago | |
| 📄 packages.lock.json | 1 month ago |
📄
OutGridTree/OutGridTree.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
using System; using System.Management.Automation; using System.Management.Automation.Internal; using System.Threading; using Avalonia; using Avalonia.Controls; using Avalonia.Controls.ApplicationLifetimes; namespace OutGridTree; [Cmdlet(VerbsData.Out, "GridTree")] [Alias("ogt")] public sealed class OutGridTree : Cmdlet { [Parameter(Mandatory = true, Position = 0, ValueFromPipeline = true)] public PSObject InputObject { get; set; } = AutomationNull.Value; private ClassicDesktopStyleApplicationLifetime? lifetime; private Application? application; private Thread? uiThread; protected override void BeginProcessing() { uiThread = new Thread(RunUi); uiThread.Start(); } private void RunUi() { lifetime = new ClassicDesktopStyleApplicationLifetime(); AppBuilder .Configure(() => { application = new(); return application; }) .UsePlatformDetect() .SetupWithLifetime(lifetime); lifetime.MainWindow = new Window() { Title = "Out-GridTree" }; if (application is null) { ThrowTerminatingError( new( new InvalidOperationException("Could not initialize UI system."), "Initialize UI system", ErrorCategory.InvalidOperation, null ) ); return; } application.Run(lifetime.MainWindow); } protected override void ProcessRecord() { // TODO: Add record to window WriteDebug($"Processing record: {InputObject}"); } protected override void EndProcessing() { // TODO: Wait for window to close WriteDebug("End processing"); uiThread?.Join(); WriteDebug("Exited"); } protected override void StopProcessing() { // TODO: Close window WriteDebug("Stop processing"); lifetime?.Shutdown(); WriteDebug("Shutdown"); } }