|
|
@ -23,7 +23,7 @@ namespace UserInterface.Views
|
|
|
|
this.InitializeComponent();
|
|
|
|
this.InitializeComponent();
|
|
|
|
// register IPC clients
|
|
|
|
// register IPC clients
|
|
|
|
ServiceProvider serviceProvider = new ServiceCollection()
|
|
|
|
ServiceProvider serviceProvider = new ServiceCollection()
|
|
|
|
.AddNamedPipeIpcClient<ServiceContractInterfaces>("broker", pipeName: "pipeinternal")
|
|
|
|
.AddNamedPipeIpcClient<ServiceContractInterfaces>("info", pipeName: "pipeinternal")
|
|
|
|
.BuildServiceProvider();
|
|
|
|
.BuildServiceProvider();
|
|
|
|
|
|
|
|
|
|
|
|
// resolve IPC client factory
|
|
|
|
// resolve IPC client factory
|
|
|
@ -31,36 +31,25 @@ namespace UserInterface.Views
|
|
|
|
.GetRequiredService<IIpcClientFactory<ServiceContractInterfaces>>();
|
|
|
|
.GetRequiredService<IIpcClientFactory<ServiceContractInterfaces>>();
|
|
|
|
|
|
|
|
|
|
|
|
// create client
|
|
|
|
// create client
|
|
|
|
this.client = clientFactory.CreateClient("broker");
|
|
|
|
this.client = clientFactory.CreateClient("info");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DataContext = new BackgroundServiceSettingsViewModel();
|
|
|
|
|
|
|
|
Ping();
|
|
|
|
|
|
|
|
|
|
|
|
DataContext = new InfoViewModel();
|
|
|
|
|
|
|
|
UpdateVersion();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public async void Ping() {
|
|
|
|
public async void UpdateVersion() {
|
|
|
|
while (true)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var result = await this.client.InvokeAsync(x => x.Ping("ping"));
|
|
|
|
var result = await this.client.InvokeAsync(x => x.GetCurrentVersion());
|
|
|
|
if (result == "pong")
|
|
|
|
((InfoViewModel)this.DataContext).UpdateServiceVersion(result);
|
|
|
|
{
|
|
|
|
|
|
|
|
((BackgroundServiceSettingsViewModel)this.DataContext).UpdateStatus(true, "All good");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
((BackgroundServiceSettingsViewModel)this.DataContext).UpdateStatus(false, "Not running");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (System.Exception)
|
|
|
|
catch (System.Exception)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
((BackgroundServiceSettingsViewModel)this.DataContext).UpdateStatus(false, "Not running");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var autostartresult = await this.client.InvokeAsync(x => x.IsAutoStartEnabled());
|
|
|
|
|
|
|
|
((BackgroundServiceSettingsViewModel)this.DataContext).UpdateAutostartStatus(autostartresult);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Task.Delay(1000);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -74,15 +63,6 @@ namespace UserInterface.Views
|
|
|
|
BrowserUtil.OpenBrowser("https://discord.gg/VraYT2N3wd");
|
|
|
|
BrowserUtil.OpenBrowser("https://discord.gg/VraYT2N3wd");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void EnableAutostart(object sender, RoutedEventArgs args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.client.InvokeAsync(x => x.EnableAutostart(true));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public void DisableAutostart(object sender, RoutedEventArgs args)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
this.client.InvokeAsync(x => x.EnableAutostart(false));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void InitializeComponent()
|
|
|
|
private void InitializeComponent()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
AvaloniaXamlLoader.Load(this);
|
|
|
|
AvaloniaXamlLoader.Load(this);
|
|
|
|