Files

48 lines
1.1 KiB
C#
Raw Permalink Normal View History

2026-08-27 10:57:58 -06:00
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using Pulsar.Server.Controls.Wpf;
using Pulsar.Server.Statistics;
#nullable enable
namespace Pulsar.Server.Controls
{
public sealed class StatsElementHost : ElementHost
{
private readonly StatsView _statsView;
private ClientStatisticsSnapshot? _lastSnapshot;
public StatsElementHost()
{
_statsView = new StatsView();
Child = _statsView;
Dock = DockStyle.Fill;
}
public void ShowLoading()
{
_statsView.ShowLoading();
}
public void ShowError(string message)
{
_statsView.ShowError(message);
}
public void UpdateSnapshot(ClientStatisticsSnapshot snapshot)
{
_lastSnapshot = snapshot;
_statsView.UpdateSnapshot(snapshot);
}
public void ApplyTheme(bool isDarkMode)
{
_statsView.ApplyTheme(isDarkMode);
if (_lastSnapshot != null && !_lastSnapshot.HasError)
{
_statsView.UpdateSnapshot(_lastSnapshot);
}
}
}
}