From f6c8a56db24ac726f82f79043dd0dcf429f3531a Mon Sep 17 00:00:00 2001 From: olterion Date: Thu, 12 Sep 2024 13:06:49 +0200 Subject: [PATCH] [addon] show application Version as ETS (#50) * [addon] show application Version as ETS The ETS shows the version of the application as hex number with a minor version after a point. This behavior is recreated with this change. * [CodeFactor] changes related to CodeFactor hints * Add ETS version as new textbox * Update MainWindow.xaml.cs * Update MainWindow.xaml.cs * add ETS version textbox to application tab * show only numeric numbers in ETS version textbox If there is a version 12(dez) in ETS version field should not show "C". Now it shows nothing, if there is a not numeric ETS version. * change converter to minor version numbers 10...15 In ETS versions from 10 to 15 (0xA...0xF) are displayed as x.10...x.15 For example version 2.13 is 45(dec) = 0x2D --- Kaenx.Creator/Converter/IntToVersion.cs | 53 +++++++++++++++++++ Kaenx.Creator/MainWindow.xaml | 4 ++ Kaenx.Creator/MainWindow.xaml.cs | 2 +- .../Properties/Resources.Designer.cs | 9 ++++ Kaenx.Creator/Properties/Resources.de.resx | 4 ++ Kaenx.Creator/Properties/Resources.resx | 4 ++ 6 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 Kaenx.Creator/Converter/IntToVersion.cs diff --git a/Kaenx.Creator/Converter/IntToVersion.cs b/Kaenx.Creator/Converter/IntToVersion.cs new file mode 100644 index 0000000..f481bf3 --- /dev/null +++ b/Kaenx.Creator/Converter/IntToVersion.cs @@ -0,0 +1,53 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Windows.Data; +using System.Linq; + +namespace Kaenx.Creator.Converter +{ + public class IntToVersion : IValueConverter + { + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + decimal majorVersion = Math.Floor((decimal)((int)value/16)); + int minorVersion = (int)value % 16; + return $"{majorVersion}.{minorVersion}"; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + int majorVersion; + int minorVersion; + + if(value.ToString().Contains('.')) + { + string[] versions = value.ToString().Split('.'); + + if(!int.TryParse(versions[0], out majorVersion)) + majorVersion = 0; + + if(!int.TryParse(versions[1], out minorVersion)) + minorVersion = 0; + + if(minorVersion > 15) + { + minorVersion /= 10; + if(minorVersion > 15) + minorVersion = 15; + } + }else + { + if(!int.TryParse(value.ToString(), out majorVersion)) + majorVersion = 0; + + minorVersion = 0; + } + + majorVersion *= 16; + + return majorVersion + minorVersion; + } + } +} diff --git a/Kaenx.Creator/MainWindow.xaml b/Kaenx.Creator/MainWindow.xaml index 1298634..9a08128 100644 --- a/Kaenx.Creator/MainWindow.xaml +++ b/Kaenx.Creator/MainWindow.xaml @@ -17,6 +17,7 @@ Title="Kaenx-Creator" Height="720" Width="1300"> + @@ -658,6 +659,9 @@ + + + diff --git a/Kaenx.Creator/MainWindow.xaml.cs b/Kaenx.Creator/MainWindow.xaml.cs index 9f4356b..c5ca29f 100644 --- a/Kaenx.Creator/MainWindow.xaml.cs +++ b/Kaenx.Creator/MainWindow.xaml.cs @@ -1044,4 +1044,4 @@ private async void ClickCheckVersion(object sender, RoutedEventArgs e) } } } -} \ No newline at end of file +} diff --git a/Kaenx.Creator/Properties/Resources.Designer.cs b/Kaenx.Creator/Properties/Resources.Designer.cs index 377f3b5..f1d75c7 100644 --- a/Kaenx.Creator/Properties/Resources.Designer.cs +++ b/Kaenx.Creator/Properties/Resources.Designer.cs @@ -410,6 +410,15 @@ public static string prop_vers { return ResourceManager.GetString("prop_vers", resourceCulture); } } + + /// + /// Sucht eine lokalisierte Zeichenfolge, die Veröffentlichen ähnelt. + /// + public static string prop_etsvers { + get { + return ResourceManager.GetString("prop_etsvers", resourceCulture); + } + } /// /// Sucht eine lokalisierte Zeichenfolge, die Veröffentlichen ähnelt. diff --git a/Kaenx.Creator/Properties/Resources.de.resx b/Kaenx.Creator/Properties/Resources.de.resx index 778670e..30b0b8d 100644 --- a/Kaenx.Creator/Properties/Resources.de.resx +++ b/Kaenx.Creator/Properties/Resources.de.resx @@ -273,6 +273,10 @@ Version + + ETS Version + + Busstrom diff --git a/Kaenx.Creator/Properties/Resources.resx b/Kaenx.Creator/Properties/Resources.resx index 0ba55d5..0d861ee 100644 --- a/Kaenx.Creator/Properties/Resources.resx +++ b/Kaenx.Creator/Properties/Resources.resx @@ -273,6 +273,10 @@ Version + + ETS Version + + Bus Current