Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
add RTL support for typewriter animation
Greedeksadaac1409b0f
diff --git a/.Source/GTweak/Assets/UserControls/DescriptionBlock.xaml.cs b/.Source/GTweak/Assets/UserControls/DescriptionBlock.xaml.csindex 18246fba..fdd17ccb 100644--- a/.Source/GTweak/Assets/UserControls/DescriptionBlock.xaml.cs+++ b/.Source/GTweak/Assets/UserControls/DescriptionBlock.xaml.cs@@ -1,4 +1,5 @@using System;+using System.Globalization;using System.Threading;using System.Threading.Tasks;using System.Windows;@@ -32,6 +33,8 @@ namespace GTweak.Assets.UserControlsif (Scroller != null && FunctionDescription != null){+ UpdateFlowDirection();+Scroller.BeginAnimation(ScrollViewerBehavior.VerticalOffsetProperty, null);Scroller.ScrollToVerticalOffset(0);Scroller.UpdateLayout();@@ -51,8 +54,10 @@ namespace GTweak.Assets.UserControlsLoaded += delegate{App.LanguageChanged += OnLanguageChanged;+if (FunctionDescription != null){+ UpdateFlowDirection();TypewriterAnimation.Create(DefaultText, FunctionDescription, TimeSpan.FromMilliseconds(300));}};@@ -62,15 +67,6 @@ namespace GTweak.Assets.UserControlsApp.LanguageChanged -= OnLanguageChanged;_scrollCts?.Cancel();};-- App.LanguageChanged += delegate- {- _scrollCts?.Cancel();- if (FunctionDescription != null)- {- TypewriterAnimation.Create(DefaultText, FunctionDescription, TimeSpan.Zero);- }- };}private void OnLanguageChanged(object sender, EventArgs e)@@ -78,10 +74,23 @@ namespace GTweak.Assets.UserControls_scrollCts?.Cancel();if (FunctionDescription != null){+ UpdateFlowDirection();TypewriterAnimation.Create(DefaultText, FunctionDescription, TimeSpan.Zero);}}+ private void UpdateFlowDirection()+ {+ if (FunctionDescription != null)+ {+ try+ {+ FunctionDescription.FlowDirection = CultureInfo.GetCultureInfo(SettingsEngine.Language).TextInfo.IsRightToLeft ? FlowDirection.RightToLeft : FlowDirection.LeftToRight;+ }+ catch (CultureNotFoundException) { FunctionDescription.FlowDirection = FlowDirection.LeftToRight; }+ }+ }+private async Task StartAutoScrollAsync(string text, CancellationToken token){await Task.Delay(2000, token);diff --git a/.Source/GTweak/Languages/LanguageCatalog.xaml b/.Source/GTweak/Languages/LanguageCatalog.xamlindex 83f9f13a..afa1ddab 100644--- a/.Source/GTweak/Languages/LanguageCatalog.xaml+++ b/.Source/GTweak/Languages/LanguageCatalog.xaml@@ -24,5 +24,6 @@<v:String x:Key="zh_tw">繁體中文 (TW)</v:String><v:String x:Key="zh_cn">简体中文 (CN)</v:String><v:String x:Key="tr">Türkçe (TR)</v:String>-+ <v:String x:Key="th">ไทย (TH)</v:String>+</ResourceDictionary>diff --git a/.Source/GTweak/Utilities/Animation/TypewriterAnimation.cs b/.Source/GTweak/Utilities/Animation/TypewriterAnimation.csindex 66aba32b..1ea055cb 100644--- a/.Source/GTweak/Utilities/Animation/TypewriterAnimation.cs+++ b/.Source/GTweak/Utilities/Animation/TypewriterAnimation.cs@@ -1,4 +1,5 @@using System;+using System.Globalization;using System.Text;using System.Windows;using System.Windows.Controls;@@ -43,6 +44,8 @@ namespace GTweak.Utilities.Animation}}++private static StringAnimationUsingKeyFrames CreateStringAnimation(in string textToAnimate, in TimeSpan timeSpan){StringAnimationUsingKeyFrames stringAnimation = new StringAnimationUsingKeyFrames@@ -50,17 +53,26 @@ namespace GTweak.Utilities.AnimationDuration = new Duration(timeSpan)};- StringBuilder temp = new StringBuilder();- int totalChars = textToAnimate?.Length ?? 0;+ if (string.IsNullOrEmpty(textToAnimate))+ {+ return stringAnimation;+ }++ StringInfo stringInfo = new StringInfo(textToAnimate);+ int totalElements = stringInfo.LengthInTextElements;- if (totalChars != 0)+ if (totalElements > 0){- double millisecondsPerChar = timeSpan.TotalMilliseconds / totalChars;+ double millisecondsPerElement = timeSpan.TotalMilliseconds / totalElements;+ StringBuilder temp = new StringBuilder();- for (int i = 0; i < totalChars; i++)+ TextElementEnumerator enumerator = StringInfo.GetTextElementEnumerator(textToAnimate);+ int index = 0;++ while (enumerator.MoveNext()){- temp.Append(textToAnimate[i]);- TimeSpan currentTime = TimeSpan.FromMilliseconds(millisecondsPerChar * (i + 1));+ temp.Append(enumerator.GetTextElement());+ TimeSpan currentTime = TimeSpan.FromMilliseconds(millisecondsPerElement * (index + 1));DiscreteStringKeyFrame keyFrame = new DiscreteStringKeyFrame{@@ -69,13 +81,13 @@ namespace GTweak.Utilities.Animation};stringAnimation.KeyFrames.Add(keyFrame);+ index++;}Timeline.SetDesiredFrameRate(stringAnimation, 60);- return stringAnimation;}return stringAnimation;}}-}\ No newline at end of file+}