- [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 Form Splash Screen Good bye
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 bạn cách tạo form Splash Screen GoodBye trong lập trình C# winform.
[C#] Splash Screen Good Bye Winform
Trong bài viết trước mình đã có hướng dẫn các bạn cách tạo Sprite Image hiển thị hình Gif Sticker Zalo.
Áp dụng bài viết đó, mình sẽ viết ứng dụng nhỏ là khi đóng Form thì sẽ xuất hiện con mèo Zalo say Good bye chạy vào trong.
Giao diện demo ứng dụng Splash Screen Say Good bye C#:
Ở hình trên, các bạn thấy khi mình đóng form thì chỉ còn xuất hiện con mèo Zalo chạy vào và kết thúc ứng dụng.
Cách thức:
Khi bấm nút form close, các bạn sẽ trigger vào event form_closing.
Và kích hoạt con Mèo Zalo chạy.
Con mèo zalo này được chứa trong PictureBox và Winform, cả hai đều được set BackColor = SystemColor.Control.
Nên chúng ta chỉ cần set TransparencyKey của Winform = SystemColor.Contro
l và set FormBorderStyle = None.
=> Thì giao diện form sẽ trong suốt và chỉ còn thấy con mèo Zalo chạy vào.
Source code ứng dụng Splash screen C#:
using ByeForm.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace ByeForm
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
timer1.Enabled = true;
ListImage = Split(Resources.bye, 130, 130);
count = ListImage.Images.Count;
label1.Visible = false;
pictureBox2.Visible = false;
//this.CenterToScreen();
pictureBox1.Location = new Point((this.Width / 2) - (pictureBox1.Width / 2),
(this.Height / 2) - (pictureBox1.Height / 2));
pictureBox1.Refresh();
this.FormBorderStyle = FormBorderStyle.None;
this.TransparencyKey = SystemColors.Control;
timer2.Enabled = true;
e.Cancel = true;
}
ImageList ListImage;
int count = 0;
int i = 0;
private ImageList Split(Bitmap image, int width, int height)
{
ImageList rows = new ImageList();
rows.ImageSize = new Size(width, height);
rows.Images.AddStrip(image);
ImageList cells = new ImageList();
cells.ImageSize = new Size(width, height);
foreach (Image row in rows.Images)
{
cells.Images.AddStrip(row);
}
return cells;
}
int s = 0;
private void timer1_Tick(object sender, EventArgs e)
{
s++;
if (s == 3)
{
Thread.Sleep(500);
timer1.Enabled = false;
Process.GetCurrentProcess().Kill();
}
}
private void timer2_Tick(object sender, EventArgs e)
{
pictureBox1.Image = ListImage.Images[i];
i++;
if (i == count) { i = 0; }
}
}
}
Thanks for watching!