- Move all Launcher components to LANCommander.Launcher.UI namespace - Move all SCSS files next to components (when possible) - Refactor styles that control overflow of content into titlebar to MainWindow only - Remove use in launcher UI of SDK.Client
79 lines
No EOL
2.6 KiB
Text
79 lines
No EOL
2.6 KiB
Text
@namespace LANCommander.Launcher.UI
|
|
@implements IDisposable
|
|
@inject KeepAliveService KeepAliveService
|
|
@inject IMessageService MessageService
|
|
@inject LocalizationService LocalizationService
|
|
|
|
@code {
|
|
string ConnectionMessageKey = Guid.NewGuid().ToString();
|
|
|
|
protected override void OnInitialized()
|
|
{
|
|
KeepAliveService.ConnectionSevered += OnConnectionSevered;
|
|
KeepAliveService.ConnectionRetryNext += OnConnectionRetryNext;
|
|
KeepAliveService.ConnectionLostPermanently += OnConnectionLostPermanently;
|
|
KeepAliveService.ConnectionEstablished += OnConnectionEstablished;
|
|
}
|
|
|
|
void OnConnectionSevered(object? sender, EventArgs e)
|
|
{
|
|
var messageConfig = new MessageConfig
|
|
{
|
|
Key = ConnectionMessageKey,
|
|
Type = MessageType.Loading,
|
|
Content = LocalizationService.GetString("LostConnectionRetrying"),
|
|
Duration = 0,
|
|
};
|
|
|
|
MessageService.Open(messageConfig);
|
|
}
|
|
|
|
void OnConnectionRetryNext(object? sender, EventArgs e)
|
|
{
|
|
// show same lost-connection-message by replacing the message by its key
|
|
var retry = KeepAliveService.GetRetryCount();
|
|
var messageConfig = new MessageConfig
|
|
{
|
|
Key = ConnectionMessageKey,
|
|
Type = MessageType.Loading,
|
|
Content = LocalizationService.GetString("LostConnectionRetryingWithCount", retry.current, retry.total),
|
|
Duration = 0,
|
|
};
|
|
|
|
MessageService.Open(messageConfig);
|
|
}
|
|
|
|
void OnConnectionLostPermanently(object? sender, EventArgs e)
|
|
{
|
|
var messageConfig = new MessageConfig
|
|
{
|
|
Key = ConnectionMessageKey,
|
|
Type = MessageType.Error,
|
|
Content = LocalizationService.GetString("ServerUnavailableEnablingOfflineMode"),
|
|
Duration = 2.5,
|
|
};
|
|
|
|
MessageService.Open(messageConfig);
|
|
}
|
|
|
|
void OnConnectionEstablished(object? sender, EventArgs e)
|
|
{
|
|
var messageConfig = new MessageConfig
|
|
{
|
|
Key = ConnectionMessageKey,
|
|
Type = MessageType.Success,
|
|
Content = LocalizationService.GetString("ConnectionEstablished"),
|
|
Duration = 2.5,
|
|
};
|
|
|
|
MessageService.Open(messageConfig);
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
KeepAliveService.ConnectionSevered -= OnConnectionSevered;
|
|
KeepAliveService.ConnectionRetryNext -= OnConnectionRetryNext;
|
|
KeepAliveService.ConnectionLostPermanently -= OnConnectionLostPermanently;
|
|
KeepAliveService.ConnectionEstablished -= OnConnectionEstablished;
|
|
}
|
|
} |