41 lines
969 B
C#
41 lines
969 B
C#
using FieldLogger.ViewModels;
|
|
|
|
namespace FieldLogger.Views.Controls;
|
|
|
|
public partial class AppStatusBar : ContentView
|
|
{
|
|
private IDispatcherTimer? _staleTimer;
|
|
|
|
public AppStatusBar()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
protected override void OnHandlerChanged()
|
|
{
|
|
base.OnHandlerChanged();
|
|
|
|
if (Handler is null)
|
|
{
|
|
_staleTimer?.Stop();
|
|
_staleTimer = null;
|
|
return;
|
|
}
|
|
|
|
if (_staleTimer is not null)
|
|
return;
|
|
|
|
_staleTimer = Dispatcher.CreateTimer();
|
|
_staleTimer.Interval = TimeSpan.FromSeconds(1);
|
|
_staleTimer.Tick += (_, _) => (BindingContext as AppStatusViewModel)?.Refresh();
|
|
_staleTimer.Start();
|
|
(BindingContext as AppStatusViewModel)?.Refresh();
|
|
}
|
|
|
|
protected override void OnBindingContextChanged()
|
|
{
|
|
base.OnBindingContextChanged();
|
|
(BindingContext as AppStatusViewModel)?.Refresh();
|
|
}
|
|
}
|