From adda5b3f742072bb4d1feb3c48c7f14febad7fe2 Mon Sep 17 00:00:00 2001 From: olterion Date: Fri, 6 Sep 2024 09:33:48 +0200 Subject: [PATCH 1/8] [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. --- Kaenx.Creator/Converter/IntToVersion.cs | 38 +++++++++++++++++++++++++ Kaenx.Creator/MainWindow.xaml | 5 ++-- 2 files changed, 41 insertions(+), 2 deletions(-) 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..d3533a8 --- /dev/null +++ b/Kaenx.Creator/Converter/IntToVersion.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using System.Text; +using System.Windows.Data; + +namespace Kaenx.Creator.Converter +{ + public class IntToVersion : IValueConverter + { + + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) + { + string hexString = ((int)value).ToString("X"); + if(hexString.Length > 1) + hexString = hexString.Insert(hexString.Length - 1, "."); + return hexString; + } + + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) + { + string hexString=""; + if(value.ToString().Contains(".")) + { + string[] versions = value.ToString().Split('.'); + hexString = versions[0] + versions[1]; + }else + { + hexString = value.ToString(); + } + + int number; + if(!int.TryParse(hexString, NumberStyles.HexNumber, null, out number)) + return 0; + return number; + } + } +} diff --git a/Kaenx.Creator/MainWindow.xaml b/Kaenx.Creator/MainWindow.xaml index 8a4b1b6..9445d82 100644 --- a/Kaenx.Creator/MainWindow.xaml +++ b/Kaenx.Creator/MainWindow.xaml @@ -17,6 +17,7 @@ Title="Kaenx-Creator" Height="720" Width="1300"> + @@ -649,7 +650,7 @@ - + @@ -875,7 +876,7 @@ - + From 2144f5e24370242eb4279f3e68e0158448f9811b Mon Sep 17 00:00:00 2001 From: olterion Date: Fri, 6 Sep 2024 09:55:39 +0200 Subject: [PATCH 2/8] [CodeFactor] changes related to CodeFactor hints --- Kaenx.Creator/Converter/IntToVersion.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Kaenx.Creator/Converter/IntToVersion.cs b/Kaenx.Creator/Converter/IntToVersion.cs index d3533a8..b4aa4ca 100644 --- a/Kaenx.Creator/Converter/IntToVersion.cs +++ b/Kaenx.Creator/Converter/IntToVersion.cs @@ -8,7 +8,6 @@ namespace Kaenx.Creator.Converter { public class IntToVersion : IValueConverter { - public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string hexString = ((int)value).ToString("X"); @@ -20,7 +19,7 @@ public object Convert(object value, Type targetType, object parameter, CultureIn public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { string hexString=""; - if(value.ToString().Contains(".")) + if(value.ToString().Contains('.')) { string[] versions = value.ToString().Split('.'); hexString = versions[0] + versions[1]; From 50d3acee5f43b19980e890f16c1682b06f3eecb9 Mon Sep 17 00:00:00 2001 From: olterion Date: Fri, 6 Sep 2024 19:19:08 +0200 Subject: [PATCH 3/8] Add ETS version as new textbox --- Kaenx.Creator/MainWindow.xaml.cs | 4 ++++ Kaenx.Creator/Properties/Resources.Designer.cs | 9 +++++++++ Kaenx.Creator/Properties/Resources.de.resx | 4 ++++ Kaenx.Creator/Properties/Resources.resx | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/Kaenx.Creator/MainWindow.xaml.cs b/Kaenx.Creator/MainWindow.xaml.cs index d6e73e8..0c5fae1 100644 --- a/Kaenx.Creator/MainWindow.xaml.cs +++ b/Kaenx.Creator/MainWindow.xaml.cs @@ -105,7 +105,11 @@ private async void AutoCheckUpdate() public void GoToItem(object item, object module) { +<<<<<<< Updated upstream if(module != null) +======= + if(module != null && module.GetType() == typeof(Kaenx.Creator.Models.Module)) +>>>>>>> Stashed changes { VersionTabs.SelectedIndex = 7; int index2 = item switch { 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 From ee1878547bebdb501687dcaa316de312edee695c Mon Sep 17 00:00:00 2001 From: olterion Date: Fri, 6 Sep 2024 19:49:19 +0200 Subject: [PATCH 4/8] Update MainWindow.xaml.cs --- Kaenx.Creator/MainWindow.xaml.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/Kaenx.Creator/MainWindow.xaml.cs b/Kaenx.Creator/MainWindow.xaml.cs index 0c5fae1..67015de 100644 --- a/Kaenx.Creator/MainWindow.xaml.cs +++ b/Kaenx.Creator/MainWindow.xaml.cs @@ -105,11 +105,7 @@ private async void AutoCheckUpdate() public void GoToItem(object item, object module) { -<<<<<<< Updated upstream if(module != null) -======= - if(module != null && module.GetType() == typeof(Kaenx.Creator.Models.Module)) ->>>>>>> Stashed changes { VersionTabs.SelectedIndex = 7; int index2 = item switch { @@ -1103,4 +1099,4 @@ private async void ClickCheckVersion(object sender, RoutedEventArgs e) } } } -} \ No newline at end of file +} From d4a15299f9bad7ffc1c2124d2a19ca29f138daa6 Mon Sep 17 00:00:00 2001 From: olterion Date: Fri, 6 Sep 2024 19:50:33 +0200 Subject: [PATCH 5/8] Update MainWindow.xaml.cs From d4d40aaddf7821d2eb2637050e782b535a438df2 Mon Sep 17 00:00:00 2001 From: olterion Date: Fri, 6 Sep 2024 19:57:41 +0200 Subject: [PATCH 6/8] add ETS version textbox to application tab --- Kaenx.Creator/MainWindow.xaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Kaenx.Creator/MainWindow.xaml b/Kaenx.Creator/MainWindow.xaml index 9445d82..f01c51c 100644 --- a/Kaenx.Creator/MainWindow.xaml +++ b/Kaenx.Creator/MainWindow.xaml @@ -650,6 +650,9 @@ + + + @@ -876,7 +879,7 @@ - + From 986ad4a8a4fa708457b99ce37e55d1c5cf32e694 Mon Sep 17 00:00:00 2001 From: olterion Date: Tue, 10 Sep 2024 15:33:12 +0200 Subject: [PATCH 7/8] 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. --- Kaenx.Creator/Converter/IntToVersion.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Kaenx.Creator/Converter/IntToVersion.cs b/Kaenx.Creator/Converter/IntToVersion.cs index b4aa4ca..120eec3 100644 --- a/Kaenx.Creator/Converter/IntToVersion.cs +++ b/Kaenx.Creator/Converter/IntToVersion.cs @@ -3,6 +3,7 @@ using System.Globalization; using System.Text; using System.Windows.Data; +using System.Linq; namespace Kaenx.Creator.Converter { @@ -11,8 +12,12 @@ public class IntToVersion : IValueConverter public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { string hexString = ((int)value).ToString("X"); - if(hexString.Length > 1) - hexString = hexString.Insert(hexString.Length - 1, "."); + if(hexString.All(char.IsDigit)){ + if(hexString.Length > 1) + hexString = hexString.Insert(hexString.Length - 1, "."); + }else{ + hexString = ""; + } return hexString; } From a6af5c6611daf2616e1beb53d5bdcac4536d3786 Mon Sep 17 00:00:00 2001 From: olterion Date: Tue, 10 Sep 2024 21:59:53 +0200 Subject: [PATCH 8/8] 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 | 43 ++++++++++++++++--------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/Kaenx.Creator/Converter/IntToVersion.cs b/Kaenx.Creator/Converter/IntToVersion.cs index 120eec3..f481bf3 100644 --- a/Kaenx.Creator/Converter/IntToVersion.cs +++ b/Kaenx.Creator/Converter/IntToVersion.cs @@ -10,33 +10,44 @@ namespace Kaenx.Creator.Converter public class IntToVersion : IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) - { - string hexString = ((int)value).ToString("X"); - if(hexString.All(char.IsDigit)){ - if(hexString.Length > 1) - hexString = hexString.Insert(hexString.Length - 1, "."); - }else{ - hexString = ""; - } - return hexString; + { + 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) { - string hexString=""; + int majorVersion; + int minorVersion; + if(value.ToString().Contains('.')) { string[] versions = value.ToString().Split('.'); - hexString = versions[0] + versions[1]; + + 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 { - hexString = value.ToString(); + if(!int.TryParse(value.ToString(), out majorVersion)) + majorVersion = 0; + + minorVersion = 0; } - int number; - if(!int.TryParse(hexString, NumberStyles.HexNumber, null, out number)) - return 0; - return number; + majorVersion *= 16; + + return majorVersion + minorVersion; } } }