- [DEVEXPRESS] Chia sẻ source code cách tạo biểu đồ sơ đồ tổ chức công ty Org Chart trên Winform C#
- [C#] Hướng dẫn tạo Auto Number trên Datagridview winform
- [DATABASE] Hướng dẫn tạo Procedure String Split in Mysql
- [C#] Thiết lập dấu (,) hay dấu (.) ở định dạng số đúng với định dạng số Việt Nam
- [C#] Chia sẻ source code Game Spin Lucky Wheel
- [C#] Hướng dẫn Encode and Decode HTML
- Danh sách tài khoản ChatGPT miễn phí - Hướng dẫn tạo tài khoản Chat Open AI GPT tại Việt Nam
- [C#] Hướng dẫn thay đổi giao diện ứng dụng Winform theo giao diện của Windows
- [VB.NET] Hiệu ứng Acrylic, Mica, Tabbed Blur Effect trên Winform
- [DEVEXPRESS] Hướng dẫn sử dụng HTML Template trên Combobox Edit
- [C#] Chia sẻ source code Orange Rain in Winform
- [DEVEXPRESS] Hướng dẫn sử dụng HTML Template trên XtraMessageBox Winform Devexpress 22.2.3
- [DEVEXPRESS] Hướng dẫn sử dụng HTML and CSS Code Viewer trên Winform
- [C#] Number Effect Counter up and down in winform
- [C#] Hướng dẫn Supend and Resume Process ID in Winform
- [C#] Hiển thị line number trên Richtextbox Winform
- [C#] Fake Blue Screen BSOD in winform
- [C#] Chia sẽ code demo sử dụng Async Parallel Foreach and For in Winform
- [C#] Sử dụng ActionBlock run X task at time winform
- [C#] Hướng dẫn sử dụng Property Grid để lưu và tải lại thông tin cấu hình user trên winform
[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!