NEWS

[C#] Hiệu ứng Text Effect Console trong Winform

[C#] Hiệu ứng Text Effect Console trong Winform
Đăng bởi: Thảo Meo - Lượt xem: 4428 12:52:45, 24/09/2019DEVEXPRESS   In bài viết

Xin chào các bạn, bài viết hôm nay mình sẽ demo cho các bạn Text Effect Console ASCII trong lập trình C# winform.

[C#] Text Effect Console Winform

Thường các bạn hay nhìn thấy các ứng dụng Crack, khi chạy giao diện Console thì thường có chạy những hiệu ứng Text Effect để show tên phần mềm hoặc tác giả.

Giao diện demo ứng dụng Text Effect Console Winform.

TEXT_EFFECT

Để chuyển đổi Convert Text sang mã ASCII, các bạn truy cập vào đường dẫn bên dưới để chuyển đổi.

http://patorjk.com/software/taag/#p=display&f=Doom&t=VB.NET

Nếu các bạn muốn convert hình ảnh sang mã ASCII, các bạn có thể đọc thêm bài viết ở đây:

Convert Image To ASCII C#

Tiếp theo, các bạn tạo cho mình một class EText.cs với nội dung như sau:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TextEffectConsole
{
    class EText
    {
        int x, X, y, index, k, l;
        string s;
        ConsoleColor[] cl;
        ConsoleColor cl1, cl2;
        Random r;
        int iColor, nColor;
        public EText(string s, int x, int y)
        {
            this.x = x;
            this.y = y;
            X = x;
            k = 0;
            this.s = s;
            l = s.Length;
            index = l - 1;
            cl = new ConsoleColor[] { ConsoleColor.Magenta, ConsoleColor.Yellow, ConsoleColor.Red, ConsoleColor.White, ConsoleColor.Black, ConsoleColor.Green };
            nColor = cl.Length;
            cl1 = ConsoleColor.Black;
            cl2 = ConsoleColor.Green;
            r = new Random();
            iColor = 0;
        }
        public void ve()
        {

            Console.SetCursorPosition(X, y);
            for (int i = k; i < l; i++)
            {
                Console.ForegroundColor = cl1;
                if (i == index)
                {
                    Console.ForegroundColor = cl2;
                }

                Console.Write(s[i]);

            }

            if (index == k)
            {
                k++;
                X++;
                index = l;
            }
            if (k == l - 1)
            {
                k = 0;
                X = x;
                cl1 = cl2;
                cl2 = cl[iColor];
                iColor++;
                if (iColor == nColor)
                {
                    iColor = 0;
                }
            }
            index--;

        }

    }
}

Và tiếp theo là source code của file program.cs C#:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace TextEffectConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.CursorVisible = false;
            string[] str = new string[]
            {    @"_   _______  _   _  _____ _____",
                @"| | | | ___ |  | ||  ___|_   _|",
                @"| | | | |_/ /|  | || |__   | |",
                @"| | | | ___ | . ` ||  __|  | |",
                @" \_/ / |_/ /| |  || |___  | |",
                @" \___/\____(_)_| \_/\____/  \_/ " };





            int n = str.Length;

            EText[] ET = new EText[n];
            int x, y;
            x = 15;
            y = 8;
            for (int i = 0; i < n; i++)
            {
                ET[i] = new EText(str[i], x, y + i);
            }

            while (true)
            {
                while (true)
                {
                    foreach (EText et in ET)
                    {
                        et.ve();
                    }
                }

            }
        }
    }
    
}

HAVE FUN :)

 

DOWNLOAD SOURCE

THÔNG TIN TÁC GIẢ

BÀI VIẾT LIÊN QUAN

[C#] Hiệu ứng Text Effect Console trong Winform
Đăng bởi: Thảo Meo - Lượt xem: 4428 12:52:45, 24/09/2019DEVEXPRESS   In bài viết

CÁC BÀI CÙNG CHỦ ĐỀ

Đọc tiếp
.