- [C#] Hướng dẫn fix lỗi Visual Studio 2022 not Support Target Net Framework 4.5.2
- [C#] Giới thiệu thư viện Sunny UI thiết kế giao diện trên Winform
- [DATABASE] Hướng dẫn thêm và cập nhật Extended Property Column trong Table Sqlserver
- [DEVEXPRESS] Hướng dẫn sử dụng Vertical Gridview để hiển thị thông tin sản phẩm
- [C#] Hướng dẫn sử dụng Json Schema để Validate chuỗi string có phải json
- [C#] Hướng dẫn sử dụng công cụ Clean Code trên Visual Studio
- [C#] Hướng dẫn Drag and Drop File vào RichTextBox
- [C#] Hướng dẫn tạo hiệu ứng Karaoke Text Effect Winform
- [C#] Sử dụng thư viện ZedGraph vẽ biểu đồ Line, Bar, Pie trên Winform
- [DATABASE] Hướng dẫn sort sắp xếp địa chỉ IP trên sqlserver sử dụng hàm PARSENAME
- [C#] Theo dõi sử kiện process Start hay Stop trên Winform
- [ASP.NET] Chia sẻ source code chụp hình sử dụng camera trên website
- [C#] Chạy ứng dụng trên Virtual Desktop (màn hình ảo) Winform
- [C#] Mã hóa và giải mã Data Protection API trên winform
- [C#] Hướng dẫn tạo Gradient Background trên Winform
- [DATABASE] Hướng dẫn convert Epoch to DateTime trong sqlserver
- [DATABASE] Hướng dẫn sử dụng STRING_AGG và CONCAT_WS trong sqlserver 2017
- [C#] Hướng dẫn Copy With All Property in Class Object
- [DEVEXPRESS] Hướng dẫn load Json DataSource vào GridView
- [C#] Hướng dẫn tạo chữ ký trên winform Signature Pad
[C#] Hướng dẫn tạo hiệu ứng text Fake Typer Effect Winform
Xin chào các bạn, bài viết hôm nay mình sẽ tiếp tục hướng dẫn các bạn cách tạo hiệu ứng Auto Fake Typer Text Effect trong lập trình C# Winform.
Các bạn có thể sử dụng bài hướng dẫn này để làm cho form giới thiệu ứng dụng.
Hoặc dùng trong các form giống mấy form tạo key gen, hay tool auto...
Dưới đây là giao diện demo ứng dụng Auto Fake Typer Text Effect C# Winform:
Source code C# Text Effect:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace FakerType_TextEffect
{
public partial class Form1 : Form
{
private char[] _chars;
private int _index;
public Form1()
{
InitializeComponent();
_chars = richTextBox1.Text.ToCharArray();
}
private void richTextBox2_KeyPress(object sender, KeyPressEventArgs e)
{
if(_index< _chars.Length)
{
//richTextBox2.Text += _chars[_index];
richTextBox2.AppendText(_chars[_index] + "");
_index++;
}
e.Handled = true;
}
bool flag = false;
private void timer1_Tick(object sender, EventArgs e)
{
string a = "";
if (_index < _chars.Length)
{
if(_index > 0)
{
a = _chars[_index - 1].ToString();
}
if(a == "
")
{
flag = true;
}
else
{
flag = false;
}
//richTextBox2.Text += _chars[_index];
richTextBox2.AppendText(_chars[_index] + "");
_index++;
}
}
private void chk_auto_CheckedChanged(object sender, EventArgs e)
{
if (chk_auto.Checked)
{
richTextBox2.Clear();
richTextBox2.Focus();
timer1.Start();
_index = 0;
}
else
{
timer1.Stop();
}
}
private void richTextBox2_TextChanged(object sender, EventArgs e)
{
richTextBox2.SelectionStart = richTextBox2.Text.Length;
if (!richTextBox2.ReachedBottom() && flag)
{
richTextBox2.ScrollToCaret();
}
}
}
public static class RichTextBoxExtension
{
[DllImport("user32")]
private static extern int GetScrollInfo(IntPtr hwnd, int nBar,
ref SCROLLINFO scrollInfo);
public struct SCROLLINFO
{
public int cbSize;
public int fMask;
public int min;
public int max;
public int nPage;
public int nPos;
public int nTrackPos;
}
public static bool ReachedBottom(this RichTextBox rtb)
{
SCROLLINFO scrollInfo = new SCROLLINFO();
scrollInfo.cbSize = Marshal.SizeOf(scrollInfo);
//SIF_RANGE = 0x1, SIF_TRACKPOS = 0x10, SIF_PAGE= 0x2
scrollInfo.fMask = 0x10 | 0x1 | 0x2;
GetScrollInfo(rtb.Handle, 1, ref scrollInfo);//nBar = 1 -> VScrollbar
return scrollInfo.max == scrollInfo.nTrackPos + scrollInfo.nPage + 1;
}
}
}
Thanks for watching!