Posted
so uh i found this thing like yesterday
https://i.gyazo.com/b4bdc7a9d4a176a5d82b002bbe80c378.mp4
and uh i wanted to recreate in c# so uh here it is
private static DispatcherTimer Timer;
public static Task AnimateText(DependencyObject Object, string Property, string Text, int Milliseconds = 5)
{
PropertyInfo Prop = Object.GetType().GetProperty(Property);
if (Prop == null || !(Prop.GetValue(Object) is string CurrentText))
{
return Task.CompletedTask;
}
// var Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~`!@#$%^&*()_+{}|\\/<>;':\"";
double Iteration = 0.0;
if (Timer != null)
{
Timer.Stop();
Timer = null;
}
Timer = new DispatcherTimer
{
Interval = TimeSpan.FromMilliseconds(Milliseconds),
};
Timer.Tick += (sender, args) =>
{
// var NewText = new string(CurrentText.Select((c, i) => i < Iteration ? Text[i] : Letters[new Random().Next(0, Letters.Length - 1)]).ToArray());
Prop.SetValue(Object, new string(CurrentText.Select((c, i) => i < Iteration ? Text[i] : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890~`!@#$%^&*()_+{}|\\/<>;':\""[new Random().Next(0, 86)]).ToArray()));
if (Iteration >= Text.Length)
{
Timer.Stop();
Timer = null;
}
Iteration += 1.0 / 3.0;
};
Timer.Start();
return Task.CompletedTask;
}
so uh to use it, you go like:
AnimateText(YOUR_WPF_OBJECT_NAME, "THE PROPERTY NAME, LIKE Content OR SOMETHING", "YOUR DESIRED TEXT", THIS_ONE_CAN_BE_LEFT_OUT_ITS_JUST_TIME);
its for wpf, you can change it to fit winforms or the console, im too lazy to do that
uh yeah, the effect isnt the same as I wanted, instead of going from "ASDIUA" to something like "Remove", it goes like "YYYYYY" to "Remove", I need help on that, i have no goddamn idea on how to fix that
https://i.gyazo.com/5cf4a92fecfc49369875f8748aa01b3a.mp4
Added
also i think it bugs out when you try it on a window title
Cancel
Post
Users viewing this thread:
( Members: 0, Guests: 1, Total: 1 )
Cancel
Post