Fixed some dependancy issues, added prelogo and adjusted init and mainwindow display to load AFTER osquery finishes it's scan.
This commit is contained in:
@@ -16,18 +16,47 @@ public partial class App : Application
|
||||
[STAThread]
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
MainAsync(args).GetAwaiter().GetResult();
|
||||
// Show splash screen with fade-in effect
|
||||
var splash = new SplashScreen("Assets/splash.png");
|
||||
splash.Show(false, true); // autoClose=false, topMost=true
|
||||
|
||||
// Allow 1 second for fade-in to complete
|
||||
System.Threading.Thread.Sleep(1000);
|
||||
|
||||
MainAsync(args, splash).GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
private static async Task MainAsync(string[] args)
|
||||
private static async Task MainAsync(string[] args, SplashScreen splash)
|
||||
{
|
||||
using IHost host = CreateHostBuilder(args).Build();
|
||||
await host.StartAsync().ConfigureAwait(true);
|
||||
|
||||
App app = new();
|
||||
app.InitializeComponent();
|
||||
app.MainWindow = host.Services.GetRequiredService<MainWindow>();
|
||||
app.MainWindow.Visibility = Visibility.Visible;
|
||||
|
||||
var mainWindow = host.Services.GetRequiredService<MainWindow>();
|
||||
app.MainWindow = mainWindow;
|
||||
|
||||
// Keep MainWindow hidden until system info loads
|
||||
mainWindow.Visibility = Visibility.Hidden;
|
||||
|
||||
// When system info finishes loading, show MainWindow and close splash
|
||||
mainWindow.SystemInfoLoaded += (s, e) =>
|
||||
{
|
||||
// Use dispatcher to handle UI thread timing
|
||||
mainWindow.Dispatcher.BeginInvoke(async () =>
|
||||
{
|
||||
// Wait 1 second before starting fade-out
|
||||
await Task.Delay(1000);
|
||||
|
||||
// Show the main window
|
||||
mainWindow.Visibility = Visibility.Visible;
|
||||
|
||||
// Close splash with fade-out effect (1 second)
|
||||
splash.Close(TimeSpan.FromMilliseconds(1000));
|
||||
});
|
||||
};
|
||||
|
||||
app.Run();
|
||||
|
||||
await host.StopAsync().ConfigureAwait(true);
|
||||
|
||||
BIN
LD-SysInfo/Assets/splash.png
Normal file
BIN
LD-SysInfo/Assets/splash.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 113 KiB |
@@ -51,11 +51,15 @@
|
||||
<ApplicationDefinition Remove="App.xaml" />
|
||||
<None Remove="Assets\osqueryi.exe" />
|
||||
<None Remove="Assets\trayicon.ico" />
|
||||
<None Remove="Assets\splash.png" />
|
||||
<None Remove="config.json" />
|
||||
<Content Include="Assets\LDShortcut.ico" />
|
||||
<Content Include="Assets\osqueryi.exe">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<SplashScreen Include="Assets\splash.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</SplashScreen>
|
||||
<Page Include="App.xaml" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -51,6 +51,9 @@ namespace LD_SysInfo
|
||||
|
||||
private static readonly string ConfigPath = Path.Combine(AppContext.BaseDirectory, "config.json");
|
||||
|
||||
// Event to signal when system info loading is complete
|
||||
public event EventHandler? SystemInfoLoaded;
|
||||
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
@@ -78,7 +81,10 @@ namespace LD_SysInfo
|
||||
VersionTextBlock.Text = "v0.0.0";
|
||||
}
|
||||
LoadConfig();
|
||||
DisplaySystemInfo();
|
||||
|
||||
// Load system info asynchronously to avoid blocking UI
|
||||
Task.Run(async () => await DisplaySystemInfoAsync());
|
||||
|
||||
AutoLogin();
|
||||
|
||||
// 🔍 Perform initial connectivity check
|
||||
@@ -270,6 +276,22 @@ namespace LD_SysInfo
|
||||
}
|
||||
}
|
||||
|
||||
private async Task DisplaySystemInfoAsync()
|
||||
{
|
||||
// Run system info collection on background thread
|
||||
var sysInfo = await Task.Run(() => SystemInfo.GetSystemInfo());
|
||||
|
||||
// Update UI on UI thread
|
||||
await Dispatcher.InvokeAsync(() =>
|
||||
{
|
||||
_cachedSystemInfo = sysInfo;
|
||||
UpdateSysInfoUI(_cachedSystemInfo);
|
||||
|
||||
// Notify that system info has loaded
|
||||
SystemInfoLoaded?.Invoke(this, EventArgs.Empty);
|
||||
});
|
||||
}
|
||||
|
||||
private void DisplaySystemInfo()
|
||||
{
|
||||
_cachedSystemInfo = SystemInfo.GetSystemInfo();
|
||||
|
||||
Reference in New Issue
Block a user