diff --git a/Artorio/About.xaml b/Artorio/About.xaml index a92fdc7..d806427 100644 --- a/Artorio/About.xaml +++ b/Artorio/About.xaml @@ -6,7 +6,7 @@ xmlns:local="clr-namespace:Artorio" mc:Ignorable="d" ResizeMode="NoResize" - Title="About" Height="172.637" Width="415.604"> + Title="About" Height="205" Width="415.604"> @@ -15,6 +15,7 @@ + diff --git a/Artorio/About.xaml.cs b/Artorio/About.xaml.cs index 0e63555..cbef337 100644 --- a/Artorio/About.xaml.cs +++ b/Artorio/About.xaml.cs @@ -17,6 +17,7 @@ public About() InsertLink("https://github.com/EFLFE/Artorio", githubLink); InsertLink("https://github.com/leonbloy/pngcs", pngcs); InsertLink("http://www.componentace.com/zlib_.NET.htm", zlib); + InsertLink("https://github.com/PixiEditor/ColorPicker", colorPicker); } private void InsertLink(string link, TextBlock target) diff --git a/Artorio/CountTextAnimation.cs b/Artorio/CountTextAnimation.cs new file mode 100644 index 0000000..7a0e89b --- /dev/null +++ b/Artorio/CountTextAnimation.cs @@ -0,0 +1,54 @@ +using System; +using System.Windows.Controls; +using System.Windows.Threading; + +namespace Artorio +{ + internal class CountTextAnimation + { + private TextBlock textBlock; + private DispatcherTimer timer; + private float targetValue; + private float currentValue; + private float timeLerp; + private string displayText; + + private const float timeSpeed = 0.03f; + + public CountTextAnimation(TextBlock textBlock, Dispatcher dispatcher, string displayText) + { + timeLerp = 1f; + this.displayText = displayText; + this.textBlock = textBlock; + timer = new DispatcherTimer(TimeSpan.FromSeconds(0.01), DispatcherPriority.Background, Tick, dispatcher); + } + + public void SetTarget(int value, string displayText = null) + { + if (displayText != null) + this.displayText = displayText; + + targetValue = value; + timeLerp = 0f; + timer.Start(); + } + + private void Tick(object s, EventArgs e) + { + if (timeLerp >= 1f) + { + timer.Stop(); + return; + } + + timeLerp += timeSpeed; + + if (timeLerp > 1f) + timeLerp = 1f; + + currentValue += timeLerp * (targetValue - currentValue); + textBlock.Text = displayText.Replace("#", Math.Round(currentValue).ToString()); + } + + } +} diff --git a/Artorio/MainWindow.xaml.cs b/Artorio/MainWindow.xaml.cs index 7b2ca22..bfb3b25 100644 --- a/Artorio/MainWindow.xaml.cs +++ b/Artorio/MainWindow.xaml.cs @@ -154,7 +154,6 @@ private IEnumerable ForeachColorItemCast() for (int i = 0; i < configStack.Children.Count - 1; i++) { - // TODO: Optimize yield return (ColorItemCast)configStack.Children[i]; } }