public static string RemoveHtml(this string text) { return Regex.Replace(text, "<[^>]*>", string.Empty); } public static string HtmlEncode(this string src) { return System.Net.WebUtility.HtmlEncode(src); } public static string HtmlDecode(this string src) { return System.Net.WebUtility.HtmlDecode(src); } public static string UrlEncode(this string src) { return System.Web.HttpUtility.UrlEncode(src); } public static string UrlDecode(this string src) { return System.Web.HttpUtility.UrlDecode(src); }
Hiển thị các bài đăng có nhãn Windows Form. Hiển thị tất cả bài đăng
Hiển thị các bài đăng có nhãn Windows Form. Hiển thị tất cả bài đăng
Thứ Hai, 27 tháng 10, 2014
Remove Html Tag, Html Encode/Decode, Url Encode/Decode
Thỉnh thoảng cần dùng, lưu lại cho nhớ.
Thứ Ba, 6 tháng 11, 2012
Cách làm hiệu ứng trượt khi mở Form C# Windows Form
Hôm nay ngồi coi lại cái tool viết hồi hơn 1 năm trước, tình cờ thấy lại đoạn code hồi xưa mình làm hiệu ứng trượt khi mở form con, sẵn tiện share cách làm cho ai có hứng thú.
Kéo vào Form con 1 Time Control sau đó khai báo các biến, hàm tạo và sự kiên Form Load như sau:
Ở sự kiện time_Tick khai báo:
Ở Form cha, khi open Form con sẽ cần truyền các tham số top,left, width, heigh của mình vào Form con:
Vị trí của Form con lúc bắt đầu khởi tạo:
Sau đó Form sẽ trượt ra chính giữa:
Có thể tùy chỉnh quãng đường Form sẽ trượt tại sự kiện Form Load và tốc độ trượt của Form tại sự kiện time_Tick.
Kéo vào Form con 1 Time Control sau đó khai báo các biến, hàm tạo và sự kiên Form Load như sau:
- private int _parentTop;
- private int _parentLeft;
- private int _parentWidth;
- private int _parentHeight;
- public FrConnection(int parentTop, int parentLeft, int parentWidth, int parrentHeight)
- {
- _parentTop = parentTop;
- _parentLeft = parentLeft;
- _parentWidth = parentWidth;
- _parentHeight = parrentHeight;
- InitializeComponent();
- }
- private void FrConnection_Load(object sender, EventArgs e)
- {
- Left = _parentLeft - 50;// vị trí khởi tạo của Form
- Top = ((_parentTop + _parentHeight / 2)) - (Height / 2);
- timer.Start();
- }
- private void timer_Tick(object sender, EventArgs e)
- {
- Left += 50;// tốc độ trượt của Form
- if (Left >= ((_parentLeft + _parentWidth / 2) - Width / 2))
- {
- Left = ((_parentLeft + _parentWidth / 2)) - (Width / 2);
- Top = ((_parentTop + _parentHeight / 2)) - (Height / 2);
- timer.Stop();
- }
- }
- private void newToolStripMenuItem_Click(object sender, EventArgs e)
- {
- FrConnection fr = new FrConnection(this.Top, this.Left, this.Width, this.Height);
- fr.ShowDialog();
- }
Sau đó Form sẽ trượt ra chính giữa:
Có thể tùy chỉnh quãng đường Form sẽ trượt tại sự kiện Form Load và tốc độ trượt của Form tại sự kiện time_Tick.
Đăng ký:
Bài đăng
(
Atom
)

