Merge branch 'ValueConverters' into develop

This commit is contained in:
shinichi
2020-10-16 10:41:52 +02:00
9 changed files with 96 additions and 45 deletions

View File

@@ -8,25 +8,33 @@
</PropertyGroup>
<ItemGroup>
<None Remove="Images\CoolBackground.jpg" />
<None Remove="Images\Logo\icon1.ico" />
<None Remove="Images\re15.jpg" />
<None Remove="Images\stone.png" />
<None Remove="Images\CoolBackground.jpg" />
<None Remove="Images\Icons\CheckMark.png" />
<None Remove="Images\Icons\CrossMark.png" />
<None Remove="Images\Logo\icon1.ico" />
<None Remove="Images\re15.jpg" />
<None Remove="Images\stone.png" />
</ItemGroup>
<ItemGroup>
<Content Include="Images\CoolBackground.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\Logo\icon1.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\re15.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\stone.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\CoolBackground.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\Icons\CheckMark.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\Icons\CrossMark.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\Logo\icon1.ico">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\re15.jpg">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Images\stone.png">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
@@ -42,7 +50,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="..\Hashing\Hashing.projitems" Label="Shared" />

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;
using System.Windows.Media.Imaging;
namespace ClientApp.ValueConverters
{
//[ValueConversion(typeof(bool), typeof(BitmapImage))]
class BoolToMarkConverter : IValueConverter
{
public BitmapImage TrueImage { get; set; } = new BitmapImage(new Uri("pack://application:,,,/Images/Icons/CheckMark.png"));
public BitmapImage FalseImage { get; set; } = new BitmapImage(new Uri("pack://application:,,,/Images/Icons/CrossMark.png"));
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (!(value is bool))
{
return null;
}
bool b = (bool)value;
if (b)
{
return this.TrueImage;
}
else
{
return this.FalseImage;
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@@ -20,14 +20,14 @@ namespace ClientApp.ViewModels
public bool InvertedLoginStatus { get; set; }
private MainWindowViewModel mainWindowViewModel;
private MainWindowViewModel MainWindowViewModel;
public LoginViewModel(MainWindowViewModel mainWindowViewModel)
{
this.mainWindowViewModel = mainWindowViewModel;
this.MainWindowViewModel = mainWindowViewModel;
LoginCommand = new RelayCommand<object>((parameter) =>
{
//TODO send username and password to server
this.mainWindowViewModel.client.tryLogin(Username, ((PasswordBox)parameter).Password);
this.MainWindowViewModel.client.tryLogin(Username, ((PasswordBox)parameter).Password);
});
}
@@ -35,11 +35,11 @@ namespace ClientApp.ViewModels
internal void setLoginStatus(bool status)
{
this.mainWindowViewModel.InfoModel.ConnectedToServer = status;
this.MainWindowViewModel.InfoModel.ConnectedToServer = status;
this.InvertedLoginStatus = !status;
if (status)
{
this.mainWindowViewModel.SelectedViewModel = new MainViewModel(mainWindowViewModel);
this.MainWindowViewModel.SelectedViewModel = new MainViewModel(MainWindowViewModel);
}
}
}

View File

@@ -89,7 +89,7 @@ namespace ClientApp.ViewModels
public int TitleHeight { get; set; } = 42;
public GridLength TitleHeightGridLegth { get { return new GridLength(TitleHeight + ResizeBorder); } }
public GridLength TitleHeightGridLength { get { return new GridLength(TitleHeight + ResizeBorder); } }
#endregion

View File

@@ -4,9 +4,13 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:ClientApp.Views"
xmlns:converter="clr-namespace:ClientApp.ValueConverters"
ShowsNavigationUI="False"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Page.Resources>
<converter:BoolToMarkConverter x:Key="BoolToMarkConverter"/>
</Page.Resources>
<DockPanel>
<Grid>
<Grid.ColumnDefinitions>
@@ -15,32 +19,21 @@
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal" Margin="10">
<Label Content="Connected to server:"/>
<Label Content="true"/>
<StackPanel Grid.Column="0" Grid.Row="0" Orientation="Horizontal" Margin="20" HorizontalAlignment="Center">
<Label Content="Connected to server:" VerticalAlignment="Center"/>
<Image Source="{Binding Converter={StaticResource BoolToMarkConverter},Path=MainWindowViewModel.InfoModel.ConnectedToServer}" Stretch="Uniform" Width="20" Height="20"/>
</StackPanel>
<StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal" Margin="10">
<Label Content="Connected to VR-Engine:"/>
<Label Content="{Binding Path=MainWindowViewModel.InfoModel.ConnectedToVREngine}"/>
<StackPanel Grid.Column="1" Grid.Row="0" Orientation="Horizontal" Margin="20" HorizontalAlignment="Center">
<Label Content="Connected to VR-Engine:" VerticalAlignment="Center"/>
<Image Source="{Binding Converter={StaticResource BoolToMarkConverter},Path=MainWindowViewModel.InfoModel.ConnectedToVREngine}" Stretch="Uniform" Width="20" Height="20"/>
</StackPanel>
<StackPanel Grid.Column="2" Grid.Row="0" Orientation="Horizontal" Margin="10">
<Label Content="Doctor connected:"/>
<Label Content="{Binding Path=MainWindowViewModel.InfoModel.DoctorConnected}"/>
<StackPanel Grid.Column="2" Grid.Row="0" Orientation="Horizontal" Margin="20" HorizontalAlignment="Center">
<Label Content="Doctor connected:" VerticalAlignment="Center"/>
<Image Source="{Binding Converter={StaticResource BoolToMarkConverter},Path=MainWindowViewModel.InfoModel.DoctorConnected}" Stretch="Uniform" Width="20" Height="20"/>
</StackPanel>
<Button Grid.Column="0" Grid.Row="1" Command="{Binding RetryServerCommand}" Width="50" Height="20">
<Button.Content>
<TextBlock TextWrapping="Wrap" Text="retry"/>
</Button.Content>
</Button>
</Grid>
</DockPanel>

View File

@@ -2,6 +2,7 @@
using ProftaakRH;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
@@ -92,8 +93,17 @@ namespace Hardware.Simulators
//Generate an ANT message for page 0x10
private byte[] GenerateBike0x10()
{
byte[] bikeByte = { 0x10, Convert.ToByte(equipmentType), Convert.ToByte(elapsedTime * 4 % 64), Convert.ToByte(distanceTraveled), speedArray[0], speedArray[1], Convert.ToByte(BPM), 0xFF };
return bikeByte;
//SOMEONE FIX THIS!!!!!!!!!
try
{
byte[] bikeByte = { 0x10, Convert.ToByte(equipmentType), Convert.ToByte(elapsedTime * 4 % 64), Convert.ToByte(distanceTraveled), speedArray[0], speedArray[1], Convert.ToByte(BPM), 0xFF };
return bikeByte;
}
catch (OverflowException e)
{
Debug.WriteLine(e);
return GenerateBike0x10();
}
}
//Generate an ANT message for BPM

View File

@@ -74,6 +74,7 @@ namespace RH_Engine
public static string GetID(string json)
{
//TODO fix null
dynamic d = JsonConvert.DeserializeObject(json);
return d.id;
}