Merge branch 'develop'

pull/56/head 1.0.0.40823
Sleevezipper 4 years ago
commit 80653ec31c

@ -0,0 +1,22 @@
using hass_workstation_service.Communication.InterProcesCommunication.Models;
using ReactiveUI;
using System;
using System.Collections.Generic;
using System.Text;
namespace UserInterface.ViewModels
{
public class InfoViewModel : ViewModelBase
{
private string serviceVersion;
public string ServiceVersion { get => "Service version: " + serviceVersion; private set => this.RaiseAndSetIfChanged(ref serviceVersion, value); }
public void UpdateServiceVersion(string version)
{
this.ServiceVersion = version;
}
}
}

@ -53,7 +53,7 @@ namespace UserInterface.Views
public void ComboBoxClosed(object sender, SelectionChangedEventArgs args)
{
var item = ((AddCommandViewModel)this.DataContext);
switch (item.SelectedType)
switch (this.comboBox.SelectedItem)
{
case AvailableCommands.CustomCommand:
item.Description = "This command lets you execute any command you want. It will run in a Windows Command Prompt silently. ";

@ -53,7 +53,7 @@ namespace UserInterface.Views
public void ComboBoxClosed(object sender, SelectionChangedEventArgs args)
{
var item = ((AddSensorViewModel)this.DataContext);
switch (item.SelectedType)
switch (this.comboBox.SelectedItem)
{
case AvailableSensors.UserNotificationStateSensor:
item.Description = "This sensor watches the UserNotificationState. This is normally used in applications to determine if it is appropriate to send a notification but we can use it to expose this state. \n ";

@ -7,6 +7,7 @@
<StackPanel Margin="30">
<StackPanel Margin="0 0 0 20" HorizontalAlignment="Left">
<ContentControl FontSize="18" FontWeight="Bold" >Info</ContentControl>
<TextBlock Text="{Binding ServiceVersion}" Margin="0 0 0 20"></TextBlock >
<TextBlock Text="Need some help?" Margin="0 0 0 20"></TextBlock >
<StackPanel Margin="0 0 0 20" HorizontalAlignment="Left" Orientation="Horizontal">
<Button Width="75" HorizontalAlignment="Right" Margin="10 10" Click="GitHub">GitHub</Button>

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

@ -12,23 +12,15 @@
<Design.DataContext>
<vm:MainWindowViewModel/>
</Design.DataContext>
<Grid ColumnDefinitions="Auto,1*,Auto" RowDefinitions="Auto,Auto,Auto" Margin="30">
<ScrollViewer Height="700" VerticalScrollBarVisibility="Visible">
<Grid ColumnDefinitions="Auto,1*,Auto" RowDefinitions="Auto,Auto,Auto" Margin="30" VerticalAlignment="Stretch">
<views:BrokerSettings Grid.Column="0" Grid.Row="0" Margin="10 0" Grid.RowSpan="2" Background="#2D2D30"/>
<views:SensorSettings Grid.Column="1" Grid.Row="0" Margin="10 0" Background="#2D2D30"/>
<views:CommandSettings Grid.Column="1" Grid.Row="1" Margin="0 10 0 0" Background="#2D2D30"/>
<views:BackgroundServiceSettings Grid.Column="2" Grid.Row="0" Margin="10 0" Background="#2D2D30"/>
<views:AppInfo Grid.Column="2" Grid.Row="1" Margin="10 10 10 0" Background="#2D2D30"/>
<!--<views:BrokerSettings Grid.Column="1" Grid.Row="0"/>
<views:BrokerSettings Grid.Column="2" Grid.Row="0"/>-->
<!--<TextBlock Text="Col0Row0:" Grid.Row="0" Grid.Column="0"/>
<TextBlock Text="Col0Row1:" Grid.Row="1" Grid.Column="0"/>
<TextBlock Text="Col0Row2:" Grid.Row="2" Grid.Column="0"/>
<CheckBox Content="Col2Row0" Grid.Row="0" Grid.Column="2"/>
<Button Content="SpansCol1-2Row1-2" Grid.Row="1" Grid.Column="1" Grid.RowSpan="2" Grid.ColumnSpan="2"/>-->
</Grid>
<!--<TextBlock Text="{Binding Greeting}" HorizontalAlignment="Center" VerticalAlignment="Center"/>-->
</ScrollViewer>
</Window>

@ -225,5 +225,10 @@ namespace hass_workstation_service.Communication.InterProcesCommunication
this._configurationService.AddConfiguredCommand(commandToCreate);
}
}
public string GetCurrentVersion()
{
return Program.GetVersion();
}
}
}

@ -20,5 +20,6 @@ namespace hass_workstation_service.Communication.NamedPipe
void RemoveCommandById(Guid id);
List<ConfiguredCommandModel> GetConfiguredCommands();
void AddCommand(AvailableCommands commandType, string json);
string GetCurrentVersion();
}
}

@ -80,7 +80,7 @@ namespace hass_workstation_service.Communication
// configure what happens on disconnect
this._mqttClient.UseDisconnectedHandler(e =>
{
this._mqttClientMessage = e.Reason.ToString();
this._mqttClientMessage = e.ReasonCode.ToString();
});
}

@ -226,7 +226,6 @@ namespace hass_workstation_service.Data
.WithTls(new MqttClientOptionsBuilderTlsParameters()
{
UseTls = configuredBroker.UseTLS,
SslProtocol = System.Security.Authentication.SslProtocols.Tls12,
AllowUntrustedCertificates = true
})
.WithCredentials(configuredBroker.Username, configuredBroker.Password.ToString())

@ -4,7 +4,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ApplicationRevision>39</ApplicationRevision>
<ApplicationRevision>40</ApplicationRevision>
<ApplicationVersion>1.0.0.*</ApplicationVersion>
<BootstrapperEnabled>True</BootstrapperEnabled>
<Configuration>Release</Configuration>

@ -24,6 +24,7 @@
</ItemGroup>
<ItemGroup>
<None Remove="hass-workstation-service.exe" />
<None Remove="hass-workstation-service.pdb" />
<None Remove="libHarfBuzzSharp.dll" />
<None Remove="libSkiaSharp.dll" />
@ -32,14 +33,17 @@
</ItemGroup>
<ItemGroup>
<Content Include="libSkiaSharp.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<Content Include="hass-workstation-service.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="libHarfBuzzSharp.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="libSkiaSharp.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="UserInterface.exe">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
@ -54,8 +58,8 @@
<PackageReference Include="LibreHardwareMonitorLib" Version="0.8.7" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="5.0.0" />
<PackageReference Include="Microsoft.Win32.Registry" Version="5.0.0" />
<PackageReference Include="MQTTnet" Version="3.0.15" />
<PackageReference Include="MQTTnet.Extensions.ManagedClient" Version="3.0.15" />
<PackageReference Include="MQTTnet" Version="3.0.13" />
<PackageReference Include="MQTTnet.Extensions.ManagedClient" Version="3.0.13" />
<PackageReference Include="Serilog.Extensions.Logging.File" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
@ -67,8 +71,4 @@
<HintPath>..\lib\CoreAudio.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Resource Include="libHarfBuzzSharp.dll" />
</ItemGroup>
</Project>

Loading…
Cancel
Save