Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
sleevezipper committed Mar 15, 2021
2 parents a52f90a + 63744bc commit 80653ec
Show file tree
Hide file tree
Showing 14 changed files with 60 additions and 60 deletions.
22 changes: 22 additions & 0 deletions UserInterface/ViewModels/InfoViewModel.cs
Original file line number Diff line number Diff line change
@@ -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;
}

}
}
2 changes: 1 addition & 1 deletion UserInterface/Views/AddCommandDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async void Save(object sender, RoutedEventArgs args)
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. ";
Expand Down
2 changes: 1 addition & 1 deletion UserInterface/Views/AddSensorDialog.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public async void Save(object sender, RoutedEventArgs args)
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 ";
Expand Down
1 change: 1 addition & 0 deletions UserInterface/Views/AppInfo.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
48 changes: 14 additions & 34 deletions UserInterface/Views/AppInfo.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,44 +23,33 @@ public AppInfo()
this.InitializeComponent();
// register IPC clients
ServiceProvider serviceProvider = new ServiceCollection()
.AddNamedPipeIpcClient<ServiceContractInterfaces>("broker", pipeName: "pipeinternal")
.AddNamedPipeIpcClient<ServiceContractInterfaces>("info", pipeName: "pipeinternal")
.BuildServiceProvider();

// resolve IPC client factory
IIpcClientFactory<ServiceContractInterfaces> clientFactory = serviceProvider
.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);
}
}

Expand All @@ -74,15 +63,6 @@ public void Discord(object sender, RoutedEventArgs args)
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);
Expand Down
14 changes: 3 additions & 11 deletions UserInterface/Views/MainWindow.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Original file line number Diff line number Diff line change
Expand Up @@ -225,5 +225,10 @@ public void AddCommand(AvailableCommands commandType, string json)
this._configurationService.AddConfiguredCommand(commandToCreate);
}
}

public string GetCurrentVersion()
{
return Program.GetVersion();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public interface ServiceContractInterfaces
void RemoveCommandById(Guid id);
List<ConfiguredCommandModel> GetConfiguredCommands();
void AddCommand(AvailableCommands commandType, string json);
string GetCurrentVersion();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public MqttPublisher(
// configure what happens on disconnect
this._mqttClient.UseDisconnectedHandler(e =>
{
this._mqttClientMessage = e.Reason.ToString();
this._mqttClientMessage = e.ReasonCode.ToString();

});
}
Expand Down
1 change: 0 additions & 1 deletion hass-workstation-service/Data/ConfigurationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ public async Task<IManagedMqttClientOptions> GetMqttClientOptionsAsync()
.WithTls(new MqttClientOptionsBuilderTlsParameters()
{
UseTls = configuredBroker.UseTLS,
SslProtocol = System.Security.Authentication.SslProtocols.Tls12,
AllowUntrustedCertificates = true
})
.WithCredentials(configuredBroker.Username, configuredBroker.Password.ToString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Binary file modified hass-workstation-service/UserInterface.exe
Binary file not shown.
20 changes: 10 additions & 10 deletions hass-workstation-service/hass-workstation-service.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand All @@ -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>

Expand All @@ -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" />
Expand All @@ -67,8 +71,4 @@
<HintPath>..\lib\CoreAudio.dll</HintPath>
</Reference>
</ItemGroup>

<ItemGroup>
<Resource Include="libHarfBuzzSharp.dll" />
</ItemGroup>
</Project>
Binary file modified hass-workstation-service/hass-workstation-service.exe
Binary file not shown.

0 comments on commit 80653ec

Please sign in to comment.