Skip to content
This repository was archived by the owner on Dec 3, 2024. It is now read-only.

Commit c323e22

Browse files
committed
Finished diagnostics window with translations
1 parent 17fb06a commit c323e22

11 files changed

+161
-42
lines changed

XOutput/App.xaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@
2424
<Converters:ColorConverter x:Key="ColorConverter"/>
2525
<Converters:BlinkConverter x:Key="BlinkConverter"/>
2626
<Converters:DecimalToStringConverter x:Key="DecimalToStringConverter"/>
27+
<Converters:EqualsToVisibilityConverter x:Key="EqualsToVisibilityConverter"/>
2728
</Application.Resources>
2829
</Application>

XOutput/Devices/Input/InputDiagnostics.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public IEnumerable<DiagnosticsResult> GetResults()
2626
GetButtonsResult(),
2727
GetDPadResult(),
2828
GetForceFeedbackResult(),
29+
GetSlidersResult(),
2930
};
3031
}
3132

@@ -48,6 +49,17 @@ public DiagnosticsResult GetAxesResult()
4849
return result;
4950
}
5051

52+
public DiagnosticsResult GetSlidersResult()
53+
{
54+
int slidersCount = device.Sliders.Count();
55+
return new DiagnosticsResult
56+
{
57+
Value = slidersCount,
58+
Type = InputDiagnosticsTypes.SlidersCount,
59+
State = DiagnosticsResultState.Passed,
60+
};
61+
}
62+
5163
public DiagnosticsResult GetButtonsResult()
5264
{
5365
int buttonsCount = device.Buttons.Count();

XOutput/Devices/Input/InputDiagnosticsTypes.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ namespace XOutput.Devices.Input
88
{
99
public enum InputDiagnosticsTypes
1010
{
11-
1211
AxesCount,
1312
ButtonsCount,
1413
DPadCount,
14+
SlidersCount,
1515
ForceFeedbackCount,
1616
}
1717
}

XOutput/Resources/languages.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,19 @@ WaitingForInputFor=Waiting for input for
4040
Keyboard=Keyboard
4141
Warning=Warning
4242
Error=Error
43+
True=true
44+
False=false
4345
Test=Test
46+
System=System
47+
DiagnosticsMenu=Diagnostics
48+
InputDiagnosticsTypes.AxesCount=Axes count
49+
InputDiagnosticsTypes.ButtonsCount=Buttons count
50+
InputDiagnosticsTypes.DPadCount=DPad count
51+
InputDiagnosticsTypes.SlidersCount=Sliders count
52+
InputDiagnosticsTypes.ForceFeedbackCount=Force feedback motors count
53+
XInputDiagnosticsTypes.XDevice=Virtualization software is installed
54+
XInputDiagnosticsTypes.ScpDevice=SCPToolkit is installed
55+
XInputDiagnosticsTypes.VigemDevice=ViGEm is installed
4456
VersionCheckError=There was an error while checking for updates.
4557
VersionCheckNewRelease=This is a development release.
4658
VersionCheckUpToDate=The software is up to date.
@@ -269,6 +281,18 @@ Keyboard=Billentyűzet
269281
Warning=Figyelmeztetés
270282
Error=Hiba
271283
Test=Teszt
284+
True=igaz
285+
False=hamis
286+
System=Rendszer
287+
DiagnosticsMenu=Diagnosztika
288+
InputDiagnosticsTypes.AxesCount=Tengelyek száma
289+
InputDiagnosticsTypes.ButtonsCount=Gombok száma
290+
InputDiagnosticsTypes.DPadCount=DPadok száma
291+
InputDiagnosticsTypes.SlidersCount=Csúszkák száma
292+
InputDiagnosticsTypes.ForceFeedbackCount=Rezgő motorok száma
293+
XInputDiagnosticsTypes.XDevice=Virtualizációs szoftver telepítve
294+
XInputDiagnosticsTypes.ScpDevice=SCPToolkit telepítve
295+
XInputDiagnosticsTypes.VigemDevice=ViGEm telepítve
272296
VersionCheckError=Hiba történt a frissítés keresése közben.
273297
VersionCheckNewRelease=Ez egy fejlesztői verzió.
274298
VersionCheckUpToDate=Az alkalmazás legfrissebb verzióját használja.

XOutput/UI/Component/DiagnosticsItemView.xaml

Lines changed: 55 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,39 +4,68 @@
44
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
55
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
66
xmlns:local="clr-namespace:XOutput.UI.Component"
7+
xmlns:diagnostics="clr-namespace:XOutput.Diagnostics"
78
mc:Ignorable="d"
89
d:DataContext="{d:DesignInstance Type=local:DiagnosticsItemViewModel, IsDesignTimeCreatable=False}"
910
d:DesignHeight="30" d:DesignWidth="490">
1011
<UserControl.Resources>
1112
<DataTemplate x:Key="ResultTemplate">
12-
<Grid>
13-
<Grid.ColumnDefinitions>
14-
<ColumnDefinition Width="4*" />
15-
<ColumnDefinition Width="*" />
16-
<ColumnDefinition Width="2*" />
17-
</Grid.ColumnDefinitions>
18-
<Label Grid.Column="0">
19-
<Label.Content>
20-
<MultiBinding Converter="{StaticResource DynamicLanguageConverter}">
21-
<Binding Path="Model.Path" RelativeSource="{RelativeSource AncestorType={x:Type local:DiagnosticsItemView}}" />
22-
<Binding Path="Type" />
23-
</MultiBinding>
24-
</Label.Content>
25-
</Label>
26-
<Label Grid.Column="1" Content="{Binding Value}"/>
27-
<Label Grid.Column="2">
28-
<Label.Content>
29-
<MultiBinding Converter="{StaticResource DynamicLanguageConverter}">
30-
<Binding Path="Model.Path" RelativeSource="{RelativeSource AncestorType={x:Type local:DiagnosticsItemView}}" />
31-
<Binding Path="State" />
32-
</MultiBinding>
33-
</Label.Content>
34-
</Label>
35-
</Grid>
13+
<Border BorderThickness="0 0 0 1" BorderBrush="LightGray">
14+
<Grid Height="30">
15+
<Grid.ColumnDefinitions>
16+
<ColumnDefinition Width="4*" />
17+
<ColumnDefinition Width="*" />
18+
<ColumnDefinition Width="40" />
19+
</Grid.ColumnDefinitions>
20+
<Label Grid.Column="0">
21+
<Label.Content>
22+
<MultiBinding Converter="{StaticResource DynamicLanguageConverter}">
23+
<Binding Path="DataContext.LanguageModel.Data" RelativeSource="{RelativeSource AncestorType={x:Type local:DiagnosticsItemView}}" />
24+
<Binding Path="Type" />
25+
</MultiBinding>
26+
</Label.Content>
27+
</Label>
28+
<Label Grid.Column="1">
29+
<Label.Content>
30+
<MultiBinding Converter="{StaticResource DynamicLanguageConverter}">
31+
<Binding Path="DataContext.LanguageModel.Data" RelativeSource="{RelativeSource AncestorType={x:Type local:DiagnosticsItemView}}" />
32+
<Binding Path="Value" />
33+
</MultiBinding>
34+
</Label.Content>
35+
</Label>
36+
<Label Grid.Column="2" Visibility="{Binding State, Converter={StaticResource EqualsToVisibilityConverter}, ConverterParameter={x:Static diagnostics:DiagnosticsResultState.Passed}}">
37+
<Canvas>
38+
<Ellipse Fill="Green" Width="20" Height="20"/>
39+
<Polygon Fill="White" Points="4,11 5,10 8,13 15,4 16,5 9,16 7,16"/>
40+
</Canvas>
41+
</Label>
42+
<Label Grid.Column="2" Visibility="{Binding State, Converter={StaticResource EqualsToVisibilityConverter}, ConverterParameter={x:Static diagnostics:DiagnosticsResultState.Warning}}">
43+
<Canvas>
44+
<Polygon Fill="Yellow" Points="0,20 10,0 20,20" Stroke="Orange"/>
45+
<Polygon Fill="Orange" Points="8,6 12,6 11,13 9,13"/>
46+
<Ellipse Fill="Orange" Width="4" Height="4">
47+
<Ellipse.RenderTransform>
48+
<TranslateTransform X="8" Y="15"/>
49+
</Ellipse.RenderTransform>
50+
</Ellipse>
51+
</Canvas>
52+
</Label>
53+
<Label Grid.Column="2" Visibility="{Binding State, Converter={StaticResource EqualsToVisibilityConverter}, ConverterParameter={x:Static diagnostics:DiagnosticsResultState.Failed}}">
54+
<Canvas>
55+
<Ellipse Fill="Red" Width="20" Height="20"/>
56+
<Rectangle Fill="White" Width="20" Height="20">
57+
<Rectangle.RenderTransform>
58+
<ScaleTransform CenterX="10" CenterY="10" ScaleX="0.5" ScaleY="0.2"/>
59+
</Rectangle.RenderTransform>
60+
</Rectangle>
61+
</Canvas>
62+
</Label>
63+
</Grid>
64+
</Border>
3665
</DataTemplate>
3766
</UserControl.Resources>
38-
<StackPanel>
39-
<Label Content="{Binding Model.Source}"/>
67+
<StackPanel Margin="0 0 0 15">
68+
<Label Content="{Binding Model.Source}" FontSize="16"/>
4069
<ItemsControl ItemTemplate="{StaticResource ResultTemplate}" ItemsSource="{Binding Model.Results}" />
4170
</StackPanel>
4271
</UserControl>

XOutput/UI/Component/DiagnosticsItemViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public DiagnosticsItemViewModel(DiagnosticsItemModel model, IDiagnostics diagnos
2323
protected string SourceToString(object source)
2424
{
2525
if (source == null)
26-
return "System";
26+
return LanguageModel.Instance.Translate("System");
2727
if (source is IInputDevice)
2828
return (source as IInputDevice).DisplayName;
2929
return null;

XOutput/UI/Converters/DynamicLanguageConverter.cs

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,33 @@ public object Convert(object[] values, Type targetType, object parameter, Cultur
3333
key = values[1].GetType().Name + "." + values[1].ToString();
3434
return getTranslation(translations, key) ?? values[1].ToString();
3535
}
36-
key = values[1] as string;
36+
else if (values[1] is string)
37+
key = values[1] as string;
38+
else if (values[1] is bool)
39+
key = (bool)values[1] ? "True" : "False";
40+
else if (values[1] is sbyte || values[1] is byte || values[1] is char || values[1] is short || values[1] is ushort || values[1] is int || values[1] is uint || values[1] is long || values[1] is ulong || values[1] is decimal)
41+
return values[1].ToString();
42+
else
43+
throw new ArgumentException(values[1] + " cannot be translated");
3744
return getTranslation(translations, key) ?? key;
3845
}
3946

40-
/// <summary>
41-
/// Intentionally not implemented.
42-
/// </summary>
43-
/// <param name="value">Ignored</param>
44-
/// <param name="targetTypes">Ignored</param>
45-
/// <param name="parameter">Ignored</param>
46-
/// <param name="culture">Ignored</param>
47-
/// <returns></returns>
48-
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
47+
/// <summary>
48+
/// Intentionally not implemented.
49+
/// </summary>
50+
/// <param name="value">Ignored</param>
51+
/// <param name="targetTypes">Ignored</param>
52+
/// <param name="parameter">Ignored</param>
53+
/// <param name="culture">Ignored</param>
54+
/// <returns></returns>
55+
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
4956
{
5057
throw new NotImplementedException();
5158
}
5259

5360
protected string getTranslation(Dictionary<string, string> translations, string key)
5461
{
55-
if(translations == null || key == null || !translations.ContainsKey(key))
62+
if (translations == null || key == null || !translations.ContainsKey(key))
5663
{
5764
return null;
5865
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Globalization;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using System.Windows;
8+
using System.Windows.Data;
9+
using System.Windows.Media;
10+
11+
namespace XOutput.UI.Converters
12+
{
13+
/// <summary>
14+
/// Compares enum value and converts to visibility.
15+
/// Cannot be used backwards.
16+
/// </summary>
17+
public class EqualsToVisibilityConverter : IValueConverter
18+
{
19+
/// <summary>
20+
/// Compares enum value and converts to visibility.
21+
/// </summary>
22+
/// <param name="value">Value to convert</param>
23+
/// <param name="targetType">Ignored</param>
24+
/// <param name="parameter">Ignored</param>
25+
/// <param name="culture">Ignored</param>
26+
/// <returns>If the value is not null</returns>
27+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
28+
{
29+
return value.Equals(parameter) ? Visibility.Visible : Visibility.Collapsed;
30+
}
31+
32+
/// <summary>
33+
/// Intentionally not implemented.
34+
/// </summary>
35+
/// <param name="value">Ignored</param>
36+
/// <param name="targetType">Ignored</param>
37+
/// <param name="parameter">Ignored</param>
38+
/// <param name="culture">Ignored</param>
39+
/// <returns></returns>
40+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
41+
{
42+
throw new NotImplementedException();
43+
}
44+
}
45+
}

XOutput/UI/Windows/DiagnosticsWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
Loaded="WindowLoaded"
1010
Closed="WindowClosed"
1111
d:DataContext="{d:DesignInstance Type=local:DiagnosticsViewModel, IsDesignTimeCreatable=False}"
12-
Title="Diagnostics" Height="550" Width="550">
12+
Title="{Binding LanguageModel.Data, Converter={StaticResource LanguageConverter}, ConverterParameter='DiagnosticsMenu'}" Height="750" Width="550">
1313
<ScrollViewer VerticalScrollBarVisibility="Auto">
1414
<ItemsControl Margin="5" ItemsPanel="{StaticResource VerticalStackPanel}" ItemsSource="{Binding Model.Diagnostics}"/>
1515
</ScrollViewer>

XOutput/UI/Windows/MainWindowViewModel.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,9 +242,9 @@ public void OpenSettings()
242242

243243
public void OpenDiagnostics()
244244
{
245-
ICollection<IDiagnostics> elements = Model.Controllers.Select(c => c.ViewModel.Model.Controller.InputDevice)
245+
IList<IDiagnostics> elements = Model.Controllers.Select(c => c.ViewModel.Model.Controller.InputDevice)
246246
.Select(d => new InputDiagnostics(d)).OfType<IDiagnostics>().ToList();
247-
elements.Add(new Devices.XInput.XInputDiagnostics());
247+
elements.Insert(0, new Devices.XInput.XInputDiagnostics());
248248

249249
new DiagnosticsWindow(new DiagnosticsViewModel(new DiagnosticsModel(), elements)).ShowDialog();
250250
}

0 commit comments

Comments
 (0)