Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Threading;
- namespace Testprojekt1337
- {
- class Program
- {
- static void Main(string[] args)
- {
- WriteText("Lorem ipsum dolor sit amet, consetetur sadipscing elitr, ", 100);
- WriteText("ed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.", 100, true);
- Loading('.', 300,11, 3);
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="t">Der Text</param>
- /// <param name="interval">Der Abstand zwischen den Zeichen</param>
- /// <param name="isLine">Ob eine neue Linie "erstellt" werden soll</param>
- static void WriteText(string t, int interval, bool isLine = false)
- {
- foreach (char chr in t)
- {
- //gibt den Buchstaben/Zeichen etc aus.
- Console.Write(chr);
- // Wartet
- System.Threading.Thread.Sleep(interval);
- }
- //Wenn isLine = true ist, dann wird ne neue Linie "erstellt"
- if (isLine)
- Console.WriteLine();
- }
- /// <summary>
- ///
- /// </summary>
- /// <param name="chr">Den Character zB . </param>
- /// <param name="interval">Der Abstand zwischen den Zeichen</param>
- /// <param name="repeat">Wie oft das wiederholt werden soll</param>
- /// <param name="maxlength">Maximale Länge der Linie</param>
- static void Loading(char chr, int interval, int repeat = 4, int maxlength = 3)
- {
- //aktuelle Wiederholung
- int currrepeat = 0;
- // so lange currrepeat kleiner ist als repeat
- while (currrepeat < repeat)
- {
- //currrepeat um 1 vergrössern
- currrepeat++;
- //aktuelle Länge
- int currlength = 0;
- //so lange currlength kleiner ist als maxlength
- while (currlength < maxlength)
- {
- //currlength um 1 vergrössern
- currlength++;
- //gibt den Char aus.
- Console.Write(chr);
- //Wartet
- Thread.Sleep(interval);
- }
- //löscht die Linie
- Console.SetCursorPosition(0, Console.CursorTop);
- Console.Write(new string(' ', Console.WindowWidth));
- Console.SetCursorPosition(0, Console.CursorTop - 1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment